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 - metrics - download
Index: B T

⟦bd21944a1⟧ TextFile

    Length: 11242 (0x2bea)
    Types: TextFile
    Names: »B«

Derivation

└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
    └─⟦5cb1d1d7f⟧ »DATA« 
        └─⟦3b1ee7bd8⟧ 
            └─⟦this⟧ 

TextFile

with Lines;
with String_Utilities;
package body Annotations_Generic is

    procedure Parse (This_Keyword : in String;
                     Is_Simple_Keyword : in out Boolean;
                     The_Simple_Keyword : in out Simple_Keywords) is
    begin  
        Is_Simple_Keyword := False;
        for Current_Keyword in Simple_Keywords loop
            if (String_Utilities.Upper_Case (This_Keyword) =
                Simple_Keywords'Image (Current_Keyword)) then
                -- Found match.
                Is_Simple_Keyword := True;
                The_Simple_Keyword := Current_Keyword;
                exit;
            end if;
        end loop;
    end Parse;

    procedure Parse (This_Keyword : in String;
                     Is_Valued_Keyword : in out Boolean;
                     The_Valued_Keyword : in out Valued_Keywords) is
    begin  
        Is_Valued_Keyword := False;
        for Current_Keyword in Valued_Keywords loop
            if (String_Utilities.Upper_Case (This_Keyword) =
                Valued_Keywords'Image (Current_Keyword)) then
                -- Found match.
                Is_Valued_Keyword := True;
                The_Valued_Keyword := Current_Keyword;
                exit;
            end if;
        end loop;
    end Parse;

    function Normalized (This_String : in String) return String is
    begin
        return (String_Utilities.Strip (This_String));
    end Normalized;

    procedure Parse (This_Line : in String;
                     Is_Simple_Annotation : in out Boolean;
                     The_Simple_Keyword : in out Simple_Keywords;
                     Is_Valued_Annotation : in out Boolean;
                     The_Valued_Keyword : in out Valued_Keywords) is
        --
        Normalized_Line : constant String := Normalized (This_Line);
        --
        Line_Begin : Integer := Normalized_Line'First;
        --
        Keyword_Begin : Integer := Line_Begin + 1;
        Keyword_End : Integer;
        --
    begin
        -- Must initialize ALL "in out" and "out" parameters (Ada rule).
        --
        Is_Simple_Annotation := False;
        The_Simple_Keyword := Simple_Keywords'First;
        Is_Valued_Annotation := False;
        The_Valued_Keyword := Valued_Keywords'First;
        --
        if (Normalized_Line (Line_Begin) = Annotation_Indicator) then
            for Index in Keyword_Begin .. Normalized_Line'Last loop
                if (Normalized_Line (Index) = Argument_Delimiter) then
                    -- Found an argument delimiter, so the annotation
                    -- might be valued.
                    Keyword_End := Index - 1;
                    Parse (Normalized_Line (Keyword_Begin .. Keyword_End),
                           Is_Valued_Annotation, The_Valued_Keyword);
                    if (Is_Valued_Annotation) then
                        exit;
                    end if;
                end if;
                if (Index = Normalized_Line'Last) then
                    -- Got all the way to the end of the line without
                    -- finding an argument delimiter, so the annotation
                    -- might be simple.
                    Keyword_End := Index;
                    Parse (Normalized_Line (Keyword_Begin .. Keyword_End),
                           Is_Simple_Annotation, The_Simple_Keyword);
                end if;
            end loop;
        end if;
    end Parse;

    function Is_Simple_Annotation (This_Line : in Line) return Boolean is
        --
        Is_Simple_Annotation : Boolean := False;
        The_Simple_Keyword : Simple_Keywords := Simple_Keywords'First;
        Is_Valued_Annotation : Boolean := False;
        The_Valued_Keyword : Valued_Keywords := Valued_Keywords'First;
        --
    begin  
        declare
            The_Annotation : constant String :=
               Normalized (Lines.Image (This_Line));
        begin
            Parse (The_Annotation, Is_Simple_Annotation, The_Simple_Keyword,
                   Is_Valued_Annotation, The_Valued_Keyword);
            return (Is_Simple_Annotation);
        end;
        --
    exception
        when Lines.Not_Initialized =>
            raise Not_Initialized;
        when others =>
            return (False);
            --
    end Is_Simple_Annotation;

    function Is_Valued_Annotation (This_Line : in Line) return Boolean is
        --
        Is_Simple_Annotation : Boolean := False;
        The_Simple_Keyword : Simple_Keywords := Simple_Keywords'First;
        Is_Valued_Annotation : Boolean := False;
        The_Valued_Keyword : Valued_Keywords := Valued_Keywords'First;
        --
    begin  
        declare
            The_Annotation : constant String :=
               Normalized (Lines.Image (This_Line));
        begin
            Parse (The_Annotation, Is_Simple_Annotation, The_Simple_Keyword,
                   Is_Valued_Annotation, The_Valued_Keyword);
            return (Is_Valued_Annotation);
        end;
        --
    exception
        when Lines.Not_Initialized =>
            raise Not_Initialized;
        when others =>
            return (False);
            --
    end Is_Valued_Annotation;

    function Is_Annotation (This_Line : in Line) return Boolean is
        --
        Is_Simple_Annotation : Boolean := False;
        The_Simple_Keyword : Simple_Keywords := Simple_Keywords'First;
        Is_Valued_Annotation : Boolean := False;
        The_Valued_Keyword : Valued_Keywords := Valued_Keywords'First;
        --
    begin  
        declare
            The_Annotation : constant String :=
               Normalized (Lines.Image (This_Line));
        begin
            Parse (The_Annotation, Is_Simple_Annotation, The_Simple_Keyword,
                   Is_Valued_Annotation, The_Valued_Keyword);
            return (Is_Simple_Annotation or else Is_Valued_Annotation);
        end;
        --
    exception
        when Lines.Not_Initialized =>
            raise Not_Initialized;
        when others =>
            return (False);
            --
    end Is_Annotation;

    function Keywords_Match
                (This_Simple_Annotation : in Simple_Annotation;
                 This_Simple_Keyword : in Simple_Keywords) return Boolean is
        --
        Is_Simple_Annotation : Boolean := False;
        The_Simple_Keyword : Simple_Keywords := Simple_Keywords'First;
        Is_Valued_Annotation : Boolean := False;
        The_Valued_Keyword : Valued_Keywords := Valued_Keywords'First;
        --
    begin  
        declare
            The_Annotation : constant String :=
               Normalized (Lines.Image (This_Simple_Annotation));
        begin
            Parse (The_Annotation, Is_Simple_Annotation, The_Simple_Keyword,
                   Is_Valued_Annotation, The_Valued_Keyword);
            return (Is_Simple_Annotation and then
                    (This_Simple_Keyword = The_Simple_Keyword));
        end;
        --
    exception
        when Lines.Not_Initialized =>
            raise Not_Initialized;
        when others =>
            return (False);
            --
    end Keywords_Match;

    function Keywords_Match
                (This_Valued_Annotation : in Valued_Annotation;
                 This_Valued_Keyword : in Valued_Keywords) return Boolean is
        --
        Is_Simple_Annotation : Boolean := False;
        The_Simple_Keyword : Simple_Keywords := Simple_Keywords'First;
        Is_Valued_Annotation : Boolean := False;
        The_Valued_Keyword : Valued_Keywords := Valued_Keywords'First;
        --
    begin  
        declare
            The_Annotation : constant String :=
               Normalized (Lines.Image (This_Valued_Annotation));
        begin
            Parse (The_Annotation, Is_Simple_Annotation, The_Simple_Keyword,
                   Is_Valued_Annotation, The_Valued_Keyword);
            return (Is_Valued_Annotation and then
                    (This_Valued_Keyword = The_Valued_Keyword));
        end;
        --
    exception  
        when Lines.Not_Initialized =>
            raise Not_Initialized;
        when others =>
            return (False);
            --
    end Keywords_Match;

    function Argument_To
                (This_Valued_Annotation : in String;
                 This_Valued_Keyword : in Valued_Keywords) return String is
        --
        The_Valued_Annotation : constant String :=
           Normalized (This_Valued_Annotation);
        --
        The_Keyword_Image : constant String :=
           Valued_Keywords'Image (This_Valued_Keyword);
        The_Keyword_Length : Integer := The_Keyword_Image'Length;
        Argument_Start : Integer :=
           The_Valued_Annotation'First + The_Keyword_Length + 2;
        Argument_End : Integer := The_Valued_Annotation'Last;
        --
    begin
        return (The_Valued_Annotation (Argument_Start .. Argument_End));
    end Argument_To;

    function Value_Of (This_Line : in Line) return String is
        --
        Is_Simple_Annotation : Boolean := False;
        The_Simple_Keyword : Simple_Keywords := Simple_Keywords'First;
        Is_Valued_Annotation : Boolean := False;
        The_Valued_Keyword : Valued_Keywords := Valued_Keywords'First;
        --
    begin  
        declare
            The_Line : constant String := Normalized (Lines.Image (This_Line));
        begin
            Parse (The_Line, Is_Simple_Annotation, The_Simple_Keyword,
                   Is_Valued_Annotation, The_Valued_Keyword);
            if (Is_Simple_Annotation) then
                return ("");
            elsif (Is_Valued_Annotation) then
                return (Argument_To (The_Line, The_Valued_Keyword));
            else
                -- Not an annotation
                return (Lines.Image (This_Line));
            end if;
        end;
        --
    exception  
        when Lines.Not_Initialized =>
            raise Not_Initialized;
        when others =>
            return ("<UNKNOWN>");
            --
    end Value_Of;

    function Arguments_Match (This_Valued_Annotation : in Valued_Annotation;
                              This_Argument : in Arguments) return Boolean is
        --
        Is_Simple_Annotation : Boolean := False;
        The_Simple_Keyword : Simple_Keywords := Simple_Keywords'First;
        Is_Valued_Annotation : Boolean := False;
        The_Valued_Keyword : Valued_Keywords := Valued_Keywords'First;
        --
    begin  
        declare
            The_Annotation : constant String :=
               Normalized (Lines.Image (This_Valued_Annotation));
        begin
            Parse (The_Annotation, Is_Simple_Annotation, The_Simple_Keyword,
                   Is_Valued_Annotation, The_Valued_Keyword);
            if (not Is_Valued_Annotation) then
                return (False);
            else
                return (String_Utilities.Upper_Case
                           (Argument_To (The_Annotation, The_Valued_Keyword)) =
                        String_Utilities.Upper_Case
                           (Arguments'Image (This_Argument)));
            end if;
        end;
        --
    exception  
        when Lines.Not_Initialized =>
            raise Not_Initialized;
        when others =>
            return (False);
            --
    end Arguments_Match;

end Annotations_Generic;