I'm new to using bison and am trying to modify an interpreter that uses a bison input file. I keep getting a type clash warning. I think it is because the expression and case_statement don't have a value, but I'm not sure how to fix it.
This is the warning.
parser.y:97.9-59: warning: type clash on default action: <value> != <> [-Wother]
97 | IF expression THEN statement_ ELSE statement_ ENDIF |
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parser.y:98.9-30: warning: type clash on default action: <value> != <> [-Wother]
98 | case_statement ENDCASE ;
And here is the code that is the problem
%union
{
CharPtr iden;
Operators oper;
int value;
}
%token <iden> IDENTIFIER
%token <value> INT_LITERAL REAL_LITERAL BOOL_LITERAL
%token <oper> ADDOP MULOP RELOP REMOP EXPOP
%token ANDOP
%token BEGIN_ BOOLEAN END ENDREDUCE FUNCTION INTEGER IS REDUCE RETURNS
%token ARROW OROP NOTOP CASE ELSE ENDCASE ENDIF IF REAL
%token OTHERS THEN WHEN
%type <value> body statement_ statement reductions expression relation term factor primary
power conjunction
%type <oper> operator
%%
statement_:
statement ';' |
error ';' {$$ = 0;} ;
statement:
expression |
REDUCE operator reductions ENDREDUCE {$$ = $3;} |
IF expression THEN statement_ ELSE statement_ ENDIF |
case_statement ENDCASE ;
case:
WHEN INT_LITERAL ARROW statement_;
cases:
case cases_others;
case_statement:
CASE expression IS cases OTHERS ARROW statement_ ';' |
error ';' ;
cases_others:
case cases_others |
;