Contents    Page-10    Prev    Next    Page+10    Index   

Parsing Action Conflicts[slide by John Werth.]

Parsing action conflicts are not necessarily fatal; yacc resolves them using the following default rules:

A more general mechanism used to resolve shift reduce is to associate a precedence and associativity to both productions and terminal.

Precedence of terminal depends on the order in which it appears in the specification: for example, * is higher than + in the earlier example.

The precedence and associativity of a production is that of the rightmost terminal by default. It can be set with %prec to that of any terminal. For example,

   expr : '-' expr %prec UMINUS
sets the production associativity and precedence to that of UMINUS.