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: 4164 (0x1044) Types: TextFile Names: »B«
└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11 └─ ⟦129cab021⟧ »DATA« └─⟦this⟧
with Block; with Block_Class; with Bounded_String; with Errors; with Integer_Class; with String_Class; with String_Utilities; with Trace; with Unparser; with Value; package body Primary is type Node_Structure is record Line : Natural; Rule : Natural range 1 .. 5; Obj : Object.Reference := Object.Void_Reference; Ident : Scanner.Lexeme; Val : Value.Node := Value.Empty_Node; Bloc : Block.Node := Block.Empty_Node; end record; procedure Parse (N : in out Node) is This_Int : Integer; Conv_Ok : Boolean; begin Trace.Display ("parsing Primary"); N := new Node_Structure; N.Line := Scanner.Get_Line_Number; if Block.Is_First (Scanner.Get_Token) then N.Rule := 5; N.Obj := Block_Class.Create; Block.Parse (N.Bloc); Block_Class.Set_Node (N.Obj, N.Bloc); else case Scanner.Get_Token is when Scanner.L_Int => N.Rule := 1; String_Utilities.String_To_Number (Bounded_String.Image (Scanner.Get_Value), This_Int, Conv_Ok); N.Obj := Integer_Class.Create (This_Int); Scanner.Next_Token; when Scanner.L_Str => N.Rule := 2; N.Obj := String_Class.Create (Scanner.Get_Value); Scanner.Next_Token; when Scanner.L_Id => N.Rule := 3; N.Ident := Scanner.Get_Value; Scanner.Next_Token; when Scanner.L_Opar => N.Rule := 4; Scanner.Next_Token; if Value.Is_First (Scanner.Get_Token) then Value.Parse (N.Val); case Scanner.Get_Token is when Scanner.L_Cpar => Scanner.Next_Token; when others => raise Errors.Expecting_Closing_Parenthesis; end case; else raise Errors.Expecting_Value; end if; when others => raise Errors.Expecting_Primary_First; end case; end if; end Parse; procedure Unparse (N : Node) is begin case N.Rule is when 1 => Unparser.Put (String_Utilities.Number_To_String (Object.Get_Id (N.Obj)) & " "); when 2 => Unparser.Put (""""); Unparser.Put (String_Class.Get_Value (N.Obj)); Unparser.Put (""" "); when 3 => Unparser.Put (N.Ident); Unparser.Put (" "); when 4 => Unparser.Put ("( "); Value.Unparse (N.Val); Unparser.Put (") "); when 5 => Block.Unparse (N.Bloc, N.Obj); end case; Trace.Display ("fin unparse primary"); end Unparse; function Is_First (T : Scanner.Token) return Boolean is use Scanner; begin return T = Scanner.L_Int or else T = Scanner.L_Str or else T = Scanner.L_Id or else T = Scanner.L_Opar or else Block.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 := N.Obj; when 2 => Result := N.Obj; when 3 => Result := Block_Class.Get_Value (N.Ident); when 4 => Result := Value.Interpret (N.Val); when 5 => Result := N.Obj; end case; Trace.Display ("fin interpretation primary"); Trace.Display (Result); return Result; end Interpret; end Primary;