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.
=Var pairs, one for each variable appearing only once in the term and whose name does not begin with ‘_’.
The Prolog flag
legacy_char_classification changes the criteria
for which variables are included in Names. When
legacy_char_classification is in effect the list also includes
variables that occur only once in the term and whose name begin with
‘_’ followed by a character that is not an uppercase Latin 1
false. If selected, any occurrences of
@/2in the term read in are replaced by the potentially cyclic terms they denote as described above. Otherwise (the default), Term is just unified with the term read in.
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.