gpt4 book ai didi

bison - 警告 Bison 编译

转载 作者:行者123 更新时间:2023-12-02 01:28:18 28 4
gpt4 key购买 nike

正在使用 flex/bison 开发编译器。我的构建输出中有此警告。

警告:在默认操作中键入冲突 ('s' '')

请问有什么帮助吗?

最佳答案

它似乎与源中的 %token 和 %type 声明有关。如果没有源代码行以及相关的标记和类型声明,就很难为您提供帮助。

如果您指定 val 类型的 expr 并定义 tptr 类型的 ID token

%{
#include "parser.h"
%}
%type <val> expr
%token <tptr> ID

如果你写的时候没有任何 Action , Bison 会发出警告

expr : ID;

warning: type clash ('tptr' 'val') on default action

请注意,在这种情况下,我当前使用的 Bison 级别打印的消息略有不同。

foo.by:10.12:warning: type clash on default action : <tptr> != <val>

要修复此警告,您需要采取明确的操作:

expr : ID { $$ = some_conversion_code($1); }

http://www.gnu.org/s/bison/manual/bison.html#Token-Decl

关于bison - 警告 Bison 编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7346293/

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