see the following code for yacc. if i remove the production factor : '!' expr, the parsing conflict disappears. what is happening here?
%{
#include <stdio.h>
#include <ctype.h>
%}
%token TRUE
%token FALSE
%%
line : line expr '\n' { printf("%d\n", $2); }
| line '\n'
|
;
expr : expr "or" term { printf("expr : expr or term\n"); $$ = $1 | $3; }
| term { printf("expr : term\n"); }
;
term : term "and" factor { printf("term : term and factor\n"); $$ = $1 & $3; }
| factor { printf("term : factor\n"); }
;
factor : '(' expr ')' { printf("factor : (expr)\n"); $$ = $2; }
| '!' expr { printf("factor : !expr\n"); $$ = !$2; }
| TRUE { printf("factor : TRUE\n"); }
| FALSE { printf("factor : FALSE\n"); }
;
%%
#include "lex.yy.c"
int main(int argc, char** argv)
{
while (yyparse() == 0) {
}
return 0;
}