title: Bison/YACC - avoid reduce/reduce conflict with two negation rules
body: <p>The following grammar (where INTEGER is a sequence of digits) gives rise to a reduce/reduce conflict, because e.g. -4 can be reduced by expr -> -expr or expr -> num -> -INTEGER. In my grammar, num and expr return different types so that I have to distinguish -num and -expr. My goal is that -5 is reduced by num while e.g. -(...) is an expr. How could I achieve this?</p>
  
  <pre><code>%token      INTEGER
  
  %left       '+'     '-'
  
  %%
  
  start: expr
      ;
  
  expr: expr '+' expr
      | expr '-' expr
      | '-' expr
      | '(' expr ')'
      | num
      ;
  
  num:  INTEGER
      | '-' INTEGER
      ;
  %%
  </code></pre>