11.3.72 expand_term/2 [hookable]

Synopsis

expand_term(+Term1, -Term2)

Transforms source file terms into Prolog clauses before they are compiled. Normally called by the compiler, but can be called directly. The transform can be customized by defining user:term_expansion/6.

When a source file is compiled, expand_term/2 is called with the virtual clauses beginning_of_file before and end_of_file after the real Prolog clauses, to give user:term_expansion/6 an opportunity to perform some action at the beginning and end of a source file. Please note: the virtual clause beginning_of_file is “seen” before any module declaration, i.e. before the source module has been updated.

Arguments

Term1
term
Term2
term

Description

Usually called by the built-in predicates that read code and not directly by user programs.

in particular used to translate grammar rules, written with -->/2, into ordinary Prolog clauses, written with :-/2. If Term1 is a grammar rule, then Term2 is the corresponding clause. Otherwise Term2 is simply Term1 unchanged.

Calls user:term_expansion/6.

Exceptions

Prints messages for exceptions raised by user:term_expansion/6.

See Also

phrase/[2,3], -->/2, ref-lod-exp.


Send feedback on this subject.