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

⟦1d91c5067⟧ TextFile

    Length: 10135 (0x2797)
    Types: TextFile
    Names: »B«

Derivation

└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
    └─ ⟦129cab021⟧ »DATA« 
        └─⟦this⟧ 

TextFile

with Bounded_String;
with Fichier_Io;
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.Copy (Current_Value, "Inf");
                                Current_Token := Token'(Binary);
                                State := Etat'(Less);

                            when '>' =>
                                Bounded_String.Copy (Current_Value, "Sup");
                                Current_Token := Token'(Binary);
                                State := Etat'(Greater);

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

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

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

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

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

                            when '.' =>
                                Bounded_String.Append (Current_Value, C);
                                Current_Token := Token'(Point);
                                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.Copy (Current_Value, "Et");
                                Current_Token := Token'(Binary);
                                State := Etat'(Found);

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

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

                            when '"' =>
                                State := Etat'(String);

                            when '[' =>
                                State := Etat'(Comment);

                            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 in '0' .. '9' then
                            Bounded_String.Append (Current_Value, C);
                        elsif C = '_' then
                            null;
                        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 =>
                        if C /= '"' then
                            Bounded_String.Append (Current_Value, C);
                            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
                            Bounded_String.Append (Current_Value, C);
                            Current_Token := Token'(String);
                            State := Etat'(String);
                        end if;

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

                    when Less =>
                        if C = '=' then
                            Bounded_String.Copy (Current_Value, "Inf_Egal");
                            Current_Token := Token'(Binary);
                            State := Etat'(Found);
                        elsif C = '>' then
                            Bounded_String.Copy (Current_Value, "Diff");
                            Current_Token := Token'(Binary);
                            State := Etat'(Found);
                        else
                            Fichier_Io.Unget (Fichier_Source);
                            State := Etat'(Found);
                        end if;

                    when Comment =>
                        if C = ']' then
                            State := Etat'(Normal);
                        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;

    function Get_Line_Number return Object.Index is
    begin
        return Fichier_Io.Get_Line_Number;
    end Get_Line_Number;

    procedure Put_Line_Number (Value : Object.Index) is
    begin
        Fichier_Io.Put_Line_Number (Value);
    end Put_Line_Number;

end Scanner;