DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ B T ┃
Length: 10727 (0x29e7) Types: TextFile Names: »B«
└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11 └─ ⟦129cab021⟧ »DATA« └─⟦this⟧
with Standard_String; with String_Utilities; with Text_Io; with File; with Erreurs; with Motor; package body Lexical is type Pstring is access String; subtype Keywords is Token range L_Materiel .. L_Sans; type Keywords_Table is array (Keywords) of Pstring; The_File : Text_Io.File_Type; Current_Value : Standard_String.Object; Current_Token : Token := L_Unk; Current_Number : Natural := 0; Line_Number : Integer := 1; type State is (St_Normal, St_Sub, St_Comment, St_Word, St_Time, St_Number, St_Found); subtype Part_Of_State is State range State'First .. St_Number; The_Keywords_Table : constant Keywords_Table := (L_Materiel => new String'("MATERIEL"), L_Debut => new String'("DEBUT"), L_Fin => new String'("FIN"), L_Fait => new String'("FAIT"), L_Discret => new String'("DISCRET"), --modification et suppresion de L_fugitif L_Temporel => new String'("TEMPOREL"), L_Acteurs => new String'("ACTEURS"), L_Est => new String'("EST"), L_Sur => new String'("SUR"), L_Station => new String'("STATION"), L_Scenario => new String'("SCENARIO"), L_Scene => new String'("SCENE"), L_Dans => new String'("DANS"), L_Faire => new String'("FAIRE"), L_Repeter => new String'("REPETER"), L_Fois => new String'("FOIS"), L_Repeter_Ad_Eternam => new String'("REPETER_AD_ETERNAM"), L_Toutes => new String'("TOUTES"), L_Les => new String'("LES"), L_Pendant => new String'("PENDANT"), L_De => new String'("DE"), L_Vers => new String'("VERS"), L_En => new String'("EN"), L_Experience => new String'("EXPERIENCE"), L_Effet => new String'("EFFET"), L_Enchainement => new String'("ENCHAINEMENT"), L_Groupe => new String'("GROUPE"), L_Hasard => new String'("HASARD"), L_Premier => new String'("PREMIER"), L_Duree => new String'("DUREE"), L_Avec => new String'("AVEC"), L_Sans => new String'("SANS")); procedure Open (Name_File : String) is begin Text_Io.Open (File => The_File, Mode => Text_Io.In_File, Name => Name_File, Form => ""); File.Open (The_File); Erreurs.Ouvrir (Name_File & "_err"); Motor.Ouvrir (Name_File & "_code"); end Open; procedure Close_The_File is begin Text_Io.Close (File => The_File); Erreurs.Fermer; Motor.Fermer; end Close_The_File; function At_End return Boolean is begin return File.At_End (The_File); end At_End; function Get_Token return Token is begin return Current_Token; end Get_Token; function Get_Value return Standard_String.Object is begin return Current_Value; end Get_Value; function Get_Value return Integer is The_Length : Integer := Standard_String.Length (Current_Value); Time_String : String (1 .. (The_Length - 1)); Tempo_String : String (1 .. The_Length); Response : Boolean; Current_Number : Integer; begin Tempo_String := Standard_String.Get_Contents (Current_Value); if Current_Token = L_Number then String_Utilities.String_To_Number (Source => Tempo_String, Target => Current_Number, Worked => Response); return Current_Number; elsif Current_Token = L_Temps then Time_String (1 .. (The_Length - 2)) := Tempo_String (1 .. (The_Length - 2)); Time_String (The_Length - 1) := Tempo_String (The_Length); String_Utilities.String_To_Number (Source => Time_String, Target => Current_Number, Worked => Response); return Current_Number; else return 0; end if; end Get_Value; function Keyword_To_Token (A_String : Standard_String.Object) return Token is S : String (1 .. Standard_String.Length (A_String)); begin S := String_Utilities.Upper_Case (Standard_String.Get_Contents (A_String)); for I in Keywords loop if S = The_Keywords_Table (I).all then return I; end if; end loop; return L_Id; end Keyword_To_Token; function Is_Alpha (A_Char : Character) return Boolean is begin return A_Char in 'a' .. 'z' or A_Char in 'A' .. 'Z'; end Is_Alpha; function Is_Digit (A_Char : Character) return Boolean is begin return A_Char in '0' .. '9'; end Is_Digit; procedure Next is Current_String : Standard_String.Object; Current_State : State; Current_Char : Character; begin if not File.At_End (The_File) then Current_State := St_Normal; while (Current_State /= St_Found) loop if not File.At_End (The_File) then File.Next (The_File); Current_Char := File.Value (The_File); else Current_Char := Ascii.Eot; end if; case Part_Of_State'(Current_State) is when St_Normal => case Current_Char is when Ascii.Eot => Current_Token := L_Eof; Current_State := St_Found; when ' ' => null; when Ascii.Cr => Line_Number := Line_Number + 1; when '+' => Current_Token := L_Plus; Current_State := St_Found; when '=' => Current_Token := L_Equal; Current_State := St_Found; when '*' => Current_Token := L_Star; Current_State := St_Found; when ':' => Current_Token := L_D_Point; Current_State := St_Found; when '.' => Current_Token := L_Point; Current_State := St_Found; when ',' => Current_Token := L_Virgule; Current_State := St_Found; when '(' => Current_Token := L_Open; Current_State := St_Found; when ')' => Current_Token := L_Close; Current_State := St_Found; when '-' => Current_State := St_Sub; when others => if Is_Alpha (Current_Char) then Standard_String.Add_Char (Current_String, Current_Char); Current_State := St_Word; elsif Is_Digit (Current_Char) then Standard_String.Add_Char (Current_String, Current_Char); Current_State := St_Number; else Current_Token := L_Unk; Current_State := St_Found; end if; end case; when St_Sub => if Current_Char = '-' then Current_State := St_Comment; else File.Unget (The_File); Current_Token := L_Sub; Current_State := St_Found; end if; when St_Comment => if Current_Char = Ascii.Cr then Current_State := St_Normal; Line_Number := Line_Number + 1; end if; when St_Word => if Is_Alpha (Current_Char) or Is_Digit (Current_Char) or Current_Char = '_' then Standard_String.Add_Char (Current_String, Current_Char); else File.Unget (The_File); Current_Token := Keyword_To_Token (Current_String); Current_State := St_Found; end if; when St_Time => if Is_Digit (Current_Char) then Standard_String.Add_Char (Current_String, Current_Char); Current_State := St_Found; Current_Token := L_Temps; else Current_State := St_Found; Current_Token := L_Unk; end if; when St_Number => if Is_Digit (Current_Char) then Standard_String.Add_Char (Current_String, Current_Char); else if Current_Char = '.' then Standard_String.Add_Char (Current_String, Current_Char); Current_State := St_Time; else File.Unget (The_File); Current_Token := L_Number; Current_State := St_Found; end if; end if; end case; end loop; else Current_Token := L_Eof; end if; Standard_String.Copy (Current_String, Current_Value); end Next; function Get_Line return Integer is begin return Line_Number; end Get_Line; end Lexical;