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

⟦ac9a0318b⟧ TextFile

    Length: 8931 (0x22e3)
    Types: TextFile
    Names: »B«

Derivation

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

TextFile

with Line;
with My_String;  
with Text_Io;
with Token;
package body Lex2 is

    The_File : Text_Io.File_Type;
    Current_Token : Token.Object;
    Lookahead : Boolean := False;
    Current_Value : My_String.Object (1000);
    Current_Char : Character;

    procedure Lex_Adress_Error is
    begin
        Text_Io.Put_Line ("Erreur de semantique : Adresse incorrecte");
    end Lex_Adress_Error;


    procedure Open (Nom : String) is
        M : Text_Io.File_Mode := Text_Io.In_File;
    begin
        Text_Io.Open (File => The_File, Mode => M, Name => Nom, Form => "");
    end Open;

    procedure Close is
    begin
        Text_Io.Close (The_File);
    end Close;

    function Get_Char return Character is  
    begin  
        if Lookahead then
            Lookahead := False;
        else
            if Text_Io.End_Of_Line (The_File) then
                Text_Io.Skip_Line (The_File);
                Current_Char := Ascii.Cr;
            else
                Text_Io.Get (The_File, Current_Char);
            end if;
        end if;
        return Current_Char;
    end Get_Char;

    procedure Unget_Char is
    begin
        Lookahead := True;
    end Unget_Char;


    procedure Next is  
        type State is (St_Normal, St_Affect, St_Com_St, St_Less, St_Great,
                       St_Word, St_Number, St_Adresse, St_Found);
        Current_State : State;
        The_Char : Character;
    begin
        if not Text_Io.End_Of_File (The_File) then
            My_String.Flush (Current_Value);
            Current_State := St_Normal;
            while Current_State /= St_Found loop
                if not Text_Io.End_Of_File (The_File) then
                    The_Char := Get_Char;
                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_Affect;
                            when ':' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_2points;
                            when ',' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Virgule;
                            when '(' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Ouvrante;
                            when ')' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Fermante;
                            when '.' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Point;
                            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_Mult;
                            when '/' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Div;
                            when '[' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Crochet_Ouvrant;
                            when ']' =>
                                Current_State := St_Found;
                                Current_Token := Token.L_Crochet_Fermant;
                            when '{' =>
                                Current_State := St_Com_St;
                            when '#' =>
                                Current_State := St_Adresse;

                            when others =>  
                                if The_Char in 'a' .. 'z' or
                                   The_Char in 'A' .. 'Z' then
                                    My_String.Add (Current_Value, The_Char);
                                    Current_State := St_Word;
                                else
                                    if The_Char in '0' .. '9' then
                                        My_String.Add (Current_Value, The_Char);
                                        Current_State := St_Number;
                                    else
                                        Current_Token := Token.L_Unk;
                                        Current_State := St_Found;
                                    end if;
                                end if;
                        end case;

                    when St_Com_St =>
                        if The_Char = '}' then
                            Current_State := St_Normal;
                        end if;

                    when St_Less =>
                        case The_Char is
                            when '=' =>
                                Current_Token := Token.L_Inf_Ou_Egal;
                                Current_State := St_Found;
                            when '>' =>
                                Current_Token := Token.L_Pas_Egal;
                                Current_State := St_Found;
                            when others =>
                                Unget_Char;
                                Current_Token := Token.L_Inf;
                                Current_State := St_Found;
                        end case;

                    when St_Great =>
                        if The_Char = '=' then
                            Current_Token := Token.L_Sup_Ou_Egal;
                        else
                            Unget_Char;
                            Current_Token := Token.L_Sup;
                        end if;  
                        Current_State := St_Found;
                    when St_Word =>
                        if The_Char in 'a' .. 'z' or The_Char in 'A' .. 'Z' or
                           The_Char in '0' .. '9' or The_Char = '_' then
                            My_String.Add (Current_Value, The_Char);
                        else
                            Unget_Char;
                            Current_Token :=
                               Token.Value (My_String.Value (Current_Value));
                            Current_State := St_Found;
                        end if;
                    when St_Number =>
                        if The_Char in '0' .. '9' then
                            My_String.Add (Current_Value, The_Char);
                        else
                            Unget_Char;
                            Current_Token := Token.L_Nbr;
                            Current_State := St_Found;
                        end if;  
                    when St_Affect =>
                        if The_Char = '=' then
                            Current_State := St_Found;
                            Current_Token := Token.L_Egal;
                        else
                            Unget_Char;
                            Current_Token := Token.L_Affect;
                            Current_State := St_Found;
                        end if;
                    when St_Adresse =>
                        case The_Char is
                            when 'a' .. 'f' | 'A' .. 'F' | '0' .. '9' =>
                                My_String.Add (Current_Value, The_Char);
                            when '#' =>
                                Current_Token := Token.L_Adresse;
                                Current_State := St_Found;
                            when others =>
                                Lex_Adress_Error;
                        end case;
                    when others =>
                        null;

                end case;
            end loop;  
        else
            Current_Token := Token.L_Eof;
        end if;
    end Next;


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


    function Get_Value return String is
    begin
        return My_String.Value (Current_Value);
    end Get_Value;

    function At_End return Boolean is
    begin
        return Text_Io.End_Of_File (The_File);
    end At_End;
end Lex2;