title: Bison shift-reduce conflict when operators are grouped as a non-terminal
body: <p>Assuming I have the following rules in my grammar.</p>
  
  <pre><code>expr: expr op expr
      | NUMBER
  
  op: '+' | '-' | '*' | '/'
  </code></pre>
  
  <p>And I have the following declarations done</p>
  
  <pre><code>%token NUMBER
  
  %left '+' '-'
  %right '*' '/'
  </code></pre>
  
  <p>This causes 4 shift-reduce conflicts at</p>
  
  <pre><code>State 12
  
      4 expr: expr . op expr
      4     | expr op expr .
  
      '+'  shift, and go to state 6
      '-'  shift, and go to state 7
      '*'  shift, and go to state 8
      '/'  shift, and go to state 9
  
      '+'       [reduce using rule 4 (expr)]
      '-'       [reduce using rule 4 (expr)]
      '*'       [reduce using rule 4 (expr)]
      '/'       [reduce using rule 4 (expr)]
      $default  reduce using rule 4 (expr)
  
      op   go to state 11
  </code></pre>
  
  <p>However, if I rewrite my grammar as</p>
  
  <pre><code>expr: expr '+' expr
      | expr '-' expr
      | expr '*' expr
      | expr '/' expr
      | NUMBER
  </code></pre>
  
  <p>the precedence rules kick in and the conflicts are resolved. I believe the conflicts arise because when bison encounters an <code>op</code>, it doesn't keep track of the previous <code>op</code> that was shifted into the stack. Is there a way I could group all the operators and still resolve the conflicts?</p>