I have declared such precedence for bison
:
%left '+' '-'
%left '*' '/'
Recursive rules for arithmetic:
exp: exp binary_op exp { .. }
| literal_exp { .. }
| ID { .. }
binary_op: '+' { .. }
| '-' { .. }
| '*' { .. }
| '/' { .. }
I have an arithmetic expression: 10 * 3 + 5
My program calculates the sum, and it's 80! I still don't know why precedence doesn't work.