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

⟦a212a90ec⟧ Ada Source

    Length: 10240 (0x2800)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Lexemes, seg_0057ff

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 Text_Io;

with Symbol_Table;

with Arithmetic;
use Arithmetic;
with Vstring_Equal;
use Vstring_Equal;
with Vstring_Scan;
use Vstring_Scan;
with Vstring_Query;
use Vstring_Query;
with Vstring_Type;
use Vstring_Type;

package body Lexemes is
------------------------------------------------------------------------------
-- 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.
------------------------------------------------------------------------------

------------------------------------------------------------------------------
-- Scanning Breaksets
------------------------------------------------------------------------------

    Over_Identifier : Breakset;         -- letters, digits, underscore
    Skip_Whitespace : Breakset;         -- space, ht, cr, lf, ff, vt

--\x0c
    procedure Next_Lexeme (Line   :        Vstring;  
                           Lexeme : in out Lexeme_Kind;  
                           Text   : in out Vstring;
                           Value  : in out Symbol_Value) is
------------------------------------------------------------------------------
--  Line    - Specifies the input line/fragment to scan
--  Lexeme  - Receives the Lexeme_Kind of the next lexeme
--  Text    - Receives the textual representation of the next lexeme; if any
--  Value   - Receives the value associated with the lexeme; if any
--
-- Called to scan the Line and to recognize and remove the next lexeme.
-- Lexeme is set to Lk_Error if we get confused.  Lk_Eol is returned if
-- the line is empty or ends with a comment.  The Text argument is only
-- set for Lk_Identifier values.  The Value argument is changed for any
-- lexeme value that is a name (keywords and parameter names); it's value
-- only has meaning for Lk_Identifiers.
------------------------------------------------------------------------------
        Brk     : Character;
        Success : Boolean;
    begin

        Trunc_Scan (Line, Skip_Whitespace, Brk);
        case Brk is

            when Ascii.Nul =>
                if Line.Length = 0 then
                    Lexeme := Lk_Eol;
                else
                    Lexeme := Lk_Error;
                end if;

----Letters indicate the start of a keyword or of a parameter name.

            when 'A' .. 'Z' | 'a' .. 'z' =>
                Scan (Text, Line, Over_Identifier, Brk);
                Symbol_Table.Symbol_Map.Find (Symbol_Table.Sym_Map,  
                                              To_String (Text),  
                                              Value,  
                                              Success);
                if not Success then
                    Lexeme := Lk_Unknown;
                elsif Value.Kind = Sk_Keyword then
                    Lexeme := Value.Kwd;
                else
                    Lexeme := Lk_Identifier;
                end if;

----Single character lexemes.

            when '|' =>
                Brk    := Lop_First (Line);
                Lexeme := Lk_Vbar;
            when ',' =>
                Brk    := Lop_First (Line);
                Lexeme := Lk_Comma;
            when ';' =>
                Brk    := Lop_First (Line);
                Lexeme := Lk_Semicolon;
            when '(' =>
                Brk    := Lop_First (Line);
                Lexeme := Lk_Lparen;
            when ')' =>
                Brk    := Lop_First (Line);
                Lexeme := Lk_Rparen;

----Other lexemes.

            when '=' =>
                if Line.Length > 1 and then  
                   Line.Chars (2) = '>' then
                    Lexeme := Lk_Arrow;
                    Truncstring_For (Line, 3, Inf);
                else
                    Brk    := Lop_First (Line);
                    Lexeme := Lk_Eql;
                end if;
            when '/' =>
                if Equal_Prefix (Line, "/=") then
                    Lexeme := Lk_Neq;
                    Truncstring_For (Line, 3, Inf);
                else
                    -- lexeme := lk_divide;
                    Lexeme := Lk_Error;
                end if;

----A dash is presumably a comment (at least until we have numeric types).

            when '-' =>
                if Line.Length < 2 or else  
                   Line.Chars (2) /= '-' then
                    Lexeme := Lk_Error;
                else
                    Empty_Vstring (Line);
                    Lexeme := Lk_Eol;
                end if;

----Anything else is an error; we don't know what to do.

            when others =>
                Lexeme := Lk_Error;

        end case;

    end Next_Lexeme;

--\x0c
begin

    Set_Breakset
       (Over_Identifier,
        "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_",
        "", "XR");

    Set_Breakset
       (Skip_Whitespace,
        ' ' & Ascii.Ht & Ascii.Cr & Ascii.Lf & Ascii.Ff & Ascii.Vt & Ascii.Nul,
        "", "XR");

end Lexemes;

E3 Meta Data

    nblk1=9
    nid=0
    hdr6=12
        [0x00] rec0=1f rec1=00 rec2=01 rec3=04e
        [0x01] rec0=12 rec1=00 rec2=02 rec3=05e
        [0x02] rec0=13 rec1=00 rec2=03 rec3=032
        [0x03] rec0=00 rec1=00 rec2=09 rec3=008
        [0x04] rec0=1c rec1=00 rec2=04 rec3=022
        [0x05] rec0=1d rec1=00 rec2=05 rec3=024
        [0x06] rec0=00 rec1=00 rec2=08 rec3=024
        [0x07] rec0=25 rec1=00 rec2=06 rec3=062
        [0x08] rec0=04 rec1=00 rec2=07 rec3=000
    tail 0x21500abb881978e756c97 0x42a00088462063203