Syntax of Sentences as Terms


sentence --> clause
| directive
| grammar-rule

clause --> non-unit-clause
| unit-clause

directive --> command
| query

non-unit-clause --> head :- goals

unit-clause --> head {where head is not otherwise a sentence}

command --> :- goals

query --> ?- goals

head --> term {where term is not a number or a variable}

goals --> goals , goals
| goals -> goals ; goals
| goals -> goals
| goals ; goals
| goal

goal --> term {where term is not a number and is not otherwise a goals}

grammar-rule --> gr-head --> gr-body

gr-head --> nonterminal
| nonterminal , terminals

gr-body --> gr-body , gr-body
| gr-body ; gr-body
| gr-body -> gr-body ; gr-body
| gr-body -> gr-body
| nonterminal
| terminals
| gr-condition

nonterminal --> term {where term is not a number or variable and is not otherwise a gr-body}

terminals --> list | string

gr-condition --> { goals }