[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Not able to use %union?
From: |
Akim Demaille |
Subject: |
Re: Not able to use %union? |
Date: |
Mon, 18 Feb 2019 18:36:02 +0100 |
> Le 18 févr. 2019 à 04:37, Peng Yu <address@hidden> a écrit :
>
> Since %union cannot be used in this case, how to deal with this
> scenario in bison? Thanks.
You want to read the documentation of api.value.type.
For instance:
‘{TYPE}’
Use this TYPE as semantic value.
%code requires
{
struct my_value
{
enum
{
is_int, is_str
} kind;
union
{
int ival;
char *sval;
} u;
};
}
%define api.value.type {struct my_value}
%token <u.ival> INT "integer"
%token <u.sval> STR "string"