Read a term from Stream, optionally returning extra information about the term.
A valid Prolog input stream, defaults to the current input stream.
The term that is read.
A list of zero or more of the following:
syntax_errorsProlog flag. The default is set by that flag. See ref-lps-flg.
=Var pairs, where each Name is an atom indicating the name of a non-anonymous variable in the term, and Var is the corresponding variable. The elements of the list are in the same order as in Term, i.e. in left-to-right traversal order.
=Var pairs, one for each non-anonymous variable appearing only once in the term. The elements of the list are in the same order as in Term, i.e. in left-to-right traversal order.
false. If selected, any occurrences of
@/2in the term read in are replaced by the potentially cyclic terms they denote as described below. Otherwise (the default), Term is just unified with the term read in.
The notation used when this option is selected is
Substitution is a list of Var=Term pairs where
the Var occurs in Template or in one of the Terms.
This notation stands for the instance of Template obtained by
binding each Var to its corresponding Term. The
purpose of this notation is to provide a finite printed representation
of cyclic terms. This notation is not used by default, and
@/2 has no special meaning except in this context.
Terms can be written in this notation using
write_term/[2,3] (see mpg-ref-write_term).
false. If this option is
read_term/[2,3]will consume the layout-text-item that follows the terminating ‘.’ (this layout-text-item can either be a layout-char or a comment starting with a ‘%’). If the option is
false, the layout-text-item will remain in the input stream, so that subsequent character input predicates will see it. The default of the
The characters read are subject to character-conversion.
Stream errors (see ref-iou-sfh-est), plus:
| ?- read_term(T, [variable_names(L)]). |: append([U|X],Y,[U|Z]) :- append(X,Y,Z). L = ['U'=_A,'X'=_B,'Y'=_C,'Z'=_D], T = (append([_A|_B],_C,[_A|_D]):-append(_B,_C,_D))
| ?- read_term(T, [layout(L), variable_names(Va), singletons(S)]). |: [ foo(X), X = Y ]. L = [35,[36,36],[36,[37,37,37],38]], S = ['Y'=_A], T = [foo(_B),_B=_A], Va = ['X'=_B,'Y'=_A] | ?- read_term(T, [consume_layout(false)]), get_code(C). |: 1. C = 10, T = 1 | ?- read_term(T, [consume_layout(true)]), get_code(C). |: 1. |: a C = 97, T = 1
char_conversion/2, ref-iou-tin-trm, ref-lps-flg.