DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(bison.info) Precedence Decl

Info Catalog (bison.info) Token Decl (bison.info) Declarations (bison.info) Union Decl
 
 Operator Precedence
 -------------------
 
    Use the `%left', `%right' or `%nonassoc' declaration to declare a
 token and specify its precedence and associativity, all at once.  These
 are called "precedence declarations".   Operator Precedence
 Precedence, for general information on operator precedence.
 
    The syntax of a precedence declaration is the same as that of
 `%token': either
 
      %left SYMBOLS...
 
 or
 
      %left <TYPE> SYMBOLS...
 
    And indeed any of these declarations serves the purposes of `%token'.
 But in addition, they specify the associativity and relative precedence
 for all the SYMBOLS:
 
    * The associativity of an operator OP determines how repeated uses
      of the operator nest: whether `X OP Y OP Z' is parsed by grouping
      X with Y first or by grouping Y with Z first.  `%left' specifies
      left-associativity (grouping X with Y first) and `%right'
      specifies right-associativity (grouping Y with Z first).
      `%nonassoc' specifies no associativity, which means that `X OP Y
      OP Z' 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.
 
Info Catalog (bison.info) Token Decl (bison.info) Declarations (bison.info) Union Decl
automatically generated byinfo2html