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

⟦893ad82e3⟧ Ada Source

    Length: 15360 (0x3c00)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Symbol_Table, seg_005807

Derivation

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

E3 Source Code



with Ada_Parameterization;
with Error_Report;
use Error_Report;
with Lexemes;
use Lexemes;

with Arithmetic;
use Arithmetic;
with Vstring_Assign;
use Vstring_Assign;
with Vstring_Heap;
use Vstring_Heap;
with Vstring_Query;
use Vstring_Query;
with Vstring_Type;
use Vstring_Type;

package body Symbol_Table is
------------------------------------------------------------------------------
-- Recognition and value storage for keywords and parameters.
------------------------------------------------------------------------------
-- Copyright 1989 - 1991 by Rational, Santa Clara, California.
--
--                  All Rights Reserved.
--
-- Permission to use, copy, modify, and distribute this software and its
-- documentation for any purpose and without fee is hereby granted,
-- provided that the above copyright notice(s) appear in all copies and that
-- both that copyright notice(s) and this permission notice appear in
-- supporting documentation, and that the name of Rational not be used in
-- advertising or publicity pertaining to distribution of the software
-- without specific, written prior permission.
--
-- Rational disclaims all warranties with regard to this software, including
-- all implied warranties of merchantability and fitness, in no event shall
-- Rational be liable for any special, indirect or consequential damages or
-- any damages whatsoever resulting from loss of use, data or profits, whether
-- in an action of contract, negligence or other tortious action, arising out
-- of or in connection with the use or performance of this software.
------------------------------------------------------------------------------

    procedure Define (M       : in Symbol_Map.Map;  
                      Key     : in E_String;  
                      Rt      : in Symbol_Value;
                      Dups_Ok : in Boolean := False) renames Symbol_Map.Insert;

    procedure Parse_A_Name (Parms         :     Vstring;  
                            Name_Required :     Boolean;
                            Name_Value    : out Symbol_Value);

--\x0c
    procedure Define_Keywords is
------------------------------------------------------------------------------
-- Called to enter all of our lexical keywords into the symbol map.  eg. "IF"
------------------------------------------------------------------------------
    begin

----Define the keywords that we recognize in control constructs.

        Define (Sym_Map, "IF", (Sk_Keyword, True, Kwd => Lk_If));  
        Define (Sym_Map, "THEN", (Sk_Keyword, True, Kwd => Lk_Then));  
        Define (Sym_Map, "ELSIF", (Sk_Keyword, True, Kwd => Lk_Elsif));  
        Define (Sym_Map, "ELSE", (Sk_Keyword, True, Kwd => Lk_Else));  
        Define (Sym_Map, "END", (Sk_Keyword, True, Kwd => Lk_End));

----Define the keywords that we recognize in expressions.

        Define (Sym_Map, "NOT", (Sk_Keyword, True, Kwd => Lk_Not));  
        Define (Sym_Map, "AND", (Sk_Keyword, True, Kwd => Lk_And));  
        Define (Sym_Map, "OR", (Sk_Keyword, True, Kwd => Lk_Or));  
        Define (Sym_Map, "XOR", (Sk_Keyword, True, Kwd => Lk_Xor));

----Define TRUE and FALSE.

        Define (Sym_Map, "FALSE", (Sk_Boolean, True, Bool => False));
        Define (Sym_Map, "TRUE", (Sk_Boolean, True, Bool => True));

    end Define_Keywords;

--\x0c
    procedure Define_Predefineds is separate;

--\x0c
    procedure Parse_After_Name (Parms      :     Vstring;  
                                Name_Value : out Symbol_Value) is
------------------------------------------------------------------------------
-- Called with a partially eaten parameter string after our caller had
-- read a symbol name from it.  We check for EOL, ',', '|', and '=>'.
------------------------------------------------------------------------------
        Cur_Lexeme : Lexeme_Kind;
        Cur_Text   : Vstring := New_Vstring (64);
        Cur_Text2  : Vstring;
        Cur_Value  : Symbol_Value;
    begin

        Empty_Vstring (Cur_Text);
        Next_Lexeme (Parms, Cur_Lexeme, Cur_Text, Cur_Value);

----If we hit end-of-string or a comma then the default parameter setting is
--  True.

        if Cur_Lexeme = Lk_Eol or else  
           Cur_Lexeme = Lk_Comma then
            Name_Value := (Sk_Boolean, Permanent => False, Bool => True);

----If we hit a | then we recurse and get another parameter name.

        elsif Cur_Lexeme = Lk_Vbar then
            Parse_A_Name (Parms, True, Cur_Value);
            Symbol_Map.Insert
               (Sym_Map, To_String (Cur_Text), Cur_Value, Dups_Ok => True);
            Name_Value := Cur_Value;

----If we find a => then we grab the symbol that follows it as the parameter
--  value.

        elsif Cur_Lexeme = Lk_Arrow then
            Cur_Text2 := New_Vstring (64);
            Next_Lexeme (Parms, Cur_Lexeme, Cur_Text2, Cur_Value);
            Free_Vstring Cur_Text2);
            if Cur_Lexeme = Lk_Identifier then
                if Cur_Value.Kind = Sk_Keyword then
                    Error ("The keyword " &
                           String (Substring_To (Cur_Text, 1, 512)) &
                           " is not the name of a parameter.");
                    Cur_Value := (Sk_Boolean,
                                  Permanent => False,
                                  Bool      => False);
                end if;
                Cur_Value.Permanent := False;
            else
                declare
                    Str : constant String := Lexeme_Kind'Image (Cur_Lexeme);
                begin
                    Error ("Found a " &
                           Str (Str'First + 3 .. Str'Last) & " after " &
                           String (Substring_To (Cur_Text, 1, 512)) &
                           "=> in Additonal_Parameters argument?");
                end;
                Cur_Value := (Sk_Boolean, Permanent => False, Bool => False);
            end if;
            Name_Value := Cur_Value;

