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

⟦591299bda⟧ TextFile

    Length: 7051 (0x1b8b)
    Types: TextFile
    Names: »B«

Derivation

└─⟦2f6cfab89⟧ Bits:30000547 8mm tape, Rational 1000, !projects 94-01-04
    └─ ⟦d65440be7⟧ »DATA« 
        └─⟦this⟧ 

TextFile

package body Lex is
    Current_Token : Token.Object;
    Current_Value : String_Utile.Pstring;

    type State is (St_Normal, St_Less, St_Great, St_Word,
                   St_Number, St_Commentaire, St_Found);


    procedure Lexopen (Afile : Text_Io.File_Type) is
    begin
        File.Fileopen (Afile);
    end Lexopen;

    function Lexgettoken return Token.Object is
    begin
        return Current_Token;
    end Lexgettoken;

    function Lexgetvalue return String is
    begin
        return Current_Value.all;
    end Lexgetvalue;

    function Lexatend (Afile : Text_Io.File_Type) return Boolean is
    begin
        return File.Fileatend (Afile);
    end Lexatend;

    procedure Lexnexttoken (Afile : Text_Io.File_Type) is
        The_Char : Character;
        Current_State : State;
    begin
        if not File.Fileatend (Afile) then
            Current_State := St_Normal;
            while Current_State /= St_Found loop
                if not File.Fileatend (Afile) then
                    File.Filenext (Afile);
                    The_Char := File.Filevalue (Afile);
                else
                    The_Char := Ascii.Eot;
                end if;
                case Current_State is
                    when St_Normal =>
                        case The_Char is
                            when ' ' | Ascii.Cr =>
                                null;
                            when Ascii.Eot =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Eof;
                            when '<' =>
                                Current_State := St_Less;
                            when '>' =>
                                Current_State := St_Great;
                            when '=' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Egal;
                            when ':' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Deuxpoints;
                            when ',' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Virgule;
                            when '.' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Point;
                            when '(' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Parentheseg;
                            when ')' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Parenthesed;
                            when '+' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Plus;
                            when '-' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Moins;
                            when '/' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Slash;
                            when '*' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Star;
                            when '[' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Crochetg;
                            when ']' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Crochetd;
                            when '{' =>
                                Current_State := St_Commentaire;
                            when others =>
                                if The_Char in 'a' .. 'z' then
                                    String_Utile.Buildstring (The_Char);
                                    Current_State := St_Word;
                                else
                                    if The_Char in '0' .. '9' then
                                        String_Utile.Buildstring (The_Char);
                                        Current_State := St_Number;
                                    else
                                        Current_State := St_Found;
                                        Current_Token := Token.L_Unk;
                                    end if;
                                end if;
                        end case;
                    when St_Commentaire =>
                        if The_Char = '}' then
                            Current_State := St_Normal;
                        end if;
                    when St_Less =>
                        case The_Char is
                            when '=' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Inf_Ou_Egal;
                            when '>' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Different;
                            when others =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Inf;
                                File.Fileunget (Afile);
                        end case;
                    when St_Great =>
                        if The_Char = '=' then
                            Current_Token := Token.L_Sup_Ou_Egal;
                        else
                            Current_Token := Token.L_Sup;
                            File.Fileunget (Afile);
                        end if;
                        Current_State := St_Found;
                    when St_Word =>
                        if The_Char in 'a' .. 'z' or
                           The_Char in '0' .. '9' or The_Char = '_' then
                            String_Utile.Buildstring (The_Char);
                        else
                            Current_State := St_Found;
                            Current_Value := String_Utile.Givestring;
                            Current_Token := Token.Search_Token (Current_Value);
                            File.Fileunget (Afile);
                        end if;
                    when St_Number =>
                        if The_Char in '0' .. '9' then
                            String_Utile.Buildstring (The_Char);
                        else
                            Current_State := St_Found;
                            Current_Token := Token.L_Int;
                            Current_Value := String_Utile.Givestring;
                            File.Fileunget (Afile);
                        end if;
                    when others =>
                        null;
                end case;
            end loop;
        else
            Current_Token := Token.L_Eof;
        end if;

    end Lexnexttoken;

end Lex;