| sentence | ::= module :sentence | 
|  | |  list | { where list is a list of sentence } | 
|  | |  clause | 
|  | |  directive | 
|  | |  query | 
|  | |  grammar-rule | 
|  | 
| clause | ::= rule | unit-clause | 
|  | 
| rule | ::= head :-body | 
|  | 
| unit-clause | ::= head | { where head is not otherwise a sentence } | 
|  | 
| directive | ::= :-body | 
|  | 
| query | ::= ?-body | 
|  | 
| head | ::= module :head | 
|  | |  goal | { where goal is not a variable } | 
|  | 
| body | ::= module :body | 
|  | |  body ->body disj body | 
|  | |  body ->body | 
|  | | \+body | 
|  | |  body disj body | 
|  | |  body ,body | 
|  | | once(body) | 
|  | | do(iter,body) | 
|  | | if(body,body,body) | 
|  | |  term ^body | 
|  | |  goal | 
|  | 
| goal | ::= term | { where term is not otherwise a body } | 
|  | 
| grammar-rule | ::= gr-head -->gr-body | 
|  | 
| gr-head | ::= module :gr-head | 
|  | |  gr-head ,terminals | 
|  | |  non-terminal | { where non-terminal is not a variable } | 
|  | 
| gr-body | ::= module :gr-body | 
|  | |  gr-body ->gr-body disj gr-body | 
|  | |  gr-body ->gr-body | 
|  | | \+gr-body | 
|  | |  gr-body disj gr-body | 
|  | |  gr-body ,gr-body | 
|  | | once(gr-body) | 
|  | | do(iter,gr-body) | 
|  | | if(gr-body,gr-body,gr-body) | 
|  | |  term ^gr-body | 
|  | |  non-terminal | 
|  | |  terminals | 
|  | |  gr-condition | 
|  | 
| non-terminal | ::= term | { where term is not otherwise a gr-body } | 
|  | 
| terminals | ::= list | string | 
|  | 
| gr-condition | ::= !|{body} | 
|  | 
| module | ::= atom | 
|  | 
| disj | ::= ;|| | { read as ;unless|is declared infix } | 
|  | 
| iter | ::= iter ,iter | 
|  | | fromto(term,term,term,term) | 
|  | | foreach(term,term) | 
|  | | foreacharg(term,term) | 
|  | | foreacharg(term,term,term) | 
|  | | count(term,term,term) | 
|  | | for(term,term,term) | 
|  | | param(term) |