5
votes

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

warning: type clash ('s' '') on default action

any help please?

2
It's not a 'compilator', it's a 'compiler'.Mario Becerra

2 Answers

8
votes

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

0
votes

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