changed the style of h2-ascii.ads and made related changes

This commit is contained in:
hyung-hwan 2014-01-10 08:12:40 +00:00
parent d502f1ab4c
commit bec5235659
3 changed files with 352 additions and 207 deletions

View File

@ -2,16 +2,22 @@ BEGIN {
printf ("-- Generated with ascii.txt and ascii.awk\n"); printf ("-- Generated with ascii.txt and ascii.awk\n");
printf ("-- Run qseawk -f ascii.awk ascii.txt > h2-ascii.ads for regeneration\n\n"); printf ("-- Run qseawk -f ascii.awk ascii.txt > h2-ascii.ads for regeneration\n\n");
printf ("generic\n\ttype Character_Type is (<>);\npackage H2.Ascii is\n\n"); printf ("generic\n\ttype Character_Type is (<>);\npackage H2.Ascii is\n\n");
printf ("\tpackage Pos is\n");
} }
{ {
t = sprintf ("%c", NR - 1); t = sprintf ("%c", NR - 1);
if (str::isprint(t)) t = " -- " t; if (str::isprint(t)) t = " -- " t;
else t=""; else t="";
printf ("\t%-20s: constant Character_Type := Character_Type'Val(%d);%s\n", $1, NR - 1, t); printf ("\t\t%-20s: constant := %d;%s\n", $1, NR-1, t);
X[NR - 1] = $1;
} }
END { END {
printf ("\tend Pos;\n\n");
for (i = 0; i < length(X); i++)
{
printf ("\t%-20s: constant Character_Type := Character_Type'Val(Pos.%s);\n", X[i], X[i]);
}
printf ("\nend H2.Ascii;\n"); printf ("\nend H2.Ascii;\n");
} }

View File

