Section "expansion"
We only provide shallow term expansion. Shallow term expansion can
be defined via the multi-file predicate term_expansion/2, but there
is no automatic call of goal_expansion/2 for any subgoals in the
directive or clause provided as a term. The Prolog system comes with
term expansion for definite clause grammars (DCG).
The following expansion predicates are provided:
- term_expansion(C, D):
- This predicate can be used to define custom term expansion
rules.
- expand_term(C, D):
- The predicate succeeds in D with the expansion of the term C.
- P --> Q: [DCG 7.13.2]
- P, R --> Q: [DCG 7.13.2]
- The fact is transformed into the DCG clause for the DCG
non-terminal P and the DCG body Q. The ternary form allows an
additional DCG push back R.
- phrase(B, I, O): [DCG 8.1.1]
- The predicate succeeds whenever the DCG body B succeeds for
the input I and the output O.