Multiple Types
Previous: <Value Type=>ValueType> * Next: <Actions=>Actions> * Up: <Semantics=>Semantics>

#Wrap on
{fH4}More Than One Value Type{f}

In most programs, you will need different data types for different kinds
of tokens and groupings.  For example, a numeric constant may need type
{fCode}int{f} or {fCode}long{f}, while a string constant needs type {fCode}char \*{f},
and an identifier might need a pointer to an entry in the symbol table.

To use more than one data type for semantic values in one parser, Bison
requires you to do two things:

#Indent +4

  Specify the entire collection of possible data types, with the
{fCode}%union{f} Bison declaration (\*Note <Union Decl=>UnionDecl>: The Collection of Value Types).


  Choose one of those types for each symbol (terminal or nonterminal)
for which semantic values are used.  This is done for tokens with the
{fCode}%token{f} Bison declaration (\*Note <Token Decl=>TokenDecl>: Token Type Names) and for groupings
with the {fCode}%type{f} Bison declaration (\*Note <Type Decl=>TypeDecl>: Nonterminal Symbols).

#Indent

