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

⟦e114bc314⟧ TextFile

    Length: 3214 (0xc8e)
    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 Source_Io;
package body Reserved_Words is

    Min_Keyword_Length : constant := 2;
    Max_Keyword_Length : constant := 9;

    subtype Valid_Keyword_Lengths is
       Positive range Min_Keyword_Length .. Max_Keyword_Length;

    type Keyword_Info (Length : Valid_Keyword_Lengths := Min_Keyword_Length) is
        record
            Keyword : String (1 .. Length);
        end record;

    type Table_Type is array (Positive range <>) of Keyword_Info;

    Number_Of_Keywords : constant Positive := 63;
    Keyword_Table : Table_Type (1 .. Number_Of_Keywords) :=
       ((5, "ABORT"), (3, "ABS"), (6, "ACCEPT"), (6, "ACCESS"), (3, "ALL"),
        (3, "AND"), (5, "ARRAY"), (2, "AT"), (5, "BEGIN"), (4, "BODY"),
        (4, "CASE"), (8, "CONSTANT"), (7, "DECLARE"), (5, "DELAY"),
        (5, "DELTA"), (6, "DIGITS"), (2, "DO"), (4, "ELSE"), (5, "ELSIF"),
        (3, "END"), (5, "ENTRY"), (9, "EXCEPTION"), (4, "EXIT"), (3, "FOR"),
        (8, "FUNCTION"), (7, "GENERIC"), (4, "GOTO"), (2, "IF"),
        (2, "IN"), (2, "IS"), (7, "LIMITED"), (4, "LOOP"), (3, "MOD"),
        (3, "NEW"), (3, "NOT"), (4, "NULL"), (2, "OF"), (2, "OR"),
        (6, "OTHERS"), (3, "OUT"), (7, "PACKAGE"), (6, "PRAGMA"),
        (7, "PRIVATE"), (9, "PROCEDURE"), (5, "RAISE"), (5, "RANGE"),
        (6, "RECORD"), (3, "REM"), (7, "RENAMES"), (6, "RETURN"),
        (7, "REVERSE"), (6, "SELECT"), (8, "SEPARATE"), (7, "SUBTYPE"),
        (4, "TASK"), (9, "TERMINATE"), (4, "THEN"), (4, "TYPE"),
        (3, "USE"), (4, "WHEN"), (5, "WHILE"), (4, "WITH"), (3, "XOR"));

    -- convert all lower case letters in a string to upper case
    function To_Upper_Case (Old_Symbol : in String) return String is

        New_Symbol : String (Old_Symbol'Range);

    begin
        -- To_Upper_Case

        for Index in Old_Symbol'Range loop
            New_Symbol (Index) := Source_Io.To_Upper_Case (Old_Symbol (Index));
        end loop;
        return New_Symbol;

    end To_Upper_Case;


    function Binary_Search
                (Symbol : in String; Lower : in Integer; Upper : in Integer)
                return Boolean is

        Middle : Integer := (Lower + Upper) / 2;

    begin
        -- Binary_Search

        if Lower > Upper then
            return False;
        elsif Symbol = Keyword_Table (Middle).Keyword then
            return True;
        elsif Symbol < Keyword_Table (Middle).Keyword then
            -- search lower half
            return Binary_Search
                      (Symbol => Symbol, Lower => Lower, Upper => Middle - 1);
        else
            -- search upper half
            return Binary_Search
                      (Symbol => Symbol, Lower => Middle + 1, Upper => Upper);
        end if;

    end Binary_Search;


    function Is_Keyword (Symbol : in String) return Boolean is
    begin
        -- Is_Keyword

        if Symbol'Length in Valid_Keyword_Lengths then

            -- worth  finding out
            return Binary_Search (Symbol => To_Upper_Case (Symbol),
                                  Lower => Keyword_Table'First,
                                  Upper => Keyword_Table'Last);
        else

            return False;

        end if;

    end Is_Keyword;

end Reserved_Words;