bison calculator problem
开发者_开发问答stmt : expr {printf("%d\n",$1);}
;
expr : expr '+' expr {$$ = $1 + $3;}
| expr '-' expr {$$ = $1 - $3;}
| INTEGER {$$ = $1;}
;
When is the stmt non terminal being executed by bison. When it sees which character ?
Assuming, these are all the rules from your bison input, the nonterminal symbol stmt
gets "executed" as soon as EOF
is reached (i.e.: no further input and the last expr
has been reduced).
However, there are conflicts in your grammar.
精彩评论