官方网站与文档(sourceforge我在使用的时候常常遇到没法访问的状况,本身想办法吧,你懂)html
flex:http://flex.sourceforge.net/node
bison:http://www.gnu.org/software/bison/flex
文档:https://www.gnu.org/software/bison/manual/html_node/index.html网站
我目前正在使用的版本分别为:flex 2.5.3七、bison 3.0.2,均为 yum 安装ui
调试参数spa
经过 --help 能够看到,flex 调试开关 -d,bison 调试开关为 -t,生成代码时加入这两个参数便可。
.net
手动调整 bison 代码,光有开关是不够的,打开 gram.c,能够看到不少宏定义里边都有:“if (yydebug)”,搜索 "int yydebug;" 定义改成:“int yydebug = 1;”;还有一个办法是在其余文件中启动语法引擎前设置 yydebug 非零。debug
参见章节:https://www.gnu.org/software/bison/manual/html_node/Tracing.html调试
scan.c的错误修复,在我使用的版本中没法编译文件,错误:
In file included from gram.y:14877:0: scan.c: In function ‘core_yylex’: scan.c:9263:47: error: macro "fprintf" requires 3 arguments, but only 2 given fprintf( stderr, "--scanner backing up\n" ); ^ scan.c:9263:5: warning: statement with no effect [-Wunused-value] fprintf( stderr, "--scanner backing up\n" ); ^ scan.c:9266:52: error: macro "fprintf" passed 4 arguments, but takes just 3 (long)yy_rule_linenum[yy_act], yytext ); ^ scan.c:9265:5: warning: statement with no effect [-Wunused-value] fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", ^ ...
打开 scan.c发现宏定义:
#undef fprintf #define fprintf(file, fmt, msg) fprintf_to_ereport(fmt, msg) static void fprintf_to_ereport(const char *fmt, const char *msg) { ereport(ERROR, (errmsg_internal("%s", msg))); }
与其下 fprintf 的用法冲突,注释掉这几行便可