Reputation: 418
So, I'm having problems with my parser.y with a compiler that I'm building. The error is saying I don't have a member inside of a union or structure, which it is. Here is the error code I've received:
parser.y:123: error: request for member ‘funcName’ in something not a structure or union
Then with the code that is inside my parser.y file:
%union {
int val;
char *funcName;
}
%token <funcName> ID
And here is where I'm trying to use the union in my parser.y file:
f_def: FUNCTION ID '(' arg_list ')' ':' type '{' stat_list '}'
{create_function_info_item(&headFunctionInfo, func_arg_list_count(), $2.funcName);}
Upvotes: 0
Views: 172
Reputation: 370377
The tokens have the type of whichever union member you assigned to them with the %token
declaration - not the union type itself. So $2
has type char*
and you don't need the .funcName
- it already holds the value of the funcName
member.
Upvotes: 1