DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

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

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦02a3691a1⟧ Ada Source

    Length: 11264 (0x2c00)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, package body File, package body Lexical, seg_02f2e1

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦5a81ac88f⟧ »Space Info Vol 1« 
        └─⟦this⟧ 

E3 Source Code



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;

E3 Meta Data

    nblk1=a
    nid=a
    hdr6=12
        [0x00] rec0=20 rec1=00 rec2=01 rec3=024
        [0x01] rec0=18 rec1=00 rec2=02 rec3=004
        [0x02] rec0=1f rec1=00 rec2=03 rec3=004
        [0x03] rec0=22 rec1=00 rec2=04 rec3=02a
        [0x04] rec0=17 rec1=00 rec2=05 rec3=04e
        [0x05] rec0=13 rec1=00 rec2=06 rec3=050
        [0x06] rec0=12 rec1=00 rec2=07 rec3=00a
        [0x07] rec0=13 rec1=00 rec2=08 rec3=096
        [0x08] rec0=15 rec1=00 rec2=09 rec3=001
        [0x09] rec0=cd rec1=09 rec2=18 rec3=6ed
    tail 0x217280edc848c6f24b981 0x42a00088462060003
Free Block Chain:
  0xa: 0000  00 00 00 06 80 03 3e 20 6e 03 20 6e 06 07 08 09  ┆      > n  n    ┆