1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
B() allows you to specify these choices with the operator precedence
directives tt(%left) and tt(%right). Each such directive contains a list of
tokens, which are operators whose precedence and associativity is being
declared. The tt(%left) directive makes all those operators left-associative
and the tt(%right) directive makes them right-associative. A third alternative
is tt(%nonassoc), which declares that it is a syntax error to find the same
operator twice `in a row'. Actually, tt(%nonassoc) is not currently (0.98.004)
punished that way by b(). Instead, tt(%nonassoc) and tt(%left) are
handled identically.
The relative precedence of different operators is controlled by the order in
which they are declared. The first tt(%left) or tt(%right) directive in the
file declares the operators whose precedence is lowest, the next such
directive declares the operators whose precedence is a little higher, and so
on.
|