Running Bison on this file:
%{
#include <iostream>
int yylex();
void yyerror(const char*);
%}
%union
{
char name[100];
int val;
}
%token NUM ID
%right '='
%left '+' '-'
%left '*'
%%
exp : NUM {$$.val = $1.val;}
| ID {$$.val = vars[$1.name];}
| exp '+' exp {$$.val = $1.val + $3.val;}
| ID '=' exp {$$.val = vars[$1.name] = $3.val;}
;
%%
Leads to warnings of the kind of:
warning: $$ of 'exp' has no declared type.
What does it mean and how do I solve it?
bison error has no declared type
– INS%union { int intValue; int floatValue; }
but it does not allow me to use$$.intValue
or$1.intValue
. It sayserror: request for member ‘floatValue’ in something not a structure or union
. Why so? – Shashwat