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