
% read_string(Xs)  ---Xs will be a list of atoms read in from user input
%                     This code is based on code given in Clocksin & Mellish (1984)

read_string(Words) :-
   get0(Char),
   read_string(Char, Words).

read_string(C, []) :- newline(C), !.

read_string(C, Words) :- space(C), !,
   get0(Char),
   read_string(Char, Words).

read_string(Char, [Word|Words]) :-
   read_word(Char, Chars, Next),
   name(Word, Chars),
   read_string(Next, Words).


read_word(C, [], C) :- space(C), !.
read_word(C, [], C) :- newline(C), !.

read_word(Char, [Char|Chars], Last) :-
   get0(Next),
   read_word(Next, Chars, Last).


space(32).

newline(10).


