当我运行 bison -d myfile.y 时,它会出现以下错误: bison:m4:无效的参数。我认为问题是运营商优先,但我仍然无法解决问题。 Make * 函数创建命题逻辑表达式。
yacc文件:
%{
#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()
}
答案 0 :(得分:1)
我平台上生成的代码不太适合您。但是,我发现this link描述了其他人在Vista上使用野牛和m4时遇到的类似问题。也许建议的修复也适合你?它似乎涉及将m4二进制文件复制到本地目录。
编辑:如果你没有让它工作,我已经为你上传了两个生成的文件:prop.tab.cc prop.tab.hh。不确定它们是否会起作用,但也许它会有所帮助。