Here are some examples of using defgrammar.
defgrammar
KnowledgeWorks and Prolog User Guide (Unix version) - 24 Mar 2017