Using Precedence
Previous: <Why Precedence=>WhyPrecede> * Next: <Precedence Examples=>Precedencg> * Up: <Precedence=>Precedencf>

#Wrap on
{fH4}Specifying Operator Precedence{f}

Bison allows you to specify these choices with the operator precedence
declarations {fCode}%left{f} and {fCode}%right{f}.  Each such declaration
contains a list of tokens, which are operators whose precedence and
associativity is being declared.  The {fCode}%left{f} declaration makes all
those operators left-associative and the {fCode}%right{f} declaration makes
them right-associative.  A third alternative is {fCode}%nonassoc{f}, which
declares that it is a syntax error to find the same operator twice ``in a
row''.

The relative precedence of different operators is controlled by the
order in which they are declared.  The first {fCode}%left{f} or
{fCode}%right{f} declaration in the file declares the operators whose
precedence is lowest, the next such declaration declares the operators
whose precedence is a little higher, and so on.

