% read whitespace separated code lists

whitespace(32).
whitespace(10).
whitespace(13).
whitespace(9).

getCodeList(S,L):-get_code(S,X),(X<0 -> L = []; whitespace(X) -> getCodeList(S,L); L = [X|R], getCodeList1(S,R)).
getCodeList1(S,R):-get_code(S,X),(X<0 -> R = []; whitespace(X) -> R = []; R = [X|RR], getCodeList1(S,RR)).

% read whitespace separated numbers

getNumber(S,N):-getcodelist(S,X),(X = [] -> N = end_of_file; number_codes(N,X)).

% read whitespace separated terms

getTerm(S,T):-getcodelist(S,X),(X = [] -> T = end_of_file; read_term_from_codes(X,T,[])).

% read whitespace separated atoms

getAtom(S,A):-getcodelist(S,X),(X = [] -> A = end_of_file; atom_codes(A,X)).

% read whitespace separated strings

getString(S,A):-getcodelist(S,X),(X = [] -> A = end_of_file; string_to_list(A,X)).
