|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 14336 (0x3800)
Types: Ada Source
Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Lex, seg_03ece5
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
└─⟦cfc2e13cd⟧ »Space Info Vol 2«
└─⟦this⟧
with Text_Io, File, Unbounded_String, String_Utilities;
use Text_Io;
package body Lex is
package Moving_String is new Unbounded_String (10);
Current_Value : Moving_String.Variable_String;
Current_Token : Token;
Current_Token_Line : Integer;
Current_Token_Column : Integer;
procedure Initialize is
begin
File.Initialize;
Lex.Next;
end Initialize;
function Get_Token return Token is
begin
return Current_Token;
end Get_Token;
function Get_Value return String is
begin
return Moving_String.Image (Current_Value);
end Get_Value;
function Is_At_End return Boolean is
begin
return Current_Token = End_Of_Text;
end Is_At_End;
function Get_Line return Integer is
begin
return Current_Token_Line;
end Get_Line;
function Get_Column return Integer is
begin
return Current_Token_Column;
end Get_Column;
procedure Next is
type State is (Normal, Divide, Less, Greater,
Word, Sentence, Number, Found);
subtype Upper_Letter is Character range 'A' .. 'Z';
subtype Lower_Letter is Character range 'a' .. 'z';
subtype Digit is Character range '0' .. '9';
Current_Character : Character;
Current_State : State := Normal;
function Word_To_Token (Word : in String) return Token is
subtype Keyword_Token is Token range Entier .. Fin;
Temporary_Word : String (Word'Range) := Word;
Choosen_Token : Token := Identifier;
begin
String_Utilities.Upper_Case (Temporary_Word);
for A_Token in Keyword_Token'First .. Keyword_Token'Last loop
if Temporary_Word = Keyword_Token'Image (A_Token) then
Choosen_Token := A_Token;
end if;
end loop;
return Choosen_Token;
end Word_To_Token;
begin
Moving_String.Free (Current_Value);
Select_Token:
loop
File.Next;
Current_Character := File.Get_Value;
if Current_State = Normal and Current_Character /= ' ' and
Current_Character /= Ascii.Lf then
Current_Token_Line := File.Get_Line;
Current_Token_Column := File.Get_Column;
end if;
case Current_State is
when Normal =>
case Current_Character is
when ' ' | Ascii.Lf =>
null;
when ',' =>
Current_Token := Comma;
Current_State := Found;
when '=' =>
Current_Token := Equal;
Current_State := Found;
when ':' =>
Current_Token := Colon;
Current_State := Found;
when '"' =>
Current_State := Sentence;
when '/' =>
Current_State := Divide;
when '*' =>
Current_Token := Multiply;
Current_State := Found;
when '-' =>
Current_Token := Substract;
Current_State := Found;
when '+' =>
Current_Token := Add;
Current_State := Found;
when '<' =>
Current_State := Less;
when '>' =>
Current_State := Greater;
when '&' =>
Current_Token := Ampersand;
Current_State := Found;
when '(' =>
Current_Token := Opening_Bracket;
Current_State := Found;
when ')' =>
Current_Token := Closing_Bracket;
Current_State := Found;
when Ascii.Eot =>
Current_Token := End_Of_Text;
Current_State := Found;
when others =>
if Current_Character in Upper_Letter or
Current_Character in Lower_Letter then
Moving_String.Append
(Current_Value, Current_Character);
Current_State := Word;
elsif Current_Character in Digit then
Moving_String.Append
(Current_Value, Current_Character);
Current_State := Number;
else
Current_Token := Unknown_Symbol;
Current_State := Found;
end if;
end case;
when Word =>
if Current_Character in Upper_Letter or
Current_Character in Lower_Letter or
Current_Character in Digit or
Current_Character = '_' then
Moving_String.Append
(Current_Value, Current_Character);
else
File.Unget;
Current_Token := Word_To_Token (Moving_String.Image
(Current_Value));
Current_State := Found;
end if;
when Divide =>
if Current_Character = '/' then
while File.Get_Value /= Ascii.Lf loop
File.Next;
end loop;
File.Unget;
Current_State := Normal;
else
File.Unget;
Current_Token := Divide;
Current_State := Found;
end if;
when Less =>
if Current_Character = '=' then
Current_Token := Less_Equal;
elsif Current_Character = '>' then
Current_Token := Not_Equal;
else
File.Unget;
Current_Token := Less;
end if;
Current_State := Found;
when Greater =>
if Current_Character = '=' then
Current_Token := Greater_Equal;
else
File.Unget;
Current_Token := Greater;
end if;
Current_State := Found;
when Sentence =>
if Current_Character = '"' then
Current_Token := Right_Sentence;
Current_State := Found;
elsif Current_Character = Ascii.Eot or
Current_Character = Ascii.Lf then
Current_Token := Wrong_Sentence;
Current_State := Found;
File.Unget;
else
Moving_String.Append
(Current_Value, Current_Character);
end if;
when Number =>
if Current_Character in Digit then
Moving_String.Append
(Current_Value, Current_Character);
else
File.Unget;
Current_Token := Number;
Current_State := Found;
end if;
when Found =>
null;
end case;
exit when Current_State = Found;
end loop Select_Token;
end Next;
end Lex;
nblk1=d
nid=4
hdr6=14
[0x00] rec0=2d rec1=00 rec2=01 rec3=044
[0x01] rec0=1d rec1=00 rec2=0b rec3=026
[0x02] rec0=18 rec1=00 rec2=07 rec3=06a
[0x03] rec0=14 rec1=00 rec2=0c rec3=01c
[0x04] rec0=12 rec1=00 rec2=06 rec3=00a
[0x05] rec0=11 rec1=00 rec2=08 rec3=038
[0x06] rec0=09 rec1=00 rec2=05 rec3=038
[0x07] rec0=16 rec1=00 rec2=09 rec3=004
[0x08] rec0=14 rec1=00 rec2=0d rec3=024
[0x09] rec0=11 rec1=00 rec2=03 rec3=000
[0x0a] rec0=11 rec1=00 rec2=03 rec3=000
[0x0b] rec0=0d rec1=00 rec2=04 rec3=000
[0x0c] rec0=24 rec1=00 rec2=0f rec3=790
tail 0x2173e5d0086053a5aee76 0x42a00088462060003
Free Block Chain:
0x4: 0000 00 02 00 05 80 02 75 61 02 03 04 05 06 07 08 09 ┆ ua ┆
0x2: 0000 00 0a 00 07 80 04 6f 6c 75 6d 04 05 06 07 72 6e ┆ olum rn┆
0xa: 0000 00 00 00 2d 80 12 20 20 20 20 20 20 20 46 69 6c ┆ - Fil┆