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

⟦fde47f787⟧ TextFile

    Length: 7542 (0x1d76)
    Types: TextFile
    Names: »B«

Derivation

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

TextFile

-- table des symboles

with Text_Io;
with Fichier_Io;
with Bounded_String;
with Reserved_Word;

package body Scanner is
    procedure Open (Name : in Standard.String) is
    begin  
        Fichier_Io.Open (Fichier_Source, Name);
        Scanner.Next;
    end Open;

    procedure Close is
    begin
        Fichier_Io.Close (Fichier_Source);
    end Close;

    function At_End return Boolean is
    begin
        return Fichier_Io.At_End (Fichier_Source);
    end At_End;

    function At_Line return Boolean is
    begin
        return Fichier_Io.At_Line (Fichier_Source);
    end At_Line;

    procedure Next is
        C : Character;
        State : Etat;

    begin  
        Bounded_String.Free (Current_Value);
        if Fichier_Io.At_End (Fichier_Source) then
            Current_Token := Token'(Eof);
        else
            State := Etat'(Normal);
            loop
                if Fichier_Io.At_End (Fichier_Source) then
                    C := Ascii.Eot;
                else
                    C := Fichier_Io.Get (Fichier_Source);
                end if;

                case State is
                    when Normal =>
                        case C is
                            when Ascii.Eot =>
                                Current_Token := Token'(Eof);
                                State := Etat'(Found);

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

                            when '<' =>
                                Bounded_String.Append (Current_Value, C);
                                Current_Token := Token'(Inf);
                                State := Etat'(Inf);

                            when '>' =>
                                Bounded_String.Append (Current_Value, C);
                                Current_Token := Token'(Sup);
                                State := Etat'(Sup);

                            when '=' =>
                                Bounded_String.Append (Current_Value, C);
                                Current_Token := Token'(Egal);
                                State := Etat'(Found);

                            when '{' | '}' | '(' | ')' | '.' =>
                                Bounded_String.Append (Current_Value, C);
                                Current_Token := Token'(Special);
                                State := Etat'(Found);

                            when '+' =>
                                Bounded_String.Copy (Current_Value, "Plus");
                                Current_Token := Token'(Binary);
                                State := Etat'(Found);

                            when '-' =>
                                Bounded_String.Copy (Current_Value, "Moins");
                                Current_Token := Token'(Binary);
                                State := Etat'(Found);

                            when '*' =>
                                Bounded_String.Copy (Current_Value, "Mul");
                                Current_Token := Token'(Binary);
                                State := Etat'(Found);

                            when '/' =>
                                Bounded_String.Copy (Current_Value, "Div");
                                Current_Token := Token'(Binary);
                                State := Etat'(Found);

                            when '"' =>
                                Bounded_String.Append (Current_Value, C);
                                State := Etat'(String);

                            when others =>
                                if C in 'a' .. 'z' or else
                                   C in 'A' .. 'Z' or else C = '_' then  
                                    Bounded_String.Append (Current_Value, C);
                                    State := Etat'(Identifier);
                                elsif C in '0' .. '9' then
                                    Bounded_String.Append (Current_Value, C);
                                    State := Etat'(Number);
                                else
                                    Bounded_String.Append (Current_Value, C);
                                    Current_Token := Token'(Unknown);
                                    State := Etat'(Found);
                                end if;

                        end case;

                    when Number =>
                        if C in '0' .. '9' then
                            Bounded_String.Append (Current_Value, C);
                        else
                            Fichier_Io.Unget (Fichier_Source);
                            Current_Token := Token'(Integer);
                            State := Etat'(Found);
                        end if;

                    when Identifier =>
                        if C in 'a' .. 'z' or else
                           C in 'A' .. 'Z' or else C = '_' then
                            Bounded_String.Append (Current_Value, C);
                        elsif C = ':' then
                            Current_Token := Token'(Keyword);
                            State := Etat'(Found);  
                        else
                            Fichier_Io.Unget (Fichier_Source);
                            Current_Token := Token'(Identifier);
                            Current_Token := Reserved_Word.Reserved_To_Token
                                                (Bounded_String.Image
                                                    (Current_Value));
                            State := Etat'(Found);
                        end if;

                    when String =>
                        Bounded_String.Append (Current_Value, C);
                        if C /= '"' then
                            Current_Token := Token'(String);
                        else
                            State := Etat'(Found_String);
                        end if;

                    when Found_String =>
                        if C /= '"' then
                            Current_Token := Token'(String);
                            State := Etat'(Found);
                            Fichier_Io.Unget (Fichier_Source);
                        else
                            Current_Token := Token'(String);
                            State := Etat'(String);
                        end if;

                    when Sup =>
                        if C = '=' then
                            Bounded_String.Append (Current_Value, C);
                            Current_Token := Token'(Sup_Egal);
                        else
                            Fichier_Io.Unget (Fichier_Source);
                            State := Etat'(Found);
                        end if;

                    when Inf =>
                        if C = '=' then
                            Bounded_String.Append (Current_Value, C);
                            Current_Token := Token'(Inf_Egal);
                        else
                            Fichier_Io.Unget (Fichier_Source);
                            State := Etat'(Found);
                        end if;

                    when Found =>
                        null;
                end case;
                exit when (State = Found);
            end loop;
        end if;
    end Next;

    function Get_Value return Object.Tiny_String is
    begin
        return Scanner.Current_Value;
    end Get_Value;

    function Get_Token return Token is
    begin
        -- Next;
        return Scanner.Current_Token;
    end Get_Token;

end Scanner;