DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ B T

⟦2ef6d06c1⟧ TextFile

    Length: 5681 (0x1631)
    Types: TextFile
    Names: »B«

Derivation

└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
    └─ ⟦129cab021⟧ »DATA« 
        └─⟦this⟧ 

TextFile

with Arguments;
with Block_Class;
with Bounded_String;
with Message;
with More_List1;
with More_List2;
with Msg_Report;
with Object;
with Scanner;
with String_Utilities;
with Symbol_Table;  
with Unparse_Report;


package body List is

    procedure Bs_Copy (A_String : in out Scanner.B_String; A_Value : String)
        renames Bounded_String.Copy;

    function Bs_Image (A_String : Scanner.B_String) return String
        renames Bounded_String.Image;

    function Is_Equal_String
                (Str1 : String; Str2 : String; Ignore_Case : Boolean := True)
                return Boolean renames String_Utilities.Equal;

    function Su_Capitalize (A_String : String) return String
        renames String_Utilities.Capitalize;

    type Node_Structure is
        record
            Rule : Natural range 0 .. 1 := 0;  
            Info : Natural range 0 .. 1 := 0;  
            Mol1 : More_List1.Node := More_List1.Empty_Node;  
            Mol2 : More_List2.Node := More_List2.Empty_Node;  
            Iden : Scanner.B_String;  
            Keyw : Message.Selector := Message.Void_Selector;
            Lign : Integer;
        end record;

    procedure Parse (N : in out Node; Error : out Boolean) is
        Failed : Boolean := False;
        use Scanner;

    begin  
        Msg_Report.Information ("I enter in list's parse");

        N := new Node_Structure;

        N.Lign := Scanner.Line_Number;

        if Scanner.Symbol = L_Identifier then
            Bs_Copy (N.Iden, Scanner.Value);
            Scanner.Next;
            if More_List1.Is_First (Scanner.Symbol) then
                N.Info := 1;
                More_List1.Parse (N.Mol1, Failed);  
            end if;
        else  
            Message.Copy (N.Keyw, Scanner.Value);
            Scanner.Next;
            N.Rule := 1;
            if Scanner.Symbol = L_Identifier then
                Bs_Copy (N.Iden, Scanner.Value);
                Scanner.Next;
                if More_List2.Is_First (Scanner.Symbol) then
                    N.Info := 1;
                    More_List2.Parse (N.Mol2, Failed);  
                end if;
            else
                Failed := True;
                Msg_Report.Syntax_Error ("identifier expected, not");
            end if;
        end if;

        Msg_Report.Information ("I leave list's parse with failed = " &
                                Boolean'Image (Failed));

        Error := Failed;
    end Parse;


    procedure Unparse (N : Node) is

    begin  
        case N.Rule is
            when 0 =>

                Unparse_Report.Write (Su_Capitalize (Bs_Image (N.Iden)) & " ");
                if N.Info = 1 then
                    More_List1.Unparse (N.Mol1);
                end if;


            when 1 =>

                Unparse_Report.Write (Su_Capitalize (Message.Image (N.Keyw)));
                Unparse_Report.Write (Su_Capitalize (Bs_Image (N.Iden)) & " ");
                if N.Info = 1 then
                    More_List2.Unparse (N.Mol2);
                end if;
        end case;

    end Unparse;


    function Is_First (T : Scanner.Token) return Boolean is
        use Scanner;

    begin
        return T = L_Identifier or else T = L_Key_Word;
    end Is_First;


    function Interpret
                (N : Node;
                 Inherited : Object.Reference := Object.Void_Reference;
                 A_Keyword_Mess : Message.Selector := Message.Void_Selector;
                 A_List : Arguments.List := Arguments.Void_Arguments)
                return Object.Reference is

        Result : Object.Reference := Object.Void_Reference;  
        Arg : Object.Reference;
        Arg_List : Arguments.List;
        Keyword_Mess, Msg : Message.Selector := Message.Void_Selector;

    begin

        Msg_Report.Information ("I enter in list's interpret");

        Msg_Report.Set_Line_Number (N.Lign);

        Keyword_Mess := A_Keyword_Mess;
        Message.Extract_Keyword (Keyword_Mess, Msg);
        Arg_List := A_List;
        Arguments.First (Arg_List);
        Arguments.Read (Arg_List, Arg);

        if N.Rule = 0 then  
            if Is_Equal_String (Message.Image (Msg),
                                Block_Class.Evaluate_Msg) then  
                Symbol_Table.Insert (N.Iden, Arg);  
            else
                Msg_Report.Interpret_Error
                   ("Incorrect call parameter :" & Message.Image (Msg));
                raise Incorrect_Call_Parameter;
            end if;

            if N.Info = 1 then
                Result := More_List1.Interpret (N.Mol1,
                                                A_Keyword_Mess => Keyword_Mess,
                                                A_List => Arg_List);
            end if;  
        else  
            if Is_Equal_String (Message.Image (Msg),
                                Message.Format (N.Keyw)) then  
                Symbol_Table.Insert (N.Iden, Arg);  
            else
                Msg_Report.Interpret_Error
                   ("Incorrect call parameter :" & Message.Image (Msg));
                raise Incorrect_Call_Parameter;
            end if;

            if N.Info = 1 then
                Result := More_List2.Interpret (N.Mol2,
                                                A_Keyword_Mess => Keyword_Mess,
                                                A_List => Arg_List);
            end if;
        end if;

        Msg_Report.Information ("I leave list's interpret with result :");
        Msg_Report.Continue
           ("class = " & Object.Class'Image (Object.The_Class (Result)) &
            " ident = " & Integer'Image (Object.Identificator (Result)));

        return Result;
    end Interpret;  
end List;