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

⟦334684259⟧ TextFile

    Length: 9327 (0x246f)
    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 String_Utilities;

separate (Lexical)

package body Simulated_Automate is

    type State is (St_Start, St_Let, St_Minus, St_Comm, St_Great,
                   St_Less, St_Hexa, St_Nbr, St_Word, St_Found);

    subtype Low_Alpha is Character range 'a' .. 'z';
    subtype Upp_Alpha is Character range 'A' .. 'Z';

    -- subtype Low_Alpha_Hexa is Character range 'a' .. 'f';
    -- subtype Upp_Alpha_Hexa is Character range 'A' .. 'F';

    subtype Digit is Character range '0' .. '9';

    package Keywords is
        function Is_Keyword (The_Lexeme : Lexeme) return Boolean;
        function Lexeme_To_Token (From : Lexeme) return Token;
    end Keywords;

    package body Keywords is separate;

    procedure File_Next_Char (C : in out Character) is
    begin  
        if At_End then
            C := Ascii.Eot;
        else
            if Text_Io.End_Of_Line (The_File) then
                Text_Io.Skip_Line (The_File);
                C := Ascii.Lf;
            else
                if Look_Ahead.Is_Existing then
                    C := Look_Ahead.Value;
                else
                    Text_Io.Get (The_File, C);
                end if;
            end if;
        end if;
    end File_Next_Char;

    procedure Next is  
        Current_State : State;  
        Current_Char : Character;  
        Number : Integer;
        Conversion_Ok : Boolean;
    begin
        if not At_End then
            Bounded_String.Free (Current_Value);
            Current_State := St_Start;
            loop
                File_Next_Char (Current_Char);
                case Current_State is

                    when St_Start =>
                        case Current_Char is

                            when Ascii.Eot =>
                                Current_Token := L_Eof;
                                Current_State := St_Found;

                            when ' ' | Ascii.Lf | Ascii.Ht =>
                                null;

                            when '(' =>
                                Current_Token := L_Open;
                                Current_State := St_Found;

                            when ')' =>  
                                Current_Token := L_Close;
                                Current_State := St_Found;

                            when ',' =>  
                                Current_Token := L_Comma;
                                Current_State := St_Found;

                            when '.' =>  
                                Current_Token := L_Point;
                                Current_State := St_Found;

                            when ':' =>
                                Current_State := St_Let;

                            when '+' =>  
                                Current_Token := L_Plus;
                                Current_State := St_Found;

                            when '-' =>  
                                Current_State := St_Minus;

                            when '*' =>
                                Current_Token := L_Star;
                                Current_State := St_Found;

                            when '/' =>  
                                Current_Token := L_Slash;
                                Current_State := St_Found;

                            when '=' =>  
                                Current_Token := L_Equ;
                                Current_State := St_Found;

                            when '>' =>
                                Current_State := St_Great;

                            when '<' =>
                                Current_State := St_Less;

                            when '#' =>
                                Current_State := St_Hexa;

                            when Digit =>
                                Bounded_String.Append
                                   (Current_Value, Current_Char);
                                Current_State := St_Nbr;

                            when Low_Alpha | Upp_Alpha | '_' =>
                                Bounded_String.Append
                                   (Current_Value, Current_Char);
                                Current_State := St_Word;

                            when others =>  
                                Current_Token := L_Unk;
                                Current_State := St_Found;
                        end case;

                    when St_Let =>
                        if Current_Char = '=' then
                            Current_Token := L_Affect;
                            Current_State := St_Found;
                        else
                            Current_Token := L_Unk;
                            Current_State := St_Found;
                        end if;

                    when St_Minus =>
                        if Current_Char = '-' then
                            Current_State := St_Comm;
                        else  
                            Look_Ahead.Affect (Current_Char);
                            Current_Token := L_Minus;
                            Current_State := St_Found;
                        end if;

                    when St_Comm =>
                        if Current_Char = Ascii.Lf then
                            Current_State := St_Start;
                        end if;

                    when St_Great =>
                        if Current_Char = '=' then  
                            Current_Token := L_Geq;
                            Current_State := St_Found;
                        else  
                            Look_Ahead.Affect (Current_Char);
                            Current_Token := L_Gt;
                            Current_State := St_Found;
                        end if;

                    when St_Less =>
                        case Current_Char is
                            when '=' =>
                                Current_Token := L_Leq;
                                Current_State := St_Found;

                            when '>' =>
                                Current_Token := L_Neq;
                                Current_State := St_Found;

                            when others =>
                                Look_Ahead.Affect (Current_Char);
                                Current_Token := L_Lt;
                                Current_State := St_Found;
                        end case;

                    when St_Hexa =>
                        case Current_Char is
                            when Digit | Low_Alpha | Upp_Alpha =>
                                Bounded_String.Append
                                   (Current_Value, Current_Char);

                            when others =>
                                Look_Ahead.Affect (Current_Char);
                                begin
                                    String_Utilities.String_To_Number
                                       (Bounded_String.Image (Current_Value),
                                        Number, Conversion_Ok, 16);

                                    if Conversion_Ok then
                                        Bounded_String.Free (Current_Value);
                                        Bounded_String.Append
                                           (Current_Value,
                                            String_Utilities.Number_To_String
                                               (Number));
                                        Current_Token := L_Nbr;
                                        Current_State := St_Found;
                                    else
                                        Current_Token := L_Unk;
                                        Current_State := St_Found;
                                    end if;
                                exception
                                    when Numeric_Error =>
                                        Current_Token := L_Unk;
                                        Current_State := St_Found;
                                end;
                        end case;

                    when St_Nbr =>
                        if Current_Char in Digit then
                            Bounded_String.Append (Current_Value, Current_Char);
                        else
                            Look_Ahead.Affect (Current_Char);
                            Current_Token := L_Nbr;
                            Current_State := St_Found;
                        end if;

                    when St_Word =>
                        case Current_Char is
                            when Low_Alpha | Upp_Alpha | '_' | Digit =>
                                Bounded_String.Append
                                   (Current_Value, Current_Char);

                            when others =>
                                Look_Ahead.Affect (Current_Char);
                                Current_Token :=
                                   Keywords.Lexeme_To_Token (Lexical.Value);
                                Current_State := St_Found;
                        end case;

                    when St_Found =>
                        null;
                end case;
                exit when Current_State = St_Found;
            end loop;
        else
            Current_Token := L_Eof;
        end if;
    end Next;

end Simulated_Automate;