Bison is ignoring %prec for this simple grammar: %left PRIORITY2 %left PRIORITY1 %token NUMBER %%
program : expr { };
expr : expr '+' expr %prec PRIORITY2 { };
expr : expr '-' expr %prec PRIORITY2 { };
expr : expr '*' expr %prec PRIORITY1 { };
expr : expr '/' expr %prec PRIORITY1 { };
expr : NUMBER { };
%%
int yyerror(char *s) {
fprintf(stderr, "error, line %d: %s\n", yylineno, s);
return 0;
}
int main(int argc, char **argv) {
yyparse();
return 0;
}
#include "lex.yy.c"
I realize a work around is to not use %prec for this, but this is not
an option for my purposes because I am attempting to create the bison
grammar file automatically from a format where one specifies priority
with a number in the rules.
If this is not a bug, I would appreciate any help on how to make this work properly because from all the documentation I have read it seems it ought to.
Attached is debug version + the lex file for testing purposes. Thanks, Darren
bugreport.tgz
Description: GNU Zip compressed data