@ -5,133 +5,264 @@ generic
type Character_Type is (<>); type Character_Type is (<>);
package H2.Ascii is package H2.Ascii is
NUL : constant Character_Type := Character_Type'Val(0); package Pos is
SOH : constant Character_Type := Character_Type'Val(1); NUL : constant := 0;
STX : constant Character_Type := Character_Type'Val(2); SOH : constant := 1;
ETX : constant Character_Type := Character_Type'Val(3); STX : constant := 2;
EOT : constant Character_Type := Character_Type'Val(4); ETX : constant := 3;
ENQ : constant Character_Type := Character_Type'Val(5); EOT : constant := 4;
ACK : constant Character_Type := Character_Type'Val(6); ENQ : constant := 5;
BEL : constant Character_Type := Character_Type'Val(7); ACK : constant := 6;
BS : constant Character_Type := Character_Type'Val(8); BEL : constant := 7;
HT : constant Character_Type := Character_Type'Val(9); BS : constant := 8;
LF : constant Character_Type := Character_Type'Val(10); HT : constant := 9;
VT : constant Character_Type := Character_Type'Val(11); LF : constant := 10;
FF : constant Character_Type := Character_Type'Val(12); VT : constant := 11;
CR : constant Character_Type := Character_Type'Val(13); FF : constant := 12;
SO : constant Character_Type := Character_Type'Val(14); CR : constant := 13;
SI : constant Character_Type := Character_Type'Val(15); SO : constant := 14;
DLE : constant Character_Type := Character_Type'Val(16); SI : constant := 15;
DC1 : constant Character_Type := Character_Type'Val(17); DLE : constant := 16;
DC2 : constant Character_Type := Character_Type'Val(18); DC1 : constant := 17;
DC3 : constant Character_Type := Character_Type'Val(19); DC2 : constant := 18;
DC4 : constant Character_Type := Character_Type'Val(20); DC3 : constant := 19;
NAK : constant Character_Type := Character_Type'Val(21); DC4 : constant := 20;
SYN : constant Character_Type := Character_Type'Val(22); NAK : constant := 21;
ETB : constant Character_Type := Character_Type'Val(23); SYN : constant := 22;
CAN : constant Character_Type := Character_Type'Val(24); ETB : constant := 23;
EM : constant Character_Type := Character_Type'Val(25); CAN : constant := 24;
SUB : constant Character_Type := Character_Type'Val(26); EM : constant := 25;
ESC : constant Character_Type := Character_Type'Val(27); SUB : constant := 26;
FS : constant Character_Type := Character_Type'Val(28); ESC : constant := 27;
GS : constant Character_Type := Character_Type'Val(29); FS : constant := 28;
RS : constant Character_Type := Character_Type'Val(30); GS : constant := 29;
US : constant Character_Type := Character_Type'Val(31); RS : constant := 30;
Space : constant Character_Type := Character_Type'Val(32); -- US : constant := 31;
Exclamation : constant Character_Type := Character_Type'Val(33); -- ! Space : constant := 32; --
Quotation : constant Character_Type := Character_Type'Val(34); -- " Exclamation : constant := 33; -- !
Number_Sign : constant Character_Type := Character_Type'Val(35); -- # Quotation : constant := 34; -- "
Dollar_Sign : constant Character_Type := Character_Type'Val(36); -- $ Number_Sign : constant := 35; -- #
Percent_Sign : constant Character_Type := Character_Type'Val(37); -- % Dollar_Sign : constant := 36; -- $
Ampersand : constant Character_Type := Character_Type'Val(38); -- & Percent_Sign : constant := 37; -- %
Apostrophe : constant Character_Type := Character_Type'Val(39); -- ' Ampersand : constant := 38; -- &
Left_Parenthesis : constant Character_Type := Character_Type'Val(40); -- ( Apostrophe : constant := 39; -- '
Right_Parenthesis : constant Character_Type := Character_Type'Val(41); -- ) Left_Parenthesis : constant := 40; -- (
Asterisk : constant Character_Type := Character_Type'Val(42); -- * Right_Parenthesis : constant := 41; -- )
Plus_Sign : constant Character_Type := Character_Type'Val(43); -- + Asterisk : constant := 42; -- *
Comma : constant Character_Type := Character_Type'Val(44); -- , Plus_Sign : constant := 43; -- +
Minus_Sign : constant Character_Type := Character_Type'Val(45); -- - Comma : constant := 44; -- ,
Period : constant Character_Type := Character_Type'Val(46); -- . Minus_Sign : constant := 45; -- -
Slash : constant Character_Type := Character_Type'Val(47); -- / Period : constant := 46; -- .
Zero : constant Character_Type := Character_Type'Val(48); -- 0 Slash : constant := 47; -- /
One : constant Character_Type := Character_Type'Val(49); -- 1 Zero : constant := 48; -- 0
Two : constant Character_Type := Character_Type'Val(50); -- 2 One : constant := 49; -- 1
Three : constant Character_Type := Character_Type'Val(51); -- 3 Two : constant := 50; -- 2
Four : constant Character_Type := Character_Type'Val(52); -- 4 Three : constant := 51; -- 3
Five : constant Character_Type := Character_Type'Val(53); -- 5 Four : constant := 52; -- 4
Six : constant Character_Type := Character_Type'Val(54); -- 6 Five : constant := 53; -- 5
Seven : constant Character_Type := Character_Type'Val(55); -- 7 Six : constant := 54; -- 6
Eight : constant Character_Type := Character_Type'Val(56); -- 8 Seven : constant := 55; -- 7
Nine : constant Character_Type := Character_Type'Val(57); -- 9 Eight : constant := 56; -- 8
Colon : constant Character_Type := Character_Type'Val(58); -- : Nine : constant := 57; -- 9
Semicolon : constant Character_Type := Character_Type'Val(59); -- ; Colon : constant := 58; -- :
Less_Than_Sign : constant Character_Type := Character_Type'Val(60); -- < Semicolon : constant := 59; -- ;
Equals_Sign : constant Character_Type := Character_Type'Val(61); -- = Less_Than_Sign : constant := 60; -- <
Greater_Than_Sign : constant Character_Type := Character_Type'Val(62); -- > Equals_Sign : constant := 61; -- =
Question : constant Character_Type := Character_Type'Val(63); -- ? Greater_Than_Sign : constant := 62; -- >
Commercial_At : constant Character_Type := Character_Type'Val(64); -- @ Question : constant := 63; -- ?
UC_A : constant Character_Type := Character_Type'Val(65); -- A Commercial_At : constant := 64; -- @
UC_B : constant Character_Type := Character_Type'Val(66); -- B UC_A : constant := 65; -- A
UC_C : constant Character_Type := Character_Type'Val(67); -- C UC_B : constant := 66; -- B
UC_D : constant Character_Type := Character_Type'Val(68); -- D UC_C : constant := 67; -- C
UC_E : constant Character_Type := Character_Type'Val(69); -- E UC_D : constant := 68; -- D
UC_F : constant Character_Type := Character_Type'Val(70); -- F UC_E : constant := 69; -- E
UC_G : constant Character_Type := Character_Type'Val(71); -- G UC_F : constant := 70; -- F
UC_H : constant Character_Type := Character_Type'Val(72); -- H UC_G : constant := 71; -- G
UC_I : constant Character_Type := Character_Type'Val(73); -- I UC_H : constant := 72; -- H
UC_J : constant Character_Type := Character_Type'Val(74); -- J UC_I : constant := 73; -- I
UC_K : constant Character_Type := Character_Type'Val(75); -- K UC_J : constant := 74; -- J
UC_L : constant Character_Type := Character_Type'Val(76); -- L UC_K : constant := 75; -- K
UC_M : constant Character_Type := Character_Type'Val(77); -- M UC_L : constant := 76; -- L
UC_N : constant Character_Type := Character_Type'Val(78); -- N UC_M : constant := 77; -- M
UC_O : constant Character_Type := Character_Type'Val(79); -- O UC_N : constant := 78; -- N
UC_P : constant Character_Type := Character_Type'Val(80); -- P UC_O : constant := 79; -- O
UC_Q : constant Character_Type := Character_Type'Val(81); -- Q UC_P : constant := 80; -- P
UC_R : constant Character_Type := Character_Type'Val(82); -- R UC_Q : constant := 81; -- Q
UC_S : constant Character_Type := Character_Type'Val(83); -- S UC_R : constant := 82; -- R
UC_T : constant Character_Type := Character_Type'Val(84); -- T UC_S : constant := 83; -- S
UC_U : constant Character_Type := Character_Type'Val(85); -- U UC_T : constant := 84; -- T
UC_V : constant Character_Type := Character_Type'Val(86); -- V UC_U : constant := 85; -- U
UC_W : constant Character_Type := Character_Type'Val(87); -- W UC_V : constant := 86; -- V
UC_X : constant Character_Type := Character_Type'Val(88); -- X UC_W : constant := 87; -- W
UC_Y : constant Character_Type := Character_Type'Val(89); -- Y UC_X : constant := 88; -- X
UC_Z : constant Character_Type := Character_Type'Val(90); -- Z UC_Y : constant := 89; -- Y
Left_Square_Bracket : constant Character_Type := Character_Type'Val(91); -- [ UC_Z : constant := 90; -- Z
Backslash : constant Character_Type := Character_Type'Val(92); -- \ Left_Square_Bracket : constant := 91; -- [
Right_Square_Bracket: constant Character_Type := Character_Type'Val(93); -- ] Backslash : constant := 92; -- \
Circumflex : constant Character_Type := Character_Type'Val(94); -- ^ Right_Square_Bracket: constant := 93; -- ]
Low_Line : constant Character_Type := Character_Type'Val(95); -- _ Circumflex : constant := 94; -- ^
Grave : constant Character_Type := Character_Type'Val(96); -- ` Low_Line : constant := 95; -- _
LC_A : constant Character_Type := Character_Type'Val(97); -- a Grave : constant := 96; -- `
LC_B : constant Character_Type := Character_Type'Val(98); -- b LC_A : constant := 97; -- a
LC_C : constant Character_Type := Character_Type'Val(99); -- c LC_B : constant := 98; -- b
LC_D : constant Character_Type := Character_Type'Val(100); -- d LC_C : constant := 99; -- c
LC_E : constant Character_Type := Character_Type'Val(101); -- e LC_D : constant := 100; -- d
LC_F : constant Character_Type := Character_Type'Val(102); -- f LC_E : constant := 101; -- e
LC_G : constant Character_Type := Character_Type'Val(103); -- g LC_F : constant := 102; -- f
LC_H : constant Character_Type := Character_Type'Val(104); -- h LC_G : constant := 103; -- g
LC_I : constant Character_Type := Character_Type'Val(105); -- i LC_H : constant := 104; -- h
LC_J : constant Character_Type := Character_Type'Val(106); -- j LC_I : constant := 105; -- i
LC_K : constant Character_Type := Character_Type'Val(107); -- k LC_J : constant := 106; -- j
LC_L : constant Character_Type := Character_Type'Val(108); -- l LC_K : constant := 107; -- k
LC_M : constant Character_Type := Character_Type'Val(109); -- m LC_L : constant := 108; -- l
LC_N : constant Character_Type := Character_Type'Val(110); -- n LC_M : constant := 109; -- m
LC_O : constant Character_Type := Character_Type'Val(111); -- o LC_N : constant := 110; -- n
LC_P : constant Character_Type := Character_Type'Val(112); -- p LC_O : constant := 111; -- o
LC_Q : constant Character_Type := Character_Type'Val(113); -- q LC_P : constant := 112; -- p
LC_R : constant Character_Type := Character_Type'Val(114); -- r LC_Q : constant := 113; -- q
LC_S : constant Character_Type := Character_Type'Val(115); -- s LC_R : constant := 114; -- r
LC_T : constant Character_Type := Character_Type'Val(116); -- t LC_S : constant := 115; -- s
LC_U : constant Character_Type := Character_Type'Val(117); -- u LC_T : constant := 116; -- t
LC_V : constant Character_Type := Character_Type'Val(118); -- v LC_U : constant := 117; -- u
LC_W : constant Character_Type := Character_Type'Val(119); -- w LC_V : constant := 118; -- v
LC_X : constant Character_Type := Character_Type'Val(120); -- x LC_W : constant := 119; -- w
LC_Y : constant Character_Type := Character_Type'Val(121); -- y LC_X : constant := 120; -- x
LC_Z : constant Character_Type := Character_Type'Val(122); -- z LC_Y : constant := 121; -- y
Left_Curly_Bracket : constant Character_Type := Character_Type'Val(123); -- { LC_Z : constant := 122; -- z
Vertical_Line : constant Character_Type := Character_Type'Val(124); -- | Left_Curly_Bracket : constant := 123; -- {
Right_Curly_Bracket : constant Character_Type := Character_Type'Val(125); -- } Vertical_Line : constant := 124; -- |
Tilde : constant Character_Type := Character_Type'Val(126); -- ~ Right_Curly_Bracket : constant := 125; -- }
DEL : constant Character_Type := Character_Type'Val(127); Tilde : constant := 126; -- ~
DEL : constant := 127;
end Pos;
NUL : constant Character_Type := Character_Type'Val(Pos.NUL);
SOH : constant Character_Type := Character_Type'Val(Pos.SOH);
STX : constant Character_Type := Character_Type'Val(Pos.STX);
ETX : constant Character_Type := Character_Type'Val(Pos.ETX);
EOT : constant Character_Type := Character_Type'Val(Pos.EOT);
ENQ : constant Character_Type := Character_Type'Val(Pos.ENQ);
ACK : constant Character_Type := Character_Type'Val(Pos.ACK);
BEL : constant Character_Type := Character_Type'Val(Pos.BEL);
BS : constant Character_Type := Character_Type'Val(Pos.BS);
HT : constant Character_Type := Character_Type'Val(Pos.HT);
LF : constant Character_Type := Character_Type'Val(Pos.LF);
VT : constant Character_Type := Character_Type'Val(Pos.VT);
FF : constant Character_Type := Character_Type'Val(Pos.FF);
CR : constant Character_Type := Character_Type'Val(Pos.CR);
SO : constant Character_Type := Character_Type'Val(Pos.SO);
SI : constant Character_Type := Character_Type'Val(Pos.SI);
DLE : constant Character_Type := Character_Type'Val(Pos.DLE);
DC1 : constant Character_Type := Character_Type'Val(Pos.DC1);
DC2 : constant Character_Type := Character_Type'Val(Pos.DC2);
DC3 : constant Character_Type := Character_Type'Val(Pos.DC3);
DC4 : constant Character_Type := Character_Type'Val(Pos.DC4);
NAK : constant Character_Type := Character_Type'Val(Pos.NAK);
SYN : constant Character_Type := Character_Type'Val(Pos.SYN);
ETB : constant Character_Type := Character_Type'Val(Pos.ETB);
CAN : constant Character_Type := Character_Type'Val(Pos.CAN);
EM : constant Character_Type := Character_Type'Val(Pos.EM);
SUB : constant Character_Type := Character_Type'Val(Pos.SUB);
ESC : constant Character_Type := Character_Type'Val(Pos.ESC);
FS : constant Character_Type := Character_Type'Val(Pos.FS);
GS : constant Character_Type := Character_Type'Val(Pos.GS);
RS : constant Character_Type := Character_Type'Val(Pos.RS);
US : constant Character_Type := Character_Type'Val(Pos.US);
Space : constant Character_Type := Character_Type'Val(Pos.Space);
Exclamation : constant Character_Type := Character_Type'Val(Pos.Exclamation);
Quotation : constant Character_Type := Character_Type'Val(Pos.Quotation);
Number_Sign : constant Character_Type := Character_Type'Val(Pos.Number_Sign);
Dollar_Sign : constant Character_Type := Character_Type'Val(Pos.Dollar_Sign);
Percent_Sign : constant Character_Type := Character_Type'Val(Pos.Percent_Sign);
Ampersand : constant Character_Type := Character_Type'Val(Pos.Ampersand);
Apostrophe : constant Character_Type := Character_Type'Val(Pos.Apostrophe);
Left_Parenthesis : constant Character_Type := Character_Type'Val(Pos.Left_Parenthesis);
Right_Parenthesis : constant Character_Type := Character_Type'Val(Pos.Right_Parenthesis);
Asterisk : constant Character_Type := Character_Type'Val(Pos.Asterisk);
Plus_Sign : constant Character_Type := Character_Type'Val(Pos.Plus_Sign);
Comma : constant Character_Type := Character_Type'Val(Pos.Comma);
Minus_Sign : constant Character_Type := Character_Type'Val(Pos.Minus_Sign);
Period : constant Character_Type := Character_Type'Val(Pos.Period);
Slash : constant Character_Type := Character_Type'Val(Pos.Slash);
Zero : constant Character_Type := Character_Type'Val(Pos.Zero);
One : constant Character_Type := Character_Type'Val(Pos.One);
Two : constant Character_Type := Character_Type'Val(Pos.Two);
Three : constant Character_Type := Character_Type'Val(Pos.Three);
Four : constant Character_Type := Character_Type'Val(Pos.Four);
Five : constant Character_Type := Character_Type'Val(Pos.Five);
Six : constant Character_Type := Character_Type'Val(Pos.Six);
Seven : constant Character_Type := Character_Type'Val(Pos.Seven);
Eight : constant Character_Type := Character_Type'Val(Pos.Eight);
Nine : constant Character_Type := Character_Type'Val(Pos.Nine);
Colon : constant Character_Type := Character_Type'Val(Pos.Colon);
Semicolon : constant Character_Type := Character_Type'Val(Pos.Semicolon);
Less_Than_Sign : constant Character_Type := Character_Type'Val(Pos.Less_Than_Sign);
Equals_Sign : constant Character_Type := Character_Type'Val(Pos.Equals_Sign);
Greater_Than_Sign : constant Character_Type := Character_Type'Val(Pos.Greater_Than_Sign);
Question : constant Character_Type := Character_Type'Val(Pos.Question);
Commercial_At : constant Character_Type := Character_Type'Val(Pos.Commercial_At);
UC_A : constant Character_Type := Character_Type'Val(Pos.UC_A);
UC_B : constant Character_Type := Character_Type'Val(Pos.UC_B);
UC_C : constant Character_Type := Character_Type'Val(Pos.UC_C);
UC_D : constant Character_Type := Character_Type'Val(Pos.UC_D);
UC_E : constant Character_Type := Character_Type'Val(Pos.UC_E);
UC_F : constant Character_Type := Character_Type'Val(Pos.UC_F);
UC_G : constant Character_Type := Character_Type'Val(Pos.UC_G);
UC_H : constant Character_Type := Character_Type'Val(Pos.UC_H);
UC_I : constant Character_Type := Character_Type'Val(Pos.UC_I);
UC_J : constant Character_Type := Character_Type'Val(Pos.UC_J);
UC_K : constant Character_Type := Character_Type'Val(Pos.UC_K);
UC_L : constant Character_Type := Character_Type'Val(Pos.UC_L);
UC_M : constant Character_Type := Character_Type'Val(Pos.UC_M);
UC_N : constant Character_Type := Character_Type'Val(Pos.UC_N);
UC_O : constant Character_Type := Character_Type'Val(Pos.UC_O);
UC_P : constant Character_Type := Character_Type'Val(Pos.UC_P);
UC_Q : constant Character_Type := Character_Type'Val(Pos.UC_Q);
UC_R : constant Character_Type := Character_Type'Val(Pos.UC_R);
UC_S : constant Character_Type := Character_Type'Val(Pos.UC_S);
UC_T : constant Character_Type := Character_Type'Val(Pos.UC_T);
UC_U : constant Character_Type := Character_Type'Val(Pos.UC_U);
UC_V : constant Character_Type := Character_Type'Val(Pos.UC_V);
UC_W : constant Character_Type := Character_Type'Val(Pos.UC_W);
UC_X : constant Character_Type := Character_Type'Val(Pos.UC_X);
UC_Y : constant Character_Type := Character_Type'Val(Pos.UC_Y);
UC_Z : constant Character_Type := Character_Type'Val(Pos.UC_Z);
Left_Square_Bracket : constant Character_Type := Character_Type'Val(Pos.Left_Square_Bracket);
Backslash : constant Character_Type := Character_Type'Val(Pos.Backslash);
Right_Square_Bracket: constant Character_Type := Character_Type'Val(Pos.Right_Square_Bracket);
Circumflex : constant Character_Type := Character_Type'Val(Pos.Circumflex);
Low_Line : constant Character_Type := Character_Type'Val(Pos.Low_Line);
Grave : constant Character_Type := Character_Type'Val(Pos.Grave);
LC_A : constant Character_Type := Character_Type'Val(Pos.LC_A);
LC_B : constant Character_Type := Character_Type'Val(Pos.LC_B);
LC_C : constant Character_Type := Character_Type'Val(Pos.LC_C);
LC_D : constant Character_Type := Character_Type'Val(Pos.LC_D);
LC_E : constant Character_Type := Character_Type'Val(Pos.LC_E);
LC_F : constant Character_Type := Character_Type'Val(Pos.LC_F);
LC_G : constant Character_Type := Character_Type'Val(Pos.LC_G);
LC_H : constant Character_Type := Character_Type'Val(Pos.LC_H);
LC_I : constant Character_Type := Character_Type'Val(Pos.LC_I);
LC_J : constant Character_Type := Character_Type'Val(Pos.LC_J);
LC_K : constant Character_Type := Character_Type'Val(Pos.LC_K);
LC_L : constant Character_Type := Character_Type'Val(Pos.LC_L);
LC_M : constant Character_Type := Character_Type'Val(Pos.LC_M);
LC_N : constant Character_Type := Character_Type'Val(Pos.LC_N);
LC_O : constant Character_Type := Character_Type'Val(Pos.LC_O);
LC_P : constant Character_Type := Character_Type'Val(Pos.LC_P);
LC_Q : constant Character_Type := Character_Type'Val(Pos.LC_Q);
LC_R : constant Character_Type := Character_Type'Val(Pos.LC_R);
LC_S : constant Character_Type := Character_Type'Val(Pos.LC_S);
LC_T : constant Character_Type := Character_Type'Val(Pos.LC_T);
LC_U : constant Character_Type := Character_Type'Val(Pos.LC_U);
LC_V : constant Character_Type := Character_Type'Val(Pos.LC_V);
LC_W : constant Character_Type := Character_Type'Val(Pos.LC_W);
LC_X : constant Character_Type := Character_Type'Val(Pos.LC_X);
LC_Y : constant Character_Type := Character_Type'Val(Pos.LC_Y);
LC_Z : constant Character_Type := Character_Type'Val(Pos.LC_Z);
Left_Curly_Bracket : constant Character_Type := Character_Type'Val(Pos.Left_Curly_Bracket);
Vertical_Line : constant Character_Type := Character_Type'Val(Pos.Vertical_Line);
Right_Curly_Bracket : constant Character_Type := Character_Type'Val(Pos.Right_Curly_Bracket);
Tilde : constant Character_Type := Character_Type'Val(Pos.Tilde);
DEL : constant Character_Type := Character_Type'Val(Pos.DEL);
end H2.Ascii; end H2.Ascii;

