|
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 - download
Length: 11264 (0x2c00) Types: Ada Source Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Lex, seg_049117
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000 └─ ⟦5a81ac88f⟧ »Space Info Vol 1« └─⟦this⟧
with Our_String; package body Lex is subtype Digit is Character range '0' .. '9'; subtype Lower is Character range 'a' .. 'z'; subtype Upper is Character range 'A' .. 'Z'; subtype Keyword_Token is Token range Complements .. Ou; type State is (Normal, Found, Less, Great, Commentary_Start, Identifier, Sentence_Start, Number); Current_Value : Our_String.Variable_String; Current_Token : Token; function Keyword_To_Token (A_Id : in String) return Token is A_Token : Keyword_Token; begin A_Token := Keyword_Token'Value (A_Id); return Token'Value (A_Id); exception when Constraint_Error => return Identifier; end Keyword_To_Token; procedure Init is begin File.Init; end Init; function Get_Line return Natural is begin return File.Get_Line; end Get_Line; function Get_Token return Token is begin return Current_Token; end Get_Token; function Get_Value return String is begin return (Our_String.Image (Current_Value)); end Get_Value; function Is_At_End return Boolean is begin return Current_Token = Eof; end Is_At_End; procedure Next is Current_Char : Character; Current_State : State; begin Our_String.Free (Current_Value); Current_State := Normal; loop if not File.At_End then File.Next; Current_Char := File.Value; else Current_Char := Ascii.Eot; end if; case Current_State is when Normal => case Current_Char is when Ascii.Eot => Current_Token := Eof; Current_State := Found; when ' ' | Ascii.Cr => null; when '+' => Current_Token := Plus; Current_State := Found; when '-' => Current_Token := Minus; Current_State := Found; when '*' => Current_Token := Cross; Current_State := Found; when '/' => Current_Token := Slash; Current_State := Found; when '<' => Current_State := Less; when '>' => Current_State := Great; when '=' => Current_Token := Equal; Current_State := Found; when ',' => Current_Token := Coma; Current_State := Found; when '(' => Current_Token := Left_Bracket; Current_State := Found; when ')' => Current_Token := Right_Bracket; Current_State := Found; when '.' => Current_Token := Dot; Current_State := Found; when '{' => Current_State := Commentary_Start; when '"' => Current_State := Sentence_Start; when others => if Current_Char in Upper or Current_Char in Lower then Our_String.Append (Current_Value, Current_Char); Current_State := Identifier; elsif Current_Char in Digit then Our_String.Append (Current_Value, Current_Char); Current_State := Number; else Current_Token := Unknown; Current_State := Found; end if; end case; when Commentary_Start => if Current_Char = '}' then Current_State := Normal; end if; when Sentence_Start => if Current_Char = '"' then Current_Token := Sentence; Current_State := Found; else Our_String.Append (Current_Value, Current_Char); end if; when Less => case Current_Char is when '>' => Current_Token := Not_Equal; Current_State := Found; when '=' => Current_Token := Less_Equal; Current_State := Found; when others => File.Unget; Current_Token := Less; Current_State := Found; end case; when Great => if Current_Char = '=' then Current_Token := Great_Equal; Current_State := Found; else File.Unget; Current_Token := Great; Current_State := Found; end if; when Identifier => if Current_Char in Upper or Current_Char in Lower or Current_Char in Digit or Current_Char = '_' then Our_String.Append (Current_Value, Current_Char); else File.Unget; Current_Token := Keyword_To_Token (Our_String.Image (Current_Value)); Current_State := Found; end if; when Number => if Current_Char in Digit then Our_String.Append (Current_Value, Current_Char); else File.Unget; Current_Token := Number; Current_State := Found; end if; when Found => null; end case; exit when Current_State = Found; end loop; end Next; end Lex;
nblk1=a nid=5 hdr6=12 [0x00] rec0=2c rec1=00 rec2=01 rec3=024 [0x01] rec0=2a rec1=00 rec2=03 rec3=036 [0x02] rec0=15 rec1=00 rec2=06 rec3=062 [0x03] rec0=14 rec1=00 rec2=07 rec3=072 [0x04] rec0=18 rec1=00 rec2=09 rec3=04c [0x05] rec0=03 rec1=00 rec2=0a rec3=00a [0x06] rec0=16 rec1=00 rec2=04 rec3=04a [0x07] rec0=1b rec1=00 rec2=08 rec3=00c [0x08] rec0=01 rec1=00 rec2=02 rec3=000 [0x09] rec0=1a rec1=00 rec2=06 rec3=001 tail 0x2154672ce865b42d5d32f 0x42a00088462060003 Free Block Chain: 0x5: 0000 00 00 00 14 80 02 6c 3b 02 00 0c 20 20 20 20 20 ┆ l; ┆