
152 Compilers – Principles and Practice
char s; /* symbol table index */
Node *np; /* node pointer */
};
This results in the following code being included in the yacc output header file y.tab.h:
typedef union {
int i; /* integer value */
float f; /* float value */
char s; /* symbol table index */
Node *np; /* node pointer */
} YYSTYPE;
extern YYSTYPE yylval;
The type of semantic value for each type of term in the grammar is defined at the beginning of the
yacc input file as:
%token <i> INTEGER
%type <f> expr
This binds expr to f, and INTEGER to i in the YYSTYPE union. With this binding, yacc
automatically generates a correct ...