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;
-- Input: sequence of characters and integers, surrounded by any number
-- of blanks and newlines
-- Output: Each character and integer, on a separate line. Skipes white space.
-- Example Input:
-- a b 1234567 cd 12 8 d e
-- g 12 34
-- Example Output:
-- a
-- b
-- 1234567
-- c
-- d
-- 12
-- 8
-- e
-- g
-- 12
-- 34
procedure lookahead3 is
i: integer;
c: character;
eol: boolean;
begin
loop
exit when end_of_file;
look_ahead(c, eol);
if eol then
skip_line;
else -- Only look at c if not at eol
if c = ' ' then
get(c); -- get the blank, move input marker
elsif is_digit(c) then
get(i); -- Integer get
put(i); new_line;
else -- not a space or an integer
get(c);
put(c); new_line;
end if;
end if;
end loop;
end lookahead3;