DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(bison.info) Multiple Types

Info Catalog (bison.info) Value Type (bison.info) Semantics (bison.info) Actions
 
 More Than One Value Type
 ------------------------
 
    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:
 
    * Specify the entire collection of possible data types, with the
      `%union' Bison declaration ( The Collection of Value Types
      Union Decl.).
 
    * Choose one of those types for each symbol (terminal or nonterminal)
      for which semantic values are used.  This is done for tokens with
DONTPRINTYET       the `%token' Bison declaration ( Token Type Names Token
      Decl.) and for groupings with the `%type' Bison declaration (*note
DONTPRINTYET       the `%token' Bison declaration ( Token Type Names Token
      Decl.) and for groupings with the `%type' Bison declaration (

      Nonterminal Symbols Type Decl.).
 
Info Catalog (bison.info) Value Type (bison.info) Semantics (bison.info) Actions
automatically generated byinfo2html