Bison throws this
error: $2 of ‘exp’ has no declared type
but I believe I've declared everything.
FLEX:
[0-9]+ {
yylval.string =yytext; //yes I want ints as strings.
return INT;
}
"*" {yylval.string=yytext; return MUL;}
"/" {yylval.string=yytext; return DIV;}
"-" {yylval.string=yytext; return MINUS;}
"+" {yylval.string=yytext; return PLUS;}
"^" {yylval.string=yytext; return POW;}
BISON:
%union {
char * string;
}
%token <string> INT DEC STRING PLUS MINUS MUL DIV POW
%type <string> OP
.
.
.
exp: type {foo(x,$1);}
|exp
OP {foo(x,$2);}
exp;
OP: PLUS | MINUS| MUL| DIV| POW ;
.
.
.
There is a lot more code but this is the part where the error occurs. When I create a rule for every operator I get no error but I get other problems because of the recursion so I believe I need to do it this way.
.y
file that you can actually run through bison and generate the error. – Chris Dodd