with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Characters.Handling; use Ada.Characters.Handling;

procedure LookAheadDemo is

    c: Character;
    i: Integer;

    line: String(1 .. 80);
    len: Natural;

    EOL: Boolean;

begin

    loop
        put("Enter a number or a string, or 'x' to exit: ");

        look_ahead(c, EOL);

        put_line("Value of c: |" & c & "|");
        put_line("Value of EOL: " & Boolean'Image(EOL));

        -- when EOL is true, look_ahead does not set c
        exit when c = 'x' and not EOL;

        if EOL then
            put_line("EOL is true.");
            skip_line;  -- Go to next line

        else -- Not EOL
            if Ada.Characters.Handling.is_digit(c) then

                -- Input and print an integer
                get(i);  
                put_line("You entered this number: " & Integer'Image(i));

            else  -- Input didn't start with a number

                -- Input and print a string
                get_line(line, len);  
                put_line("You entered this string: " & line(1 .. len));

            end if;
        end if;
    end loop;

end LookAheadDemo;