[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
3.1.1 The prologue
The Prologue section contains macro definitions and declarations
of functions and variables that are used in the actions in the grammar
rules. These are copied to the beginning of the parser file so that
they precede the definition of yyparse
. You can use
‘#include’ to get the declarations from a header file. If you
don't need any C declarations, you may omit the ‘%{’ and
‘%}’ delimiters that bracket this section.
The Prologue section is terminated by the the first occurrence of ‘%}’ that is outside a comment, a string literal, or a character constant.
You may have more than one Prologue section, intermixed with the
Bison declarations. This allows you to have C and Bison
declarations that refer to each other. For example, the %union
declaration may use types defined in a header file, and you may wish to
prototype functions that take arguments of type YYSTYPE
. This
can be done with two Prologue blocks, one before and one after the
%union
declaration.
%{
#include <stdio.h>
#include "ptypes.h"
%}
%union {
long int n;
tree t; /* |