[not loaded]expand.pl -- Prolog source-code transformation
This module specifies, together with dcg.pl, the transformation of terms as they are read from a file before they are processed by the compiler.
The toplevel is expand_term/2. This uses three other translators:
- Conditional compilation
- term_expansion/2 rules provided by the user
- DCG expansion
Note that this ordering implies that conditional compilation directives cannot be generated by term_expansion/2 rules: they must literally appear in the source-code.
Term-expansion may choose to overrule DCG expansion. If the result of term-expansion is a DCG rule, the rule is subject to translation into a predicate.
Next, the result is passed to expand_bodies/2, which performs goal expansion.
- expand_term(+Input, -Output) is det
- expand_term(+Input, +Pos0, -Output, -Pos) is det
- This predicate is used to translate terms as they are read from a source-file before they are added to the Prolog database.
- var_property(+Var, ?Property)
- True when Var has a property Key with Value. Defined properties
are:
- fresh(Fresh)
- Variable is first introduced in this goal and thus guaranteed to be unbound. This property is always present.
- singleton(Bool)
- It
true
indicate that the variable appears once in the source. Note this doesn't mean it is a semantic singleton. - name(-Name)
- True when Name is the name of the variable.
- expand_goal(+BodyTerm, +Pos0, -Out, -Pos) is det
- expand_goal(+BodyTerm, -Out) is det
- Perform macro-expansion on body terms by calling goal_expansion/2.
- $expand_closure(+BodyIn, +ExtraArgs, -BodyOut) is semidet
- $expand_closure(+BodyIn, +PIn, +ExtraArgs, -BodyOut, -POut) is semidet
- Expand a closure using goal expansion for some extra arguments. Note that the extra argument must remain at the end. If this is not the case, '$expand_closure'/3,5 fail.
- expand_term(+Input, -Output) is det
- expand_term(+Input, +Pos0, -Output, -Pos) is det
- This predicate is used to translate terms as they are read from a source-file before they are added to the Prolog database.
- expand_goal(+BodyTerm, +Pos0, -Out, -Pos) is det
- expand_goal(+BodyTerm, -Out) is det
- Perform macro-expansion on body terms by calling goal_expansion/2.