Hi,
I have a grammar with some conflicts between the return statement and
the declaration (due to missing semicolons). I thought I could resolve
this issue by giving the primary-production in expr a context-dependent
precedence, but it had no effect on the conflicts. I still have a
conflict for the FOO and the BAR token. Can somebody explain to me why?
Cheers,
Matthias
This is the grammar:
%token ID
%token FOO
%token BAR
%token RETURN
/* resolve RETURN-primary conflict as shift */
%nonassoc RETURN
%nonassoc ID
%left '+'
%left '*'
%%
stmts
: stmt
| stmts stmt
;
stmt
: RETURN
| RETURN expr /* conflict */
| primary /* conflict */
;
primary
: ID
| FOO
| BAR
;
expr
: primary %prec ID /* give tokens of primary the precedence of ID */
| expr '+' expr
| expr '*' expr
;
%%
_______________________________________________
help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison