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

⟦e0dfec799⟧ TextFile

    Length: 8391 (0x20c7)
    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 Standard_String;
with String_Utilities;
with Text_Io;

-- ajoute par pichot

package body Lexical is

    type Pstring is access String;
    subtype Keywords is Token range L_Materiel .. L_Sans;  
    type Keywords_Table is array (Keywords) of Pstring;

    The_File : Text_Io.File_Type;
    Current_Value : Standard_String.Object;
    Current_Token : Token := L_Unk;


    type State is (St_Normal, St_Sub, St_Comment, St_Word, St_Number, St_Found);

    subtype Part_Of_State is State range State'First .. St_Number;

    The_Keywords_Table : constant Keywords_Table :=
       (L_Materiel => new String'("MATERIEL"),
        L_Begin => new String'("DEBUT"),
        L_End => new String'("FIN"),
        L_Fait => new String'("FAIT"),
        L_Binaire => new String'("BINAIRE"),
        L_Fugitif => new String'("FUGITIF"),
        L_Temporel => new String'("TEMPOREL"),
        L_Acteurs => new String'("ACTEURS"),
        L_Est => new String'("EST"),
        L_Sur => new String'("SUR"),
        L_Station => new String'("STATION"),
        L_Scenario => new String'("SCENARIO"),
        L_Scene => new String'("SCENE"),
        L_Dans => new String'("DANS"),
        L_Faire => new String'("FAIRE"),
        L_Repeter => new String'("REPETER"),
        L_Fois => new String'("FOIS"),
        L_Repeter_Ad_Eternam => new String'("REPETER_AD_ETERNAM"),
        L_Toutes => new String'("TOUTES"),
        L_Les => new String'("LES"),
        L_Pendant => new String'("PENDANT"),
        L_De => new String'("DE"),
        L_Vers => new String'("VERS"),
        L_En => new String'("EN"),
        L_Experience => new String'("EXPERIENCE"),
        L_Effet => new String'("EFFET"),
        L_Enchainement => new String'("ENCHAINEMENT"),
        L_Groupe => new String'("GROUPE"),
        L_Hasard => new String'("HASARD"),
        L_Avec => new String'("AVEC"),
        L_Sans => new String'("SANS"));

    package File is  
        procedure Open (A_File : Text_Io.File_Type);
        function At_End (A_File : Text_Io.File_Type) return Boolean;
        procedure Next (A_File : Text_Io.File_Type);
        function Value (A_File : Text_Io.File_Type) return Character;
        function Get (A_File : Text_Io.File_Type) return Character;
        procedure Unget (A_File : Text_Io.File_Type);
    end File;

    package body File is separate;

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

    procedure Close_The_File is
    begin
        Text_Io.Close (File => The_File);
    end Close_The_File;

    function At_End return Boolean is
    begin
        return File.At_End (The_File);
    end At_End;

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


    function Get_Value return Standard_String.Object is
    begin
        return Current_Value;
    end Get_Value;

    function Keyword_To_Token  
                (A_String : Standard_String.Object) return Token is  
        S : String (1 .. Standard_String.Length (A_String));
    begin  
        S := String_Utilities.Upper_Case
                (Standard_String.Get_Contents (A_String));
        for I in Keywords loop
            if S = The_Keywords_Table (I).all then
                return I;
            end if;
        end loop;  
        return L_Id;
    end Keyword_To_Token;

    function Is_Alpha (A_Char : Character) return Boolean is
    begin
        return A_Char in 'a' .. 'z' or A_Char in 'A' .. 'Z';  
    end Is_Alpha;

    function Is_Digit (A_Char : Character) return Boolean is
    begin
        return A_Char in '0' .. '9';
    end Is_Digit;

    procedure Next is
        Current_Number : Integer := 0;
        Current_String : Standard_String.Object;  
        Current_State : State;
        Current_Char : Character;
    begin
        if not File.At_End (The_File) then
            Current_State := St_Normal;
            while (Current_State /= St_Found) loop
                if not File.At_End (The_File) then
                    File.Next (The_File);
                    Current_Char := File.Value (The_File);
                else
                    Current_Char := Ascii.Eot;
                end if;  
                case Part_Of_State'(Current_State) is
                    when St_Normal =>
                        case Current_Char is
                            when Ascii.Eot =>
                                Current_Token := L_Eof;
                                Current_State := St_Found;
                            when ' ' | Ascii.Cr =>
                                null;
                            when '+' =>
                                Current_Token := L_Plus;
                                Current_State := St_Found;
                            when '=' =>
                                Current_Token := L_Equal;
                                Current_State := St_Found;
                            when '*' =>
                                Current_Token := L_Star;
                                Current_State := St_Found;
                            when ':' =>
                                Current_Token := L_D_Point;
                                Current_State := St_Found;
                            when '.' =>
                                Current_Token := L_Point;
                                Current_State := St_Found;
                            when '(' =>
                                Current_Token := L_Open;
                                Current_State := St_Found;
                            when ')' =>
                                Current_Token := L_Close;
                                Current_State := St_Found;
                            when '-' =>
                                Current_State := St_Sub;
                            when others =>
                                if Is_Alpha (Current_Char) then
                                    Standard_String.Add_Char
                                       (Current_String, Current_Char);
                                    Current_State := St_Word;
                                elsif Is_Digit (Current_Char) then
                                    Standard_String.Add_Char
                                       (Current_String, Current_Char);
                                    Current_State := St_Number;
                                else  
                                    Current_Token := L_Unk;
                                    Current_State := St_Found;
                                end if;
                        end case;  
                    when St_Sub =>
                        if Current_Char = '-' then
                            Current_State := St_Comment;
                        else
                            File.Unget (The_File);
                            Current_Token := L_Sub;
                            Current_State := St_Found;
                        end if;
                    when St_Comment =>
                        if Current_Char = Ascii.Cr then
                            Current_State := St_Normal;
                        end if;
                    when St_Word =>
                        if Is_Alpha (Current_Char) or
                           Is_Digit (Current_Char) or Current_Char = '_' then
                            Standard_String.Add_Char
                               (Current_String, Current_Char);
                        else
                            File.Unget (The_File);
                            Current_Token := Keyword_To_Token (Current_String);
                            Current_State := St_Found;
                        end if;
                    when St_Number =>
                        if Is_Digit (Current_Char) then
                            Standard_String.Add_Char
                               (Current_String, Current_Char);
                        else
                            File.Unget (The_File);
                            Current_Token := L_Number;
                            Current_State := St_Found;
                        end if;
                end case;
            end loop;
        else
            Current_Token := L_Eof;
        end if;
    end Next;

end Lexical;