If you want to experiment with DCGs here are a few things you should know:
There are two ways to call a procedure which you have defined using DCGs:
phrase/2. This takes as its first argument the highest level DCG rule head to apply (think of this as being like a top level Prolog goal) and as its second argument the list of terminal symbols which can be parsed using the group of DCG clauses referenced by the term in the first argument.
If you want to see how the Prolog system will translate your DCGs into ordinary clauses there are two ways in which you can do this:
expand_term/2with the first argument containing a DCG clause. It will return the expanded translation as its second argument. For example:
| ?- expand_term(a --> b, X). X = a(_124,_133):-b(_124,_133)
listing/0which will list out all the loaded clauses in translated form.