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

⟦12fc16152⟧ TextFile

    Length: 5862 (0x16e6)
    Types: TextFile
    Names: »B«

Derivation

└─⟦85b835f43⟧ Bits:30000549 8mm tape, Rational 1000, Xlib rev 6.00
    └─ ⟦0c20f784e⟧ »DATA« 
        └─⟦1abbe589f⟧ 
            └─⟦591c5b094⟧ 
                └─⟦this⟧ 

TextFile

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

--\f

    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;

--\f

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;