gpt4 book ai didi

c++ - C++ 子类上的 Bison 类型冲突

转载 作者:行者123 更新时间:2023-11-30 03:00:51 24 4
gpt4 key购买 nike

所以我在 bison 中遇到类型冲突,形式为

warning: type clash on default action: <stmt> != <expr>

因为我有这样的作品

%type <stmt> Stmt
%type <expr> Expr
...
Stmt : Expr /* empty */
| Otherstuff {do other stuff.....}
;

我想知道是否有办法消除这些错误,因为 Expr 是 Stmt 的子类(我使用的是 C++),但有额外的功能,所以只需放入

%type <stmt> Stmt Expr

不会工作。有什么想法吗?

最佳答案

简单的方法是:

Stmt : Expr         {$$ =  $1;} // This is the same as default action

关于c++ - C++ 子类上的 Bison 类型冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11641818/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com