The original example was this
expr:
INTEGER
| expr '+' expr { $$ = $1 + $3; }
| expr '-' expr { $$ = $1 - $3; }
;
I wanted this to be “simpler,” so I wrote this (I understand that it will do a “+” to add and subtract. But this is an example)
expr:
INTEGER
| expr addOp expr { $$ = $1 + $3; }
;
addOp:
'+' { $$ = $1; }
| '-' { $$ = $1; }
;
Now I get a shift / decrease error. It should be the same -_- (for me). What do I need to do to fix this?
edit: To make everything clear. In the first case, there are no warnings / errors. I use% left to set priority (and I will use% right for = and other ops rights). However, this does not seem to apply to the transition to subexpressions.
user34537
source
share