Precedence Decl
Previous: <Token Decl=>TokenDecl> * Next: <Union Decl=>UnionDecl> * Up: <Declarations=>Declaratio>

#Wrap on
{fH4}Operator Precedence{f}

Use the {fCode}%left{f}, {fCode}%right{f} or {fCode}%nonassoc{f} declaration to
declare a token and specify its precedence and associativity, all at
once.  These are called {fUnderline}precedence declarations{f}.
\*Note <Precedence=>Precedencf>: Operator Precedence, for general information on operator precedence.

The syntax of a precedence declaration is the same as that of
{fCode}%token{f}: either

#Wrap off
#fCode
%left {fStrong}symbols{f}
#f
#Wrap on

or

#Wrap off
#fCode
%left <{fStrong}type{f}> {fStrong}symbols{f}
#f
#Wrap on

And indeed any of these declarations serves the purposes of {fCode}%token{f}.
But in addition, they specify the associativity and relative precedence for
all the {fStrong}symbols{f}:

#Indent +4

  The associativity of an operator {fStrong}op{f} determines how repeated uses
of the operator nest: whether {fEmphasis}{fStrong}x{f} {fStrong}op{f} {fStrong}y{f} {fStrong}op{f}
{fStrong}z{f}{f} is parsed by grouping {fStrong}x{f} with {fStrong}y{f} first or by
grouping {fStrong}y{f} with {fStrong}z{f} first.  {fCode}%left{f} specifies
left-associativity (grouping {fStrong}x{f} with {fStrong}y{f} first) and
{fCode}%right{f} specifies right-associativity (grouping {fStrong}y{f} with
{fStrong}z{f} first).  {fCode}%nonassoc{f} specifies no associativity, which
means that {fEmphasis}{fStrong}x{f} {fStrong}op{f} {fStrong}y{f} {fStrong}op{f} {fStrong}z{f}{f} is
considered a syntax error.


  The precedence of an operator determines how it nests with other operators.
All the tokens declared in a single precedence declaration have equal
precedence and nest together according to their associativity.
When two tokens declared in different precedence declarations associate,
the one declared later has the higher precedence and is grouped first.

#Indent

