Next: , Previous: , Up: D Parsers   [Contents][Index]


10.2.2 D Semantic Values

Semantic types are handled by %union and ‘%define api.value.type union’, similar to C/C++ parsers. In the latter case, the union of the values is handled by the backend. In D, unions can hold classes, structs, etc., so this directive is more similar to ‘%define api.value.type variant’ from C++.

D parsers do not support %destructor, since the language adopts garbage collection. The parser will try to hold references to semantic values for as little time as needed.

D parsers support %printer. An example for the output of type int, where yyo is the parser’s debug output:

%printer { yyo.write($$); } <int>