[英]bison error: rule given for Semi, which is a token?
我的野牛語法遇到了錯誤:
解析器.yy:
%union {
Ast *ast;
char *str;
int tok;
}
%token <tok> NEWLINE SEMICOLON
%type <ast> Semi
%%
Semi: NEWLINE { $$ = new Ast($1); }
| SEMICOLON { $$ = new Ast($1); }
;
Statements: Statement
| Statement Semi Statements
;
Statement: ...
;
%%
它給出了錯誤信息:
Parser.yy:xxx.x-x: error: rule given for Semi, which is a token
有沒有辦法實現這個?
或者我必須這樣寫:?
Statements: Statement
| Statement NEWLINE Statements
| Statement SEMICOLON Statements
;
Semi是一種代幣。 它不需要定義規則即可返回。 就用它吧。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.