Next: , Previous: , Up: Bison Declarations   [Contents][Index]

3.7.4 Nonterminal Symbols

When you use %union to specify multiple value types, you must declare the value type of each nonterminal symbol for which values are used. This is done with a %type declaration, like this:

%type <type> nonterminal

Here nonterminal is the name of a nonterminal symbol, and type is the name given in the %union to the alternative that you want (see The Union Declaration). You can give any number of nonterminal symbols in the same %type declaration, if they have the same value type. Use spaces to separate the symbol names.

While POSIX Yacc allows %type only for nonterminals, Bison accepts that this directive be also applied to terminal symbols. To declare exclusively nonterminal symbols, use the safer %nterm:

%nterm <type> nonterminal