Why do we use pointers for complex classes when defining union in parser file?
<p>I'm working on a parser for <a href="http://users.cecs.anu.edu.au/~ssanner/IPPC_2011/RDDL.pdf" rel="nofollow">RDDL</a> and, as I've done it before, when I define union which contains types I use, I use pointers. E.g.</p>

<pre><code>%union {
    double d;
    int i;
    std::string *str;
    std::vector&lt;std::string&gt; *vectorStr;

    RDDLBlock *rddlBlock;
    Domain *domain;
    DefineType *defineType;
    std::vector&lt;DefineType*&gt; *vectorDefineType;
    DomainList *domainList;
    std::vector&lt;PvarDefinition*&gt; *vectorPvarDefinition;
    PvarDefinition *pVarDefinition;
    CpfDefinition *cpfDefinition;
    std::vector&lt;CpfDefinition*&gt; *vectorCpfDefinition;
    PvarExpression *pVarExpression;
    LogicalExpression *logicalExpression;
    std::vector&lt;LogicalExpression*&gt; *vectorLogicalExpression;
    LConstCaseList *lConstCaseList;
    CaseDefine *caseDefine;
    std::vector&lt;CaseDefine*&gt; *vectorCaseList;
    Parameter *parameter;
    ParameterList *parameterList;

    ObjectDefine *objectDefine;
    std::vector&lt;ObjectDefine*&gt; *objectsList;
    PvariablesInstanceDefine* pvariablesInstanceDefine;
    std::vector&lt;PvariablesInstanceDefine*&gt; *pvariablesInstanceList;

    Instance *instance;
    NonFluentBlock *nonFluentBlock;
}
</code></pre>

<p>This is the way I saw most people implement multiple token types in parsers. While searching for this answer on the web, all I saw are the examples and no explanation on why we have to use pointers. One of my tasks now is to 'clean pointers' where ever that is possible. So my question is, why do we (have to) use pointers in unions in this case?</p>

<p><strong>EDIT</strong>: Added full list of types defined in union.</p>