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 ("-- 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 ("\tpackage Pos is\n");
}
{
t = sprintf ("%c", NR - 1);
if (str::isprint(t)) t = " -- " 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 {
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");
}

View File

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

View File

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