View File

@ -2438,68 +2438,57 @@ Print (Interp, Operand);
-- TODO: Pass Token Location when calling Token.Set -- TODO: Pass Token Location when calling Token.Set
-- Pity that "case .. end case" can't be used instead of "if .. end if" -- Use Ch.Pos.XXX values instead of Ch.XXX values as gnat complained that
-- because Ch.XXX values are not static. This is a pain to take -- Ch.XXX values are not static. For this reason, "case LC.Value is ..."
-- for making this package generic. -- changed to use Object_Character'Pos(LC.Value).
if LC.Value = Ch.Left_Parenthesis then case Object_Character'Pos(LC.Value) is
Token.Set (Interp, Left_Parenthesis_Token, LC.Value);
elsif LC.Value = Ch.Right_Parenthesis then
Token.Set (Interp, Right_Parenthesis_Token, LC.Value);
elsif LC.Value = Ch.Period then
Token.Set (Interp, Period_Token, LC.Value);
elsif LC.Value = Ch.Apostrophe then
Token.Set (Interp, Single_Quote_Token, LC.Value);
elsif LC.Value = Ch.Quotation then
Fetch_Character;
Token.Set (Interp, String_Token);
loop
if LC.Kind /= Normal_Character then
-- String ended prematurely.
-- TODO: Set Error code, Error Number.... Error location
raise Syntax_Error;
end if;
if LC.Value = Ch.Backslash then when Ch.Pos.Left_Parenthesis =>
Fetch_Character; Token.Set (Interp, Left_Parenthesis_Token, LC.Value);
when Ch.Pos.Right_Parenthesis =>
Token.Set (Interp, Right_Parenthesis_Token, LC.Value);
when Ch.Pos.Period =>
Token.Set (Interp, Period_Token, LC.Value);
when Ch.Pos.Apostrophe =>
Token.Set (Interp, Single_Quote_Token, LC.Value);
when Ch.Pos.Quotation =>
Fetch_Character;
Token.Set (Interp, String_Token);
loop
if LC.Kind /= Normal_Character then if LC.Kind /= Normal_Character then
-- String ended prematurely. -- String ended prematurely.
-- TODO: Set Error code, Error Number.... Error location -- TODO: Set Error code, Error Number.... Error location
raise Syntax_Error; raise Syntax_Error;
end if; end if;
-- TODO: escape letters??? \n \r \\ etc....
Token.Append_Character (Interp, LC.Value); if LC.Value = Ch.Backslash then
elsif LC.Value = Ch.Quotation then Fetch_Character;
exit; if LC.Kind /= Normal_Character then
else -- String ended prematurely.
Token.Append_Character (Interp, LC.Value); -- TODO: Set Error code, Error Number.... Error location
Fetch_Character; raise Syntax_Error;
end if; end if;
end loop; -- TODO: escape letters??? \n \r \\ etc....
Token.Append_Character (Interp, LC.Value);
elsif LC.Value = Ch.Number_Sign then elsif LC.Value = Ch.Quotation then
Fetch_Character; exit;
-- TODO: t, false, etc else
elsif LC.Value in Ch.Zero .. Ch.Nine then Token.Append_Character (Interp, LC.Value);
-- TODO; negative number, floating-point number, bignum, hexdecimal, etc Fetch_Character;
Token.Set (Interp, Integer_Token); end if;
loop end loop;
Token.Append_Character (Interp, LC.Value);
when Ch.Pos.Number_Sign =>
Fetch_Character; Fetch_Character;
if LC.Kind /= Normal_Character or else -- TODO: t, false, etc
LC.Value not in Ch.Zero .. Ch.Nine then
-- Unfetch the last character
Interp.LC_Unfetched := Standard.True;
exit;
end if;
end loop;
elsif LC.Value = Ch.Plus_Sign or else LC.Value = Ch.Minus_Sign then when Ch.Pos.Zero .. Ch.Pos.Nine =>
Tmp(1) := LC.Value; -- TODO; negative number, floating-point number, bignum, hexdecimal, etc
Token.Set (Interp, Integer_Token);
Fetch_Character;
if LC.Kind = Normal_Character and then
LC.Value in Ch.Zero .. Ch.Nine then
Token.Set (Interp, Integer_Token, Tmp(1..1));
loop loop
Token.Append_Character (Interp, LC.Value); Token.Append_Character (Interp, LC.Value);
Fetch_Character; Fetch_Character;
@ -2510,37 +2499,56 @@ Print (Interp, Operand);
exit; exit;
end if; end if;
end loop; end loop;
else
Token.Set (Interp, Identifier_Token, Tmp(1..1)); when Ch.Pos.Plus_Sign | Ch.Pos.Minus_Sign =>
Tmp(1) := LC.Value;
Fetch_Character;
if LC.Kind = Normal_Character and then
LC.Value in Ch.Zero .. Ch.Nine then
Token.Set (Interp, Integer_Token, Tmp(1..1));
loop
Token.Append_Character (Interp, LC.Value);
Fetch_Character;
if LC.Kind /= Normal_Character or else
LC.Value not in Ch.Zero .. Ch.Nine then
-- Unfetch the last character
Interp.LC_Unfetched := Standard.True;
exit;
end if;
end loop;
else
Token.Set (Interp, Identifier_Token, Tmp(1..1));
loop
-- TODO: more characters
if LC.Kind /= Normal_Character or else
Is_Identifier_Stopper(LC.Value) then
-- Unfetch the last character
Interp.LC_Unfetched := Standard.True;
exit;
end if;
Token.Append_Character (Interp, LC.Value);
Fetch_Character;
end loop;
end if;
when others =>
Token.Set (Interp, Identifier_Token);
loop loop
-- TODO: more characters Token.Append_Character (Interp, LC.Value);
Fetch_Character;
--exit when not Is_Ident_Char(C.Value);
-- TODO: more characters
if LC.Kind /= Normal_Character or else if LC.Kind /= Normal_Character or else
Is_Identifier_Stopper(LC.Value) then Is_Identifier_Stopper(LC.Value) then
-- Unfetch the last character -- Unfetch the last character
Interp.LC_Unfetched := Standard.True; Interp.LC_Unfetched := Standard.True;
exit; exit;
end if; end if;
Token.Append_Character (Interp, LC.Value);
Fetch_Character;
end loop; end loop;
end if; end case;
else
Token.Set (Interp, Identifier_Token);
loop
Token.Append_Character (Interp, LC.Value);
Fetch_Character;
--exit when not Is_Ident_Char(C.Value);
-- TODO: more characters
if LC.Kind /= Normal_Character or else
Is_Identifier_Stopper(LC.Value) then
-- Unfetch the last character
Interp.LC_Unfetched := Standard.True;
exit;
end if;
end loop;
end if;
--Ada.Text_IO.Put (">>>>>>>>>>>>>>>>>>>>>>> Token: " & Interp.Token.Value.Ptr(1..Interp.Token.Value.Last)); --Ada.Text_IO.Put (">>>>>>>>>>>>>>>>>>>>>>> Token: " & Interp.Token.Value.Ptr(1..Interp.Token.Value.Last));
end Fetch_Token; end Fetch_Token;