为什么我在我的 Lexer 程序中收到此警告“规则无法匹配”

问题描述 投票:0回答:1

我在弹性程序“.l”中有这段代码

"if" {return IF;} "else" {return ELSE;} "For" {return FOR;} . {printf("SYNTAX ERROR .. EXIT ..");exit(0);}

以及 bison 程序“.y”中的代码

%token IF ELSE FOR

但我得到了

的错误

warning, rule cannot be matched warning, rule cannot be matched warning, rule cannot be matched

bison flex-lexer lex
1个回答
0
投票

我发现问题了 我需要像这样在一行上编写代码

"if" { return IF; }
不是这样的
"if" { return IF; } 

© www.soinside.com 2019 - 2024. All rights reserved.