Don't confuse bison's %union
directive with the C/C++ syntax.
In the code generated by bison, there will be a C/C++ union
, whose body is copied from the %union
directive, but it is certainly not anonymous: its name is YYSTYPE
. However, you hardly ever need to know that, since the only exposed variable with that type is yylval
. (The internal bison stack is also composed of elements of type YYSTYPE
but it is not exposed to user code.)
There are various other possible ways to define YYSTYPE
, as described by the bison manual. For example, you can create your own C/C++ union
(or struct
) type, as described here. However, these advanced bison
features are rarely required.