4.1.7.4 Syntax of Terms as Tokens

term-read-in ::= subterm(1200) full-stop

subterm(N) ::= term(M) { where M is less than or equal to N }

term(N) ::= op(N,fx) subterm(N-1) { except in the case of a number if subterm starts with a ‘(’, op must be followed by whitespace-text }
| op(N,fy) subterm(N) { if subterm starts with a ‘(’, op must be followed by whitespace-text }
| subterm(N-1) op(N,xfx) subterm(N-1)
| subterm(N-1) op(N,xfy) subterm(N)
| subterm(N) op(N,yfx) subterm(N-1)
| subterm(N-1) op(N,xf)
| subterm(N) op(N,yf)

term(1100) ::= subterm(1099) | subterm(1100) { term with functor ;/2 }
term(1000) ::= subterm(999) , subterm(1000) { term with functor ','/2 }

term(0) ::= functor ( arguments ) { provided there is no whitespace-text between the functor and the ‘(’ }
| ( subterm(1200) )
| { subterm(1200) }
| list
| string
| constant
| variable

op(N,T) ::= name { where name has been declared as an operator of type T and precedence N }

arguments ::= subterm(999)
| subterm(999) , arguments

list ::= []
| [ listexpr ]

listexpr ::= subterm(999)
| subterm(999) , listexpr
| subterm(999) | subterm(999)

constant ::= atom | number

number ::= unsigned-number
| sign unsigned-number
| sign inf
| sign nan

unsigned-number ::= natural-number | unsigned-float

atom ::= name

functor ::= name

Send feedback on this subject.