當我運行野牛-d myfile.y它提供了以下錯誤:野牛:M4:無效的參數。我認爲這個問題是運營商的優先,但我仍然無法解決問題。 使*函數創建命題邏輯表達式。解析器命題邏輯
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()
}
這在我的機器上正常工作。你在哪個平臺上使用野牛,以及哪個版本的野牛? – Gian
@Gian謝謝你的回覆;我在Windows Vista上運行bison 2.4.1。你能把我生成的代碼發給我嗎? – saadtaame