bison c++:在 ‘*’ 之前预期初始化程序错误代币
我在 C++ 上使用 flex 和 bison,但现在我很挣扎。
g++ 抛出的错误是:
src/bison.tab.h:125: error: expected initializer before ‘*’ token
bison.tab.h 是 bison yacc 解析器自动生成的文件,给我错误的行是
bison.tab.h:125: extern YYSTYPE yylval;
My bison.y
void yyerror(const char* error);
#include "objects/tabla.h"
#include "Node.h"
#define YYSTYPE Node*
#include "bison.tab.h"
#include "lex.yy.c"
using namespace std;
void yyerror(const char* error) {cout<<"*** "<<error<<endl; };
Node* root;
%}
%nonassoc vacio
%tokens
%start start
%%
Grammar....
%%
main()
{
yyparse();
}
我不知道这是否是我看不到的问题...
干杯,
I'm using flex and bison on C++ bur now I struggled.
The error that g++ throws is:
src/bison.tab.h:125: error: expected initializer before ‘*’ token
bison.tab.h is an auto generated file from bison yacc parser, the line that give me the error is
bison.tab.h:125: extern YYSTYPE yylval;
My bison.y
void yyerror(const char* error);
#include "objects/tabla.h"
#include "Node.h"
#define YYSTYPE Node*
#include "bison.tab.h"
#include "lex.yy.c"
using namespace std;
void yyerror(const char* error) {cout<<"*** "<<error<<endl; };
Node* root;
%}
%nonassoc vacio
%tokens
%start start
%%
Grammar....
%%
main()
{
yyparse();
}
I don't know if here is the problem that i can't see...
Cheers,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
#define YYSTYPE Node*
我认为这一行会导致问题,如果你最好使用
%union
来自定义节点类型,例如#define YYSTYPE Node*
I think this line leads to the problem, and if you'd better use
%union
to customize node type, like