This module provides the term-expansion rules for DCGs as well as
phrase/2,3 and call_dcg/3 for calling DCGs. The original code was copied
from C-Prolog and written by Fernando Pereira, EDCAAD, Edinburgh, 1984.
Since then many people have modified and extended this code.
DCGs have for a long time been a moving target, notably when it comes to
dealing with cuts and unification delaying for calls to non-DCG code.
This has slowly converged. This implementation attempts to be closely
compatible to the pending ISO standard for DCGs.
dcg_body(:DCG, ?Pos0, +Qualify, ?List, ?Tail, -Goal, -Pos) is det[private]- Translate DCG body term.
qualify(+QualifyInfo, +Goal, +Pos0, -QGoal, -Pos) is det[private]-
- Arguments:
-
QualifyInfo | - is a term q(Module,Context,Pos) , where Module
is the module in which Goal must be called and Context is the
current source module. |
- dcg_extend(+Head, +Extra1, +Extra2, -NewHead)[private]
- Extend Head with two more arguments (on behalf DCG compilation).
The solution below is one option. Using =.. and append is the
alternative. In the current version (5.3.2), the =.. is actually
slightly faster, but it creates less garbage.
dcg_extend(:Rule, ?Pos0, ?List, ?Tail, -Head, -Pos) is det[private]- Extend a non-terminal with the DCG difference list List\Tail.
The position term is extended as well to reflect the layout of
the created term. The additional variables are located at the
end of the Rule.
dcg_bt_pos(?BraceTermPos, -Pos) is det[private]- Position transformation for mapping of {G} to (G, S=SR).
dcg_terminal_pos(+ListPos, -TermPos)[private]
dcg_qualify_pos(?TermPos0, ?ModuleCreatingPos, -TermPos)[private]
phrase(:RuleSet, ?List)
phrase(:RuleSet, ?List, ?Rest)- Interface to DCGs
Undocumented predicates
The following predicates are exported, but not or incorrectly documented.
dcg_translate_rule(Arg1, Arg2, Arg3, Arg4)
phrase(Arg1, Arg2, Arg3)
call_dcg(Arg1, Arg2, Arg3)
dcg_translate_rule(Arg1, Arg2)