Next: mpg-ref-read_line, Previous: mpg-ref-raise_exception, Up: mpg-bpr [Contents][Index]
read/[1,2]
ISOread(-Term)
read(+Stream, -Term)
Reads the next term from Stream and unifies it with Term. Same as:
read_term(Term, [])
read_term(Stream, Term, [])
stream_object, must be ground
A valid Prolog input stream.
term
The term to be read.
Term must be followed by a full stop. The full stop is removed from the input stream and is not a part of the term that is read. The term is read with respect to current operator declarations.
Does not finish until the full stop is encountered. Thus, if you type at top level
| ?- read(X)
then you will keep getting prompts (first ‘|: ’, and five spaces thereafter) every time you type RET, but nothing else will happen, whatever you type, until you type a full stop.
If a syntax error is encountered, then the action taken depends on the
current value of the syntax_errors
Prolog flag.
If the end of the current input stream has been reached, then
Term will be unified with the atom end_of_file
. Further
calls to read/[1,2]
for the same stream will then raise an
exception, unless the stream is connected to the terminal. The
characters read are subject to character-conversion.
Stream errors (see ref-iou-sfh-est), plus:
syntax_error
A syntax error was found.
read_term/[2,3]
, char_conversion/2
, ref-iou-tin-trm,
ref-lps-flg.