Node:Term Token, Next:, Previous:Sentence, Up:Full Syntax



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 layout-text }
                   |  op(N,fy) subterm(N)
                         { if subterm starts with a (,
                           op must be followed by layout-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(1000)        --> subterm(999) , subterm(1000)

term(0)           --> functor ( arguments )
                         { provided there is no layout-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