DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

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

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦3e2d9cc17⟧ Ada Source

    Length: 17408 (0x4400)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, procedure Parse, seg_01b4c0, separate Parameter_Parser

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦cfc2e13cd⟧ »Space Info Vol 2« 
        └─⟦this⟧ 

E3 Source Code



separate (Parameter_Parser)
procedure Parse (Parameter : String;
                 Options : out Iterator;
                 Success : out Boolean) is

    Iter : Iterator := new Iterator_Data;
    Itns : Iteration;


    procedure Parse (Parameter : String) is
        Pos : Integer := Parameter'First;
        Last : Integer := Parameter'Last;
        Token : Token_Kind;
        Start, Finish : Integer;
        Name : Image;
        Value : Image;

        function New_Iteration (Id : Option_Id) return Iteration is
            Itn : Iteration := new Iteration_Data;
        begin
            Itn.Name := Find (Id);

            if Itn.Name /= null then
                Itn.Status := Ok;
            else
                Itn.Status := Undefined_Id;
                Itn.Diagnosis := new String'(Option_Id'Image (Id));
            end if;

            return Itn;
        end New_Iteration;

        function New_Iteration (Name : Image) return Iteration is
            Itn : Iteration := new Iteration_Data;
            Id : Option_Id;
        begin
            if Name = null then
                Itn.Status := Missing_Name;
                Itn.Diagnosis := new String'(Parameter (Start .. Finish));
            else
                declare
                    Norm : constant String := Normal (Name.all);
                begin
                    Itn.Name := Find (Norm, True);

                    if Itn.Name = null then
                        Itn.Status := Undefined_Name;
                        Itn.Diagnosis := Name;
                        return Itn;
                    end if;

                    if Norm /= Itn.Name.Name.all and then
                       Find (Norm, True, Itn.Name.Next) /= null then
                        Itn.Name := Find (Norm);  -- look for exact match

                        if Itn.Name = null then
                            -- No exact, 2 prefixes match
                            Itn.Status := Ambiguous_Name;
                            Itn.Diagnosis := Name;
                            return Itn;
                        end if;
                    end if;

                    Itn.Status := Ok;
                    Itn.Kind := Itn.Name.Kind;

                    if Itn.Kind = Literal then
                        Itn.Value := Name;
                        Id := Itn.Name.Id;
                        Itn.Name := Find (Id);

                        if Itn.Name = null then
                            Itn.Status := Undefined_Id;
                            Itn.Diagnosis := new String'(Option_Id'Image (Id));
                        end if;
                    end if;
                end;
            end if;

            return Itn;
        end New_Iteration;

        procedure Add_Iteration (Itn : Iteration) is
            Pnt : Iteration;
        begin
            if Itn.Status = Ok then
                Pnt := Itns;

                while Pnt /= null loop
                    if Pnt.Status = Ok and then Pnt.Name.Id = Itn.Name.Id then
                        return;
                    else
                        Pnt := Pnt.Next;
                    end if;
                end loop;
            end if;

            Itn.Next := Itns;
            Itns := Itn;
        end Add_Iteration;

        procedure Add_Iteration (Name1 : Image) is
        begin
            Add_Iteration (New_Iteration (Name1));
        end Add_Iteration;

        procedure Add_Iteration (Name1, Name2 : Image) is
            Itn1 : Iteration;
            Itn2 : Iteration;
        begin
            Itn1 := New_Iteration (Name1);
            Itn2 := New_Iteration (Name2);

            Add_Iteration (Itn1);

            if Itn1.Status = Ok and then Itn2.Status = Ok then
                for I in Option_Id'Succ (Itn1.Name.Id) ..
                            Option_Id'Pred (Itn2.Name.Id) loop
                    Add_Iteration (New_Iteration (I));
                end loop;
            end if;

            Add_Iteration (Itn2);
        end Add_Iteration;

        procedure Add_Range (Id1, Id2 : Option_Id) is
            Opt : Option;
            Itn : Iteration;
        begin
            for Id in Id1 .. Id2 loop
                Opt := Find (Id);

                if Opt /= null then
                    Itn := new Iteration_Data;
                    Itn.Name := Opt;
                    Itn.Status := Ok;
                    Add_Iteration (Itn);
                end if;
            end loop;
        end Add_Range;

        procedure Eat_Token is
        begin
            loop
                if Pos not in Parameter'First .. Last then
                    Token := End_String;
                    Start := Parameter'First;
                    Finish := Start - 1;
                    return;
                end if;

                exit when Parameter (Pos) /= ' ';

                Pos := Pos + 1;
            end loop;

            Start := Pos;
            Finish := Pos;

            Token := Other;

            case Parameter (Pos) is
                when '=' =>
                    if Pos < Last and then Parameter (Pos + 1) = '>' then
                        Finish := Pos + 1;
                    end if;

                    Token := Arrow;

                when ':' =>
                    if Pos < Last and then Parameter (Pos + 1) = '=' then
                        Finish := Pos + 1;
                        Token := Arrow;
                    end if;

                when '|' =>
                    Token := Bar;

                when '.' =>
                    if Pos < Last and then Parameter (Pos + 1) = '.' then
                        Finish := Pos + 1;
                        Token := Dots;
                    end if;

                when '~' =>
                    Token := Tilde;

                when ',' | ';' | Ascii.Lf =>
                    Token := Separator;

                when others =>
                    null;
            end case;

            Pos := Finish + 1;
        end Eat_Token;

        procedure Get_Value is
            D : Integer := 0;
        begin
            case Token is
                when Separator | End_String =>
                    -- null Value
                    Pos := Finish;
                    Finish := Start - 1;

                when others =>
                    if Parameter (Start) = '(' or else
                       Parameter (Start) = '[' or else
                       Parameter (Start) = '{' then
                        while Pos <= Last loop
                            case Parameter (Pos) is
                                when '(' | '[' | '{' =>
                                    D := D + 1;
                                when ')' | ']' | '}' =>
                                    exit when D = 0;
                                    D := D - 1;
                                when '\' =>
                                    Pos := Pos + 1;
                                when others =>
                                    null;
                            end case;

                            Pos := Pos + 1;
                        end loop;

                        Finish := Pos;
                        Pos := Pos + 1;
                    else
                        while Pos <= Last loop
                            case Parameter (Pos) is
                                when ',' | ';' | Ascii.Lf =>
                                    exit;
                                when '\' =>
                                    Pos := Pos + 1;
                                    Finish := Pos;
                                when ' ' =>
                                    null;
                                when others =>
                                    Finish := Pos;
                            end case;

                            Pos := Pos + 1;
                        end loop;
                    end if;
            end case;

            Value := new String'(Parameter (Start .. Finish));
            Eat_Token;
        end Get_Value;

        procedure Get_Name is
        begin
            if Token = Other then
                while Pos <= Last loop
                    case Parameter (Pos) is
                        when '=' | ';' | ',' | ' ' | Ascii.Lf | '|' =>
                            exit;
                        when ':' =>
                            exit when Pos < Last and then
                                         Parameter (Pos + 1) = '=';
                        when '.' =>
                            exit when Pos < Last and then
                                         Parameter (Pos + 1) = '.';
                        when others =>
                            null;
                    end case;

                    Pos := Pos + 1;
                end loop;

                Finish := Pos - 1;
                Name := new String'(Parameter (Start .. Finish));
                Eat_Token;
            else
                Name := null;
            end if;
        end Get_Name;

        procedure Get_Range is
            Name1 : Image;
        begin
            Get_Name;

            if Token = Dots then
                if Name = null then
                    Add_Iteration (Name);
                    Eat_Token;
                    Get_Name;
                    Add_Iteration (Name);
                else
                    Name1 := Name;
                    Eat_Token;
                    Get_Name;
                    Add_Iteration (Name1, Name);
                end if;

            elsif Name /= null and then Normal (Name.all) = "OTHERS" then
                Add_Range (Lowest, Highest);

            else
                Add_Iteration (Name);
            end if;
        end Get_Range;

        procedure Get_Option is
            Fence : Iteration := Itns;
            Itn : Iteration;
            I : Integer;
            F : Float;
            Boolean_Sense : Boolean := True;
            Tilded : Boolean := False;
            Defaulted : Boolean;
        begin
            while Token = Tilde loop
                Boolean_Sense := not Boolean_Sense;
                Tilded := True;
                Eat_Token;
            end loop;

            loop
                Get_Range;
                exit when Token /= Bar;
                Eat_Token;
            end loop;

            Itn := Itns;

            if Token = Arrow then
                Eat_Token;
                Get_Value;
                Defaulted := Value.all = "<>";

                while Itn /= Fence loop
                    if Tilded then
                        Itn.Status := Tilded_Value;
                    elsif Itn.Status = Ok then
                        if Itn.Kind = Literal then
                            Itn.Status := Literal_Has_Value;
                            Itn.Diagnosis := Value;
                        elsif Defaulted then
                            if Itn.Name.Value /= null then
                                Itn.Value := new String'(Itn.Name.Value.all);
                            end if;
                        else
                            Itn.Value := Value;

                            case Itn.Kind is
                                when Boolean_Valued =>
                                    if Su.Locate (Value.all, "False", True) /=
                                       1 and then
                                       Su.Locate (Value.all, "True", True) /=
                                          1 then
                                        Itn.Status := Malformed_Boolean;
                                    end if;
                                when Integer_Valued =>
                                    I := Get_Integer
                                            (Itn);  -- exec for side-effect
                                when Float_Valued =>
                                    F := Get_Float
                                            (Itn);  -- exec for side-effect
                                when Literal | Unspecified =>
                                    null;
                            end case;
                        end if;
                    else
                        Itn.Value := Value;
                    end if;

                    Itn := Itn.Next;
                end loop;
            else
                while Itn /= Fence loop
                    if Itn.Status = Ok then
                        if Itn.Kind = Literal then
                            if Tilded then
                                Itn.Status := Tilded_Literal;
                            end if;
                        elsif Itn.Name.Kind = Boolean_Valued then
                            Itn.Value := Boolean_Value (Boolean_Sense);
                        elsif Itn.Name.Value /= null and then
                              (Su.Locate (Itn.Name.Value.all, "False", True) =
                               1 or else
                               Su.Locate (Itn.Name.Value.all, "True", True) =
                                  1) then
                            Itn.Value := Boolean_Value (Boolean_Sense);
                        else
                            Itn.Status := Has_No_Value;
                        end if;
                    end if;

                    Itn := Itn.Next;
                end loop;
            end if;
        end Get_Option;
    begin
        Eat_Token;

        loop
            if Token /= Separator and then Token /= End_String then
                Get_Option;
            end if;

            while Token = Separator loop
                Eat_Token;
            end loop;

            exit when Token = End_String;
        end loop;
    end Parse;

    function Inverted (Itns : Iteration) return Iteration is
        Itn : Iteration := Itns;
        Nxt : Iteration;
        Prv : Iteration;
    begin
        Iter.Success := True;

        while Itn /= null loop
            Nxt := Itn.Next;
            Itn.Next := Prv;

            -- Advance Prv to this iteration if it should be kept.

            if Itn.Status /= Ok then
                Iter.Success := False;
                Prv := Itn;
            elsif Itn.Value /= null then
                Prv := Itn;
            end if;

            Itn := Nxt;
        end loop;

        return Prv;
    end Inverted;

