Prolog Language Definite Clause Grammars (DCGs) Extra goals


Example

Extra goals enable to add processing to DCG clauses, for example, conditions that the elements of the list must satisfy.

The extra goals are observed between curly braces at the end of a DCG clause.

% DCG clause requiring an integer
int --> [X], {integer(X)}.

Usage:

?- phrase(int, [3]).
true.

?- phrase(int, [a]).
false.