Next: , Previous: , Up: ref-gru   [Contents][Index]


4.14.2 How to Use the Grammar Rule Facility

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

STEPS:

  1. Write a grammar, using -->/2 to formulate rules.
  2. Compile the file containing the grammar rules. The Load Predicates automatically translate 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 user:term_expansion/6; see ref-lod-exp.
  2. In debugging or in using the grammar facility for more obscure purposes it may be useful to understand more about expand_term/2.

Send feedback on this subject.