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: 3884 (0xf2c) Types: TextFile Names: »B«
└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11 └─ ⟦129cab021⟧ »DATA« └─⟦this⟧
with Block_Class; with Bounded_String; with Custom; with Errors; with Trace; with Unparser; with Value; package body Expression is type Node_Structure is record Line : Natural; Rule : Natural range 1 .. 2; Ident : Scanner.Lexeme; Val : Value.Node := Value.Empty_Node; end record; procedure Parse (N : in out Node) is begin Trace.Display ("parsing Expression"); N := new Node_Structure; N.Line := Scanner.Get_Line_Number; if Value.Is_First (Scanner.Get_Token) then N.Rule := 1; Value.Parse (N.Val); else case Scanner.Get_Token is when Scanner.L_Pour => Scanner.Next_Token; case Scanner.Get_Token is when Scanner.L_Id => N.Rule := 2; N.Ident := Scanner.Get_Value; Scanner.Next_Token; case Scanner.Get_Token is when Scanner.L_Pren => Scanner.Next_Token; if Value.Is_First (Scanner.Get_Token) then if not Custom.Is_Predefined_Id (Bounded_String.Image (N.Ident)) then if not Block_Class. Table_Created then Block_Class.New_Symbols_Table; end if; Block_Class.Init_Symbol (N.Ident); end if; Value.Parse (N.Val); else raise Errors. Expecting_Value_After_Prendre; end if; when others => raise Errors.Expecting_Prendre_After_Id; end case; when others => raise Errors.Expecting_Id_After_Pour; end case; when others => raise Errors.Expecting_Pour_Or_Value; end case; end if; end Parse; procedure Unparse (N : Node) is begin case N.Rule is when 1 => Value.Unparse (N.Val); when 2 => Unparser.Put ("Pour "); Unparser.Put (N.Ident); Unparser.Put (" prendre "); Value.Unparse (N.Val); end case; Trace.Display ("fin unparse Expression"); end Unparse; function Is_First (T : Scanner.Token) return Boolean is use Scanner; begin return T = Scanner.L_Pour or else Value.Is_First (T); end Is_First; function Interpret (N : Node) return Object.Reference is Result : Object.Reference; begin Errors.Save_Interpret_Line (N.Line); case N.Rule is when 1 => Result := Value.Interpret (N.Val); when 2 => if not Custom.Is_Predefined_Id (Bounded_String.Image (N.Ident)) then Result := Value.Interpret (N.Val); Block_Class.Set_Value (N.Ident, Result); else raise Errors.Affectation_To_Predefined_Id; end if; end case; Trace.Display ("fin interpretation Expression"); Trace.Display (Result); return Result; end Interpret; end Expression;