----Anything else is an error.

        else
            declare
                Str : constant String := Lexeme_Kind'Image (Cur_Lexeme);
            begin
                Error ("Found a " & Str (Str'First + 3 .. Str'Last) &
                       " (" & String (Substring_To (Cur_Text, 1, 512)) &
                       ") in the Additional_Parameters argument?");
            end;
        end if;
        Free_Vstring (Cur_Text);

    end Parse_After_Name;

--\x0c
    procedure Parse_A_Name (Parms         :     Vstring;  
                            Name_Required :     Boolean;
                            Name_Value    : out Symbol_Value) is
------------------------------------------------------------------------------
-- Called with a partially eaten parameter string; we expect to have a name
-- at the beginning
------------------------------------------------------------------------------
        Cur_Lexeme : Lexeme_Kind;
        Cur_Text   : Vstring := New_Vstring (64);
        Cur_Value  : Symbol_Value;
    begin

        Empty_Vstring (Cur_Text);
        Next_Lexeme (Parms, Cur_Lexeme, Cur_Text, Cur_Value);
        if Cur_Lexeme = Lk_Eol or else  
           Cur_Lexeme = Lk_Comma then
            if Name_Required then
                Error ("Expected another parameter name at end of " &
                       "Additonal_Parameters string.");
            end if;
            Name_Value := (Sk_Boolean, Permanent => False, Bool => True);
        else
            if Cur_Lexeme = Lk_Identifier and then  
               Cur_Value.Permanent then
                Error ("Not allowed to change the value for symbol: " &
                       String (Substring_To (Cur_Text, 1, 512)));
            end if;
            if Cur_Lexeme = Lk_Identifier or else  
               Cur_Lexeme = Lk_Unknown then
                Parse_After_Name (Parms, Cur_Value);
                Symbol_Map.Insert
                   (Sym_Map, To_String (Cur_Text), Cur_Value, Dups_Ok => True);
                Name_Value := Cur_Value;
            else
                declare
                    Str : constant String := Lexeme_Kind'Image (Cur_Lexeme);
                begin
                    Error ("Found a " & Str (Str'First + 3 .. Str'Last) &
                           " (" & String (Substring_To (Cur_Text, 1, 512)) &
                           ") in the Additional_Parameters argument?");
                end;
            end if;
        end if;
        Free_Vstring (Cur_Text);

    end Parse_A_Name;

--\x0c
    procedure Do_The_Parameter (Parms : Vstring) is
------------------------------------------------------------------------------
-- Called with a partially eaten parameter string.  We eat it with recursion.
------------------------------------------------------------------------------
        Cur_Value : Symbol_Value;
    begin

        while Length (Parms) > 0 loop
            Parse_A_Name (Parms, False, Cur_Value);
        end loop;

    end Do_The_Parameter;

--\x0c
    procedure Parameter_Definition (Additional_Parameters : String) is
------------------------------------------------------------------------------
--  Additional_Parameters - Specifies additional/different parameter values
--      than the default set
--
-- Called as an initialization procedure.  Sets up all of the default
-- parameter values and additionally adds or modifies any parameters that
-- are specified by the argument.
--
-- Specify parameter values with strings with these forms:
--
--      "Sun=>TRUE"                     -- any number of blanks are optional
--      "Sun => TRUE"                   -- any number of blanks are optional
--      "Sun"                           -- same as "Sun=>TRUE"
--      "Sun|Unix=>FALSE"               -- set several to one value
--      "Sun=>TRUE,Unix=>TRUE"          -- set several to several values
--
-- Blanks are allowed anywhere and are optional.  Each parameter must be
-- mentioned by name.
------------------------------------------------------------------------------
        Tmpstr : Vstring;
    begin

----First, keywords.

        Define_Keywords;

----Second, parameters and values already in use.

        Define_Predefineds;

----Third, new parameter values and/or new parameters.

        Assign_New (Tmpstr, E_String (Additional_Parameters));
        Do_The_Parameter (Tmpstr);
        Free_Vstring (Tmpstr);
        if There_Were_Errors then
            raise Ada_Parameterization.Ada_Parameterization_Errors;
        end if;

    end Parameter_Definition;

--\x0c
begin

    Symbol_Map.New_Map (Sym_Map);


end Symbol_Table;

E3 Meta Data

    nblk1=e
    nid=0
    hdr6=1c
        [0x00] rec0=1f rec1=00 rec2=01 rec3=03a
        [0x01] rec0=11 rec1=00 rec2=02 rec3=068
        [0x02] rec0=16 rec1=00 rec2=03 rec3=016
        [0x03] rec0=17 rec1=00 rec2=04 rec3=024
        [0x04] rec0=00 rec1=00 rec2=0e rec3=006
        [0x05] rec0=1c rec1=00 rec2=05 rec3=032
        [0x06] rec0=00 rec1=00 rec2=0d rec3=002
        [0x07] rec0=14 rec1=00 rec2=06 rec3=066
        [0x08] rec0=1a rec1=00 rec2=07 rec3=076
        [0x09] rec0=17 rec1=00 rec2=08 rec3=040
        [0x0a] rec0=00 rec1=00 rec2=0c rec3=006
        [0x0b] rec0=17 rec1=00 rec2=09 rec3=03a
        [0x0c] rec0=19 rec1=00 rec2=0a rec3=032
        [0x0d] rec0=22 rec1=00 rec2=0b rec3=000
    tail 0x21500ac6081978e871b12 0x42a00088462063203