我已将 YYSTYPE 联合声明为
%union
{
        char* stringValue;
        union int_double_string* ids;
}
int_double_string被声明为
union int_double_string
{
        short type;     //0:int 1:double 2:string
        int intValue;
        double doubleValue;
        char* stringValue;
};
一些代币
%token <stringValue> KEY
%token <int_double_string> VALUE
%token <stringValue> COMMENT    
%type <stringValue> pair
%type <int_double_string> key_expr
但是无论我在哪里使用 token VALUE,它都会给我这个常见的错误。
‘YYSTYPE’ has no member named ‘int_double_string’
pair:
        KEY ws '=' ws VALUE     {
                char S5[15];
                addPair($1, $5);   //Error here and where-ever I use $5 in this function
                ...
为什么会这样,尽管我已经正确地声明了它?我也在我的 lex 文件中使用了这个变量。它在那里没有显示错误。
文件
{integer}       {
                yylval.ids = malloc(sizeof(union int_double_string));
                yylval.ids->type = 0;
                yylval.ids->intValue = atoi(yytext);
                return VALUE;
        }
我认为这与工会内部的工会概念有关。
该怎么办?