begin
    Parse (Parameter);
    Iter.Start := Inverted (Itns);
    Iter.Point := Iter.Start;
    Success := Iter.Success;
    Options := Iter;
end Parse;

E3 Meta Data

    nblk1=10
    nid=0
    hdr6=20
        [0x00] rec0=22 rec1=00 rec2=01 rec3=072
        [0x01] rec0=19 rec1=00 rec2=02 rec3=020
        [0x02] rec0=1d rec1=00 rec2=03 rec3=038
        [0x03] rec0=1f rec1=00 rec2=04 rec3=07c
        [0x04] rec0=22 rec1=00 rec2=05 rec3=028
        [0x05] rec0=22 rec1=00 rec2=06 rec3=01e
        [0x06] rec0=1e rec1=00 rec2=07 rec3=006
        [0x07] rec0=17 rec1=00 rec2=08 rec3=03e
        [0x08] rec0=1a rec1=00 rec2=09 rec3=03c
        [0x09] rec0=22 rec1=00 rec2=0a rec3=028
        [0x0a] rec0=24 rec1=00 rec2=0b rec3=044
        [0x0b] rec0=13 rec1=00 rec2=0c rec3=084
        [0x0c] rec0=17 rec1=00 rec2=0d rec3=034
        [0x0d] rec0=18 rec1=00 rec2=0e rec3=02a
        [0x0e] rec0=29 rec1=00 rec2=0f rec3=036
        [0x0f] rec0=03 rec1=00 rec2=10 rec3=000
    tail 0x21718b9188363868005f1 0x42a00088462060003