我有两个词法分析器 - shell.l和javascript.l,分别带有前缀(%选项前缀)shell和javascript(shell.l和%选项前缀中的%option prefix =“shell” =“javascript”在javascript.l中)。使用flex编译多个词法分析器给出了重定义错误
我打电话从另一个文件中的词法分析器(main_file.c)依次为:
somefunc(){
.....
shelllex();
......
javascriptlex();
}
为了调用这些,我已经包含了这两个词法分析器的main_file.c头文件为:
#include <.....>
#include "lex.shell.h"
#include "lex.javascript.h"
而且,我创建这些头时,我编译柔性的文件为:
flex --header-file=lex.shell.h shell.l
flex --header-file=lex.javascript.h javascript.l
gcc -o lang lex.shell.c lex.javascript.c main_file.c -lfl
瓦恩我编译main_file.c,我得到redefiniton如下错误:16:
在文件从code_detector.c包括0:
lex.javascript.h:227:29: error: redefinition of ‘yy_nxt’
static yyconst flex_int16_t yy_nxt[][128] =
^
In file included from code_detector.c:15:0:
lex.shell.h:227:29: note: previous definition of ‘yy_nxt’ was here
static yyconst flex_int16_t yy_nxt[][128] =
我已经通过其他几个SO帖子了,但是没找到很多帮助。 我将不胜感激在解决这些问题上的任何帮助!
谢谢!
您使用的是什么版本的flex? – rici
我们使用2.5.35 –