> Le 18 févr. 2019 à 04:37, Peng Yu <pengyu...@gmail.com> 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" _______________________________________________ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison