How to Use the Grammar Rule Facility

Following is a summary of the steps that enable you to construct and utilitze definte clause grammars:

STEPS:

  1. Write a grammar, using -->/2 to formulate rules.
  2. Compile the file containing the grammar rules. The Load Predicates call expand_term/2, which translates the grammar rules into Prolog clauses.
  3. Use phrase/[2,3] to parse or generate strings.

OPTIONAL STEPS:

  1. Modify the way in which Prolog translates your grammar rules by defining clauses for term_expansion/2.
  2. In debugging or in using the grammar facility for more obscure purposes it may be useful to understand more about expand_term/2 and 'C'/3.