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

⟦420237301⟧ Ada Source

    Length: 15360 (0x3c00)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Lexical, seg_038312, seg_039029, seg_039072, seg_0391f5

Derivation

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

E3 Source Code



with Standard_String;
with String_Utilities;
with Text_Io;
with File;
with Erreurs;

with Motor;
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;
    Current_Number : Natural := 0;
    Line_Number : Integer := 1;

    type State is (St_Normal, St_Sub, St_Comment, St_Word,
                   St_Time, 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_Debut => new String'("DEBUT"),
        L_Fin => new String'("FIN"),
        L_Fait => new String'("FAIT"),
        L_Discret => new String'("DISCRET"),
        --modification et suppresion de L_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_Premier => new String'("PREMIER"),
        L_Duree => new String'("DUREE"),
        L_Avec => new String'("AVEC"),
        L_Sans => new String'("SANS"));


    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);
        Erreurs.Ouvrir (Name_File & "_err");
        Motor.Ouvrir (Name_File & "_code");
    end Open;


    procedure Close_The_File is
    begin
        Text_Io.Close (File => The_File);
        Erreurs.Fermer;
        Motor.Fermer;
    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 Get_Value return Integer is
        The_Length : Integer := Standard_String.Length (Current_Value);
        Time_String : String (1 .. (The_Length - 1));
        Tempo_String : String (1 .. The_Length);
        Response : Boolean;
        Current_Number : Integer;
    begin  
        Tempo_String := Standard_String.Get_Contents (Current_Value);
        if Current_Token = L_Number then
            String_Utilities.String_To_Number (Source => Tempo_String,
                                               Target => Current_Number,
                                               Worked => Response);  
            return Current_Number;
        elsif Current_Token = L_Temps then
            Time_String (1 .. (The_Length - 2)) :=
               Tempo_String (1 .. (The_Length - 2));
            Time_String (The_Length - 1) := Tempo_String (The_Length);
            String_Utilities.String_To_Number (Source => Time_String,
                                               Target => Current_Number,
                                               Worked => Response);  
            return Current_Number;
        else
            return 0;
        end if;
    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_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 ' ' =>
                                null;
                            when Ascii.Cr =>
                                Line_Number := Line_Number + 1;
                            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_Virgule;
                                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;
                            Line_Number := Line_Number + 1;
                        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_Time =>
                        if Is_Digit (Current_Char) then
                            Standard_String.Add_Char
                               (Current_String, Current_Char);
                            Current_State := St_Found;
                            Current_Token := L_Temps;
                        else
                            Current_State := St_Found;
                            Current_Token := L_Unk;
                        end if;
                    when St_Number =>
                        if Is_Digit (Current_Char) then
                            Standard_String.Add_Char
                               (Current_String, Current_Char);
                        else
                            if Current_Char = '.' then
                                Standard_String.Add_Char
                                   (Current_String, Current_Char);
                                Current_State := St_Time;
                            else
                                File.Unget (The_File);
                                Current_Token := L_Number;  
                                Current_State := St_Found;
                            end if;
                        end if;
                end case;
            end loop;
        else
            Current_Token := L_Eof;
        end if;
        Standard_String.Copy (Current_String, Current_Value);
    end Next;


    function Get_Line return Integer is  
    begin
        return Line_Number;
    end Get_Line;

end Lexical;

E3 Meta Data

    nblk1=e
    nid=0
    hdr6=1c
        [0x00] rec0=21 rec1=00 rec2=01 rec3=00e
        [0x01] rec0=01 rec1=00 rec2=0d rec3=02c
        [0x02] rec0=16 rec1=00 rec2=03 rec3=058
        [0x03] rec0=29 rec1=00 rec2=04 rec3=00a
        [0x04] rec0=05 rec1=00 rec2=0e rec3=008
        [0x05] rec0=12 rec1=00 rec2=0c rec3=022
        [0x06] rec0=24 rec1=00 rec2=09 rec3=038
        [0x07] rec0=17 rec1=00 rec2=0a rec3=026
        [0x08] rec0=12 rec1=00 rec2=05 rec3=070
        [0x09] rec0=12 rec1=00 rec2=06 rec3=00e
        [0x0a] rec0=12 rec1=00 rec2=07 rec3=024
        [0x0b] rec0=13 rec1=00 rec2=08 rec3=042
        [0x0c] rec0=1a rec1=00 rec2=02 rec3=01a
        [0x0d] rec0=04 rec1=00 rec2=0b rec3=000
    tail 0x21735d20084e68f7d115b 0x42a00088462060003