I write grammar in YACC (actually Bison) and I have a shift / reduction problem. This is the result of including increment and postfix reduction operators. Here is a stripped down version of the grammar:
%token NUMBER ID INC DEC %left '+' '-' %left '*' '/' %right PREINC %left POSTINC %% expr: NUMBER | ID | expr '+' expr | expr '-' expr | expr '*' expr | expr '/' expr | INC expr %prec PREINC | DEC expr %prec PREINC | expr INC %prec POSTINC | expr DEC %prec POSTINC | '(' expr ')' ; %%
Bison tells me that there are 12 shift / decrease conflicts, but if I comment out the lines for incrementing and decreasing the postfix, it works fine. Does anyone know how to fix this conflict? Right now I'm considering moving to the LL (k) parser generator, which makes it a lot easier, but LALR grammars always seemed a lot more natural to write. I also consider GLR, but I don't know any good C / C ++ GLR parser generators.
parsing bison yacc lalr shift-reduce-conflict
Zifre
source share