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

⟦4d7a1940c⟧ TextFile

    Length: 9691 (0x25db)
    Types: TextFile
    Names: »B«

Derivation

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

TextFile

with Text_Io;
with Lex_File;

package body Scanner is

    type State is (S_Found, S_Start, S_Integer, S_Identifier,
                   S_String, S_Minus, S_Less, S_Great, S_Comment);

    Current_String : String (1 .. 80);
    Symbol : Token;


    -- ****************************************
    -- * mise en route de l'analyseur lexical *
    -- ****************************************

    procedure Open (File_Name : String) is
    begin
        Lex_File.Open (File_Name);
    end Open;


    -- *********************************************
    -- * renvoi VRAI si fin de l'analyseur lexical *
    -- *********************************************

    function At_End return Boolean is
    begin
        return Lex_File.At_End;
    end At_End;


    -- ***************************************
    -- * analyse lexicale du symbole suivant *
    -- ***************************************

    procedure Next is

        Current_Char : Character;
        Current_Token : Token;
        Current_State : State;

    begin
        if Lex_File.At_End then
            Symbol := L_Eof;
        else
            -- init chaine a renvoyer avec le token
            Current_String := "";

            Current_State := S_Start;

            while (Current_State /= S_Found) loop

                if Lex_File.At_End then
                    Symbol := L_Eof;
                    Current_State := S_Found;
                else
                    -- avancer dans le fichier
                    Lex_File.Next;

                    -- lecture du caractere
                    Current_Char := Lex_File.Value;

                    case Current_State is

                        when S_Found =>
                            Current_State := S_Found;

                        when S_Start =>
                            case Current_Char is

                                when '0' .. '9' =>
                                    -- stocker le caractere
                                    Current_String :=
                                       Current_String & Current_Char;
                                    Current_State := S_Integer;

                                when 'A' .. 'Z' | 'a' .. 'z' =>
                                    -- stocker le caractere
                                    Current_String :=
                                       Current_String & Current_Char;
                                    Current_State := S_Identifier;

                                when ':' =>
                                    Current_Token := L_Unknown;
                                    Current_State := S_Found;

                                when '"' =>
                                    Current_State := S_String;

                                when '{' =>
                                    Current_Token := L_Openbracket;
                                    Current_State := S_Found;

                                when '}' =>
                                    Current_Token := L_Closebracket;
                                    Current_State := S_Found;

                                when '.' =>
                                    Current_Token := L_Dot;
                                    Current_State := S_Found;

                                when '(' =>
                                    Current_Token := L_Openparenthesis;
                                    Current_State := S_Found;

                                when ')' =>
                                    Current_Token := L_Closeparenthesis;
                                    Current_State := S_Found;

                                when '-' =>
                                    Current_State := S_Minus;

                                when '+' | '*' | '/' | '=' =>
                                    -- stocker le caractere
                                    Current_String :=
                                       Current_String & Current_Char;
                                    Current_Token := L_Binarymsg;
                                    Current_State := S_Found;

                                when '<' =>
                                    Current_State := S_Less;

                                when '>' =>
                                    Current_State := S_Great;

                                when others =>
                                    Current_State := S_Start;

                            end case;

                        when S_Integer =>
                            case Current_Char is

                                when 'A' .. 'Z' | 'a' .. 'z' =>
                                    Current_Token := L_Unknown;
                                    Current_State := S_Found;

                                when '0' .. '9' =>
                                    -- stocker le caractere
                                    Current_String :=
                                       Current_String & Current_Char;
                                    Current_State := S_Integer;

                                when others =>  
                                    Lex_File.Unget;
                                    Current_Token := L_Integer;
                                    Current_State := S_Found;

                            end case;

                        when S_Identifier =>
                            case Current_Char is

                                when 'A' .. 'Z' | 'a' .. 'z' =>
                                    -- stocker le caractere
                                    Current_String :=
                                       Current_String & Current_Char;
                                    Current_State := S_Identifier;

                                when ':' =>
                                    Current_Token := L_Keyword;
                                    Current_State := S_Found;

                                when '0' .. '9' =>
                                    Current_Token := L_Unknown;
                                    Current_State := S_Found;

                                when others =>  
                                    Lex_File.Unget;
                                    Current_Token := L_Identifier;
                                    Current_State := S_Found;

                            end case;

                        when S_String =>  
                            if Current_Char = '"' then
                                Current_Token := L_String;
                                Current_State := S_Found;
                            else
                                -- stocker le caractere
                                Current_String := Current_String & Current_Char;
                                Current_State := S_String;
                            end if;

                        when S_Minus =>
                            if Current_Char = '-' then
                                Current_State := S_Comment;
                            else
                                Lex_File.Unget;
                                Current_Token := L_Binarymsg;
                                Current_State := S_Found;
                            end if;

                        when S_Less =>
                            case Current_Char is
                                when '=' | '>' =>
                                    -- stocker le caractere
                                    Current_String :=
                                       Current_String & Current_Char;
                                    Current_Token := L_Binarymsg;
                                    Current_State := S_Found;

                                when ' ' =>
                                    Current_State := S_Less;

                                when others =>  
                                    Lex_File.Unget;
                                    Current_Token := L_Binarymsg;
                                    Current_State := S_Found;

                            end case;

                        when S_Great =>
                            case Current_Char is
                                when '=' =>
                                    -- stocker le caractere
                                    Current_String :=
                                       Current_String & Current_Char;  
                                    Current_Token := L_Binarymsg;
                                    Current_State := S_Found;

                                when ' ' =>
                                    Current_State := S_Great;

                                when others =>
                                    Lex_File.Unget;
                                    Current_Token := L_Binarymsg;
                                    Current_State := S_Found;

                            end case;

                        when S_Comment =>
                            -- if current_char = retour chariot then
                            Current_Token := L_Comment;
                            Current_State := S_Found;
                            -- end if;

                    end case;
                end if;
            end loop;

            Symbol := Current_Token;

        end if;
    end Next;


    -- *******************************
    -- * retourne la chaine courante *
    -- *******************************

    function Get_Value return String is
    begin
        return Current_String;
    end Get_Value;


    -- *****************************
    -- * retourne le token courant *
    -- *****************************

    function Get_Token return Token is
    begin
        return Symbol;
    end Get_Token;

end Scanner;