|
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: 9216 (0x2400) Types: Ada Source Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Int_Lib, seg_043d55
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000 └─ ⟦5a81ac88f⟧ »Space Info Vol 1« └─⟦this⟧
with Text_Io; package body Int_Lib is function Find (In_The_Table : in I_Table; The_String : in I_String) return Natural is begin for I in In_The_Table'Range loop if String_Table.Int_List.Isinlist (In_The_Table (I), The_String) then return Natural'Val (I); end if; end loop; return Nothing; end Find; procedure Refresh_Table (Verb_Table, Object_Table, Direction_Table : I_Table; Extracted_String : I_String; Tab_Result : in out I_Result; Number : Natural; Not_Successful : in out Boolean) is Index : Natural := Nothing; begin Not_Successful := False; Index := Find (Verb_Table, Extracted_String); -- Check if it is in the verbs table if Index /= Nothing then Tab_Result (Number).Token := Token_Pkg.T_Verbe; Tab_Result (Number).Index := Index; else Index := Find (Object_Table, Extracted_String); -- Check if it is in the objects table if Index /= Nothing then Tab_Result (Number).Token := Token_Pkg.T_Objet; Tab_Result (Number).Index := Index; else Index := Find (Direction_Table, Extracted_String); -- Check if it is in the directions table if Index /= Nothing then Tab_Result (Number).Token := Token_Pkg.T_Direction; Tab_Result (Number).Index := Index; else Tab_Result (Number).Token := Token_Pkg.T_Unk; Not_Successful := True; end if; end if; end if; end Refresh_Table; procedure Check_Table (The_Table : in I_Result; Not_Ok : in out Boolean) is Index : Natural := 1; begin Not_Ok := False; if Token_Pkg.Token'Image (The_Table (Index).Token) = Token_Pkg.Token'Image (Token_Pkg.T_Verbe) then -- Check if the first word is a verb Index := Index + 1; if Token_Pkg.Token'Image (The_Table (Index).Token) = Token_Pkg.Token'Image (Token_Pkg.T_Objet) then -- Check if the second is an object Index := Index + 1; if Token_Pkg.Token'Image (The_Table (Index).Token) = Token_Pkg.Token'Image (Token_Pkg.T_Objet) then -- Check if the third is an object too Index := Index + 1; if Token_Pkg.Token'Image (The_Table (Index).Token) /= Token_Pkg.Token'Image (Token_Pkg.T_End) then -- Check if there is a T_end at the end. Not_Ok := True; end if; elsif Token_Pkg.Token'Image (The_Table (Index).Token) /= Token_Pkg.Token'Image (Token_Pkg.T_End) then -- if the third is not an object, it must be a T_end Not_Ok := True; end if; elsif Token_Pkg.Token'Image (The_Table (Index).Token) = Token_Pkg.Token'Image (Token_Pkg.T_Direction) then -- if the second is not an object, it can be a direction Index := Index + 1; if Token_Pkg.Token'Image (The_Table (Index).Token) /= Token_Pkg.Token'Image (Token_Pkg.T_End) then -- and if the second is a direction, the 3rd must be a T_end Not_Ok := True; end if; elsif Token_Pkg.Token'Image (The_Table (Index).Token) /= Token_Pkg.Token'Image (Token_Pkg.T_End) then -- if the second is not an object nor a direction, it must be -- a T_end Not_Ok := True; end if; else -- There's no other possibility for the first one Not_Ok := True; end if; end Check_Table; procedure Interpretor (Verb_Table, Object_Table, Direction_Table : in I_Table; Tab_Result : in out I_Result) is Command_String : String (1 .. 80); Result : I_String; Word_Rank : Natural; Size, At_Pos, Index : Natural; Error, Continue : Boolean; begin Error := True; while Error loop Error := False; Continue := True; At_Pos := 1; Text_Io.Put ("> "); Text_Io.Get_Line (Command_String, Size); Word_Rank := 1; while Continue loop if Word_Rank > 4 then Continue := False; else Int_Lex.Get (Command_String, Size, At_Pos, Result); if Bounded_String.Image (Result) = "Lex Error" then -- it happens when a word is not composed with alphabetics -- characters Error := True; Continue := False; Text_Io.Put_Line ("Je ne comprends pas ! Erreur d'orthographe."); else if not (Int_Lex.Give_Up (Result)) then -- only makes a new cell of the table when the -- extracted word shouldn't be given up. Refresh_Table (Verb_Table, Object_Table, Direction_Table, Result, Tab_Result, Word_Rank, Error); if Error then -- when the word can't be found in tables. Continue := False; Text_Io.Put_Line ("Desole, je ne comprends pas ! Mot(s) inconnu(s)."); else Word_Rank := Word_Rank + 1; end if; end if; if At_Pos >= Size then Continue := False; end if; end if; end if; end loop; if Word_Rank > 4 then -- when there are too much words in the sentense Error := True; Text_Io.Put_Line ("Desole, je ne comprends pas ! Phrase incorrecte."); else Tab_Result (Word_Rank).Token := Token_Pkg.T_End; end if; if not (Error) then Check_Table (Tab_Result, Error); if Error then -- When the first semantic test fail Text_Io.Put_Line ("Desole, je ne comprends pas ! Phrase incorrecte."); end if; end if; end loop; end Interpretor; end Int_Lib;
nblk1=8 nid=0 hdr6=10 [0x00] rec0=1d rec1=00 rec2=01 rec3=05c [0x01] rec0=17 rec1=00 rec2=02 rec3=02c [0x02] rec0=14 rec1=00 rec2=03 rec3=00c [0x03] rec0=10 rec1=00 rec2=04 rec3=082 [0x04] rec0=1f rec1=00 rec2=05 rec3=014 [0x05] rec0=10 rec1=00 rec2=06 rec3=05c [0x06] rec0=17 rec1=00 rec2=07 rec3=02c [0x07] rec0=0a rec1=00 rec2=08 rec3=000 tail 0x2153f5456863b7696be9d 0x42a00088462060003