What is the exact meaning of the error: yacc: e - line 85 of "tac.y", a token appears on the lhs of a production
line 85:
T: INT { strcpy($$.type,"int"); }
|
REAL { strcpy($$.type,"real"); }
I have associated a attribute to T
%union{
struct attribute{
char name[20];
char type[20];
}attr;
}
%token <attr> ID
%token <attr> E
%token <attr> T
It means what it says: that you are attempting to provide a derivation for a token. Tokens come from the lexcal analysis, so they cannot have grammatical rules associated with them.
I guess you meant to declare the (semantic value) type of T
:
%type <attr> T
You probably need to change the declaration of E
too.
Avoiding this kind of confusion is one of the reasons it is common to use ALL_CAPS for terminals (tokens) and lower-case
for non-terminals.