开发者

Why does Flex say this is an "unrecognized rule"?

开发者 https://www.devze.com 2023-01-06 21:17 出处:网络
In the following: space([ \\t\\f\\r])+ opt_space([ \\t\\f\\r])* cpp^{opt_space}#{opt_space} word[A-Za-z_][A-Za-z_0-9]*

In the following:

space           ([ \t\f\r])+         
opt_space       ([ \t\f\r])*         
cpp             ^{opt_space}#{opt_space} 
word            [A-Za-z_][A-Za-z_0-9]*
arg_macro       {cpp}define{space}{word}
/*arg_macro       ^{opt_space}#{opt_space}define{space}{word}*/

%%
{arg_macro}     ;
%%

I get an error message

test.l:9: unrecognized rule

If I uncomment the second version of arg_macro开发者_C百科 and comment the first one, the error message goes away.

Any ideas why?


If you remove the ^ from the cpp definition, and place it in the arg_macro definition, then it's happy.

space           ([ \t\f\r])+
opt_space       ([ \t\f\r])*
cpp             {opt_space}#{opt_space}
word            [A-Za-z_][A-Za-z_0-9]*
arg_macro       ^{cpp}define{space}{word}
0

精彩评论

暂无评论...
验证码 换一张
取 消