Next: C++ Location Values, Previous: C++ Bison Interface, Up: C++ Parsers
The %union directive works as for C, see The Collection of Value Types. In particular it produces a genuine
union1, which have a few specific features in C++.
YYSTYPE is defined but its use is discouraged: rather
you should refer to the parser's encapsulated type
yy::parser::semantic_type.
Because objects have to be stored via pointers, memory is not
reclaimed automatically: using the %destructor directive is the
only means to avoid leaks. See Freeing Discarded Symbols.
[1] In the future techniques to allow complex types within pseudo-unions (similar to Boost variants) might be implemented to alleviate these issues.