Bison 野牛:yypstate和YYPUSH_的定义在哪里?

Bison 野牛:yypstate和YYPUSH_的定义在哪里?,bison,flex-lexer,Bison,Flex Lexer,我正在使用flex和bison开发一个计算器。但当我想让它成为一个推式解析器时,我得到了以下结果: "flex" lexer.l gcc -c -o lex.yy.o lex.yy.c lexer.l: In function 'main': lexer.l:29:2: error: unknown type name 'yypstate' lexer.l:29:15: warning: initialization makes pointer from integer w

我正在使用flex和bison开发一个计算器。但当我想让它成为一个推式解析器时,我得到了以下结果:

"flex" lexer.l  
gcc    -c -o lex.yy.o lex.yy.c  
lexer.l: In function 'main':  
lexer.l:29:2: error: unknown type name 'yypstate'  
lexer.l:29:15: warning: initialization makes pointer from integer without a cast [enabled by default]  
lexer.l:35:24: error: 'YYPUSH_MORE' undeclared (first use in this function)  
lexer.l:35:24: note: each undeclared identifier is reported only once for each function it appears in  
make: *** [lex.yy.o] Error 1  
代码可从(tag
u1 push parse
)获取。我不会把它贴在这里,因为我觉得它很烦人


PS:对不起,我的英语很好。希望你能理解

如果要创建推送解析器,需要指定

%define api.pure full
%define api.push-pull push
在bison(.y)文件中。(实际上,您只需要第二个,但强烈推荐第一个。请参阅。)

如果您请求了一个头文件,那么应该将这些符号放入bison生成的头文件中。要请求头文件,请包括

%defines
或者使用
-d
标志调用bison

当然,您需要在引用符号的任何源文件中包含该头文件;在您的情况下,您的
flex
输入文件


另外,确保
Makefile
指定
bison
头文件取决于
bison
步骤,并且
flex
步骤取决于
bison
头文件。否则,您可能会发现构建的顺序是错误的。

我不认为这是因为上述问题之一。你检查过我的代码吗?@user1528601我没有检查,因为没有名为variable的分支。然而,我只是看了一下名为push-parse的分支,除了我不得不删除的yywrap宏之外,它对我来说编译得还行。(如果不需要yywrap,请使用
%option noyywrap
)所以我不知道为什么它不适合您,除了Makefile中可能存在不好的依赖项之外。@user1528601,哦,您的操作缺少分号。它们必须是有效的C.Oh。谢谢你的更正。你是手工编写代码的吗?@user1528601我是手工编写的。首先是野牛,然后是flex,然后是gcc。