我收到错误消息说 '%yacc' 和 '%define api.value.type "union"' 不能一起使用

I got error saying '%yacc' and '%define api.value.type "union"' cannot be used together

我正在创建一个简单的编译器,我需要生成一个 Symantec 值类型,我已经检查过 link,我需要在我的 parser.y 文件中添加这一行:

%define api.value.type union

通知 bison %token 和 %type 指令使用的标签是真正的类型。

但我遇到了那个奇怪的错误:

parser.y: error: '%yacc' and '%define api.value.type "union"' cannot be used together

我不明白“%yacc”变量是什么以及为什么会出现该错误,据我所知,'%define api.value.type "union"' 我可以在解析器正常,但我找不到有关该错误的任何信息或资源。

this page of the documentation, bison includes a yacc front end that runs bison -y. The -y option forces various yacc-compatibility settings as described here 所述。

因此,解决方案是 运行 bison 而不是 yacc