In most programs, you will need different data types for different kinds
of tokens and groupings. For example, a numeric constant may need type
int
or long
, while a string constant needs type char *
,
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:
%union
Bison declaration (see section The Collection of Value Types).
%token
Bison declaration (see section Token Type Names) and for groupings
with the %type
Bison declaration (see section Nonterminal Symbols).
Go to the first, previous, next, last section, table of contents.