When I run bison -d myfile.y it gives the following error: bison: m4: Invalid argument. I think the problem is operator precedence but still I can’t resolve the problem. The Make* functions create propositional logic expressions.
yacc file:
%{
#include "global.h"
#include "PLResolution.h"
%}
%token END
%token LEFT_PAREN RIGHT_PAREN
%token BICOND
%token FORWARD_IMPLIC BACKWARD_IMPLIC
%token OR
%token AND
%token NOT
%token identifier
%left BICOND
%left BACKWARD_IMPLIC
%left FORWARD_IMPLIC
%left OR
%left AND
%left NOT
%start Input
%%
Input:
/* Empty */
| Input Line
;
Line:
END
| Sentence END
;
Sentence:
AtomicSentence
| ComplexSentence
;
AtomicSentence:
identifier {$$=MakeAtomicSentence($1);}
;
ComplexSentence:
LEFT_PAREN Sentence RIGHT_PAREN
| NOT Sentence {$$=MakeNotSentence($1);}
| Sentence AND Sentence {$$=MakeAndSentence($1, $2);}
| Sentence OR Sentence {$$=MakeOrSentence($1, $2);}
| Sentence FORWARD_IMPLIC Sentence {$$=MakeForwardIMPLIC($1, $2);}
| Sentence BACKWARD_IMPLIC Sentence {$$=MakeBackwardIMPLIC($1, $2);}
| Sentence BICOND Sentence {$$=MakeBICOND($1, $2);}
;
%%
int yyerror(char *s) {
printf("%s\n",s);
}
int main(void) {
yyparse()
}
The generated code on my platform is unlikely to work for you. However, I found this link which describes similar problems other people have had on Vista with bison and m4. Perhaps the suggested fix will work for you too? It seems to involve copying the m4 binary to the local directory.
EDIT: and just in case you don’t get it to work, I’ve uploaded the two generated files for you: prop.tab.cc prop.tab.hh. Not sure if they will work at all, but maybe it’ll help.