|
|
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_0449ed
└─⟦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, Moving_String, String_Utilities;
use Moving_String;
package body Lex is
Current_Value : Moving_String.Object;
Current_Token : Token;
Current_Token_Line : Natural;
Current_Token_Column : Natural;
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_Lower_Case_Value return String is
begin
return String_Utilities.Lower_Case
(Moving_String.Image (Current_Value));
end Get_Lower_Case_Value;
function Get_Value return String is
begin
return Moving_String.Image (Current_Value);
end Get_Value;
function Get_Value return Moving_String.Object is
begin
return 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_Sentence return String is
begin
return File.Get_Sentence;
end Get_Sentence;
function Get_Line return Natural is
begin
return Current_Token_Line;
end Get_Line;
function Get_Column return Natural 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 := Id;
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 others =>
if Current_Character in Upper_Letter or
Current_Character in Lower_Letter then
Current_Value := Current_Value &
Current_Character;
Current_State := Word;
elsif Current_Character in Digit then
Current_Value := Current_Value &
Current_Character;
Current_State := Number;
elsif Current_Character = Ascii.Eot then
Current_Token := End_Of_Text;
Current_State := Found;
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
Current_Value := 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
Current_Value := Current_Value & Current_Character;
end if;
when Number =>
if Current_Character in Digit then
Current_Value := 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=2
hdr6=16
[0x00] rec0=2a rec1=00 rec2=01 rec3=026
[0x01] rec0=23 rec1=00 rec2=0d rec3=072
[0x02] rec0=07 rec1=00 rec2=0b rec3=054
[0x03] rec0=1a rec1=00 rec2=07 rec3=004
[0x04] rec0=13 rec1=00 rec2=0c rec3=028
[0x05] rec0=11 rec1=00 rec2=06 rec3=04a
[0x06] rec0=11 rec1=00 rec2=05 rec3=03a
[0x07] rec0=14 rec1=00 rec2=03 rec3=020
[0x08] rec0=15 rec1=00 rec2=08 rec3=02a
[0x09] rec0=15 rec1=00 rec2=04 rec3=008
[0x0a] rec0=05 rec1=00 rec2=09 rec3=000
[0x0b] rec0=05 rec1=00 rec2=09 rec3=000
[0x0c] rec0=24 rec1=00 rec2=0f rec3=790
tail 0x2153f36e4863b683128f6 0x42a00088462060003
Free Block Chain:
0x2: 0000 00 0a 00 05 00 02 20 20 02 20 20 20 20 20 20 20 ┆ ┆
0xa: 0000 00 00 00 2d 80 12 20 20 20 20 20 20 20 46 69 6c ┆ - Fil┆