A clause of a Definite Clause Grammar is introduced with the binary
predicate -->/2
and closed by a dot. Lists in position of
predicates in the clause denote terminals to be scanned. Scanning is
done either from a Prolog list or from a token database (implementing a
Finite State Automata).
The following program implements reverse with a Definite Clause Grammar.
reverse(X,Y) :- phrase(rev(Y),X,[]). rev([]) --> []. rev([X|Y]) --> rev(Y),[X].
Directive clauses are conjunctions of directives introduced par the
unary predicate :-/1
and close by a dot mark.
:-include('foo.pl'),op(300,xfx,[hello]).