Skip to content
Norbert Preining edited this page Oct 6, 2017 · 2 revisions

operator precedence

CafeOBJ allows for complete freedom of syntax, in particular infix operators and overloading. To correctly parse terms that are ambiguous, all operators have precedence values. These values can be adjusted manually during definition of the operator (see operator attributes). In absence of manual specification of the operator precedence, the values are determined by the following rules:

  • standard prefix operators, i.e., those of the form op f : S1 .. Sk -> S, receive operator precedence value 0.
  • unary operators, i.e., those of the form op u_ : S1 -> S, receive precedence 15.
  • mix-fix operators with first and last token being arguments, i.e., those of the form op _ arg-or-op _ : S1 .. Sk -> S, receive precedence 41.
  • all other operators (constants, operators of the form a _ b, etc.) receive precedence 0.

Related: operator attributes

Clone this wiki locally