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

⟦53eaeffdf⟧ TextFile

    Length: 3420 (0xd5c)
    Types: TextFile
    Names: »B«

Derivation

└─⟦2f6cfab89⟧ Bits:30000547 8mm tape, Rational 1000, !projects 94-01-04
    └─ ⟦d65440be7⟧ »DATA« 
        └─⟦this⟧ 

TextFile

with Block;
with Value;
with Object;
with Scanner;

package body Primary is

    type Node_Structure is
        record
            Rule : Natural range 1 .. 5;
            case Rule is
                when 1 =>
                    Int : Object.Reference := Object.Void_Reference;
                when 2 =>
                    Str : Object.Reference := Object.Void_Reference;
                when 3 =>
                    Ident : Scanner.Lexeme := Scanner.Empty_Lexeme;
                when 4 =>
                    Value : Value.Node := Value.Empty_Node;
                when 5 =>
                    Block : Block.Node := Block.Empty_Node;
            end case;
        end record;

    procedure Parse (N : in out Node; Error : out Boolean) is
        Failed : Boolean := False;
    begin
        if Block.Is_First (Scanner.Get_Token) then
            N := new Node_Structure;
            N.Rule := 5;
            Block.Parse (N.Block, Failed);
        else
            case Scanner.Get_Token is
                when Scanner.L_Int =>
                    N := new Node_Structure;
                    N.Rule := 1;
                    N.Int := Object.Create (Entier, Scanner.Get_Value);
                    Scanner.Next_Token;
                when Scanner.L_Str =>
                    N := new Node_Structure;
                    N.Rule := 2;
                    N.Str := Object.Create (Chaine, Scanner.Get_Value);
                    Scanner.Next_Token;
                when Scanner.L_Id =>
                    N := new Node_Structure;
                    N.Rule := 3;
                    N.Ident := Scanner.Get_Value;
                    Scanner.Next_Token;
                when Scanner.L_Opar =>
                    N := new Node_Structure;
                    N.Rule := 4;
                    Scanner.Next_Token;
                    if Value.Is_First (Scanner.Get_Token) then
                        Value.Parse (N.Value, Failed);
                        if not Failed then
                            case Scanner.Get_Token is
                                when L_Cpar =>
                                    Scanner.Next_Token;
                                when others =>
                                    Failed := True;
                            end case;
                        end if;
                    else
                        Failed := True;
                    end if;
                when others =>
                    Failed := True;
            end case;
        end if;
        Error := Failed;
    end Parse;

    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;
                        Inherited : Object.Reference := Object.Void_Reference)
                       return Object.Reference is
        Result : Object.Reference;
    begin
        case N.Rule is
            when 0 =>
                Result := Inherited;
            when 1 =>
                Result := Expression.Interpret (N.Expr);
                Result := More_Statements.Interpret (N.More, Result);
            when 2 =>
                Result := Expression.Interpret (N.Expr);
        end case;
        return Result;
    end Interpret;

end Primary;