I'm writing a small bison / flex calculator but I'm not able to understand and debug the verbose output
This is the code which is causing the errors:
%token NUM
%token NAME
%%
input: '\n'
| line '\n'
;
line: expr {printf("%.10g\n", $1);}
| NAME '=' expr {Assign(table, yyname, $3);}
;
expr: NUM {$$ = $1;}
| NAME {$$ = Lookup(table, yyname);}
| expr '+' expr {$$ = $1 + $2;}
| expr '-' expr {$$ = $1 - $2;}
| expr '*' expr {$$ = $1 * $2;}
| expr '/' expr {$$ = $1 / $2;}
| expr '^' expr {$$ = pow($1, $2);}
| '(' expr ')' {$$ = $2;}
The verbose error output is:
state 20
7 expr: expr . '+' expr
7 | expr '+' expr .
8 | expr . '-' expr
9 | expr . '*' expr
10 | expr . '/' expr
11 | expr . '^' expr
'+' shift, and go to state 13
'-' shift, and go to state 14
'*' shift, and go to state 15
'/' shift, and go to state 16
'^' shift, and go to state 17
'+' [reduce using rule 7 (expr)]
'-' [reduce using rule 7 (expr)]
'*' [reduce using rule 7 (expr)]
'/' [reduce using rule 7 (expr)]
'^' [reduce using rule 7 (expr)]
$default reduce using rule 7 (expr)
...
state 24
7 expr: expr . '+' expr
8 | expr . '-' expr
9 | expr . '*' expr
10 | expr . '/' expr
11 | expr . '^' expr
11 | expr '^' expr .
'+' shift, and go to state 13
'-' shift, and go to state 14
'*' shift, and go to state 15
'/' shift, and go to state 16
'^' shift, and go to state 17
'+' [reduce using rule 11 (expr)]
'-' [reduce using rule 11 (expr)]
'*' [reduce using rule 11 (expr)]
'/' [reduce using rule 11 (expr)]
'^' [reduce using rule 11 (expr)]
$default reduce using rule 11 (expr)
I'm pretty new to using bison so any help on this would be appreciated, thanks in advance