开发者

warning Bison compilation

am developping a compiler using flex/bison. I have this warning in my build output.

warning: type c开发者_开发问答lash ('s' '') on default action

any help please?


It seems to be related to your %token and %type declaration in your source. without the source line and the related token and type declaration it is difficult to help you.

If you specify an expr of type val and definer an ID token of type tptr

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

If you write without any action bison will emit a warning

expr : ID;

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

Note that the bison level I am currently using print a slighty different message in this case.

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

To fix this warning you need an explicit action:

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

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


Use the union definition to type your given tokens from lex.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