708 |
@code{<stddef.h>}, and @code{<stdlib.h>} are included as needed to |
@code{<stddef.h>}, and @code{<stdlib.h>} are included as needed to |
709 |
declare memory allocators and related types. In the same situation, |
declare memory allocators and related types. In the same situation, |
710 |
C++ parsers may include @code{<cstddef>} and @code{<cstdlib>} instead. |
C++ parsers may include @code{<cstddef>} and @code{<cstdlib>} instead. |
711 |
Other system headers may be included if you define @code{YYDEBUG} |
Other system headers may be included if you define @code{YYDEBUG} to a |
712 |
(@pxref{Debugging, ,Debugging Your Parser}). |
nonzero value (@pxref{Debugging, ,Debugging Your Parser}). |
713 |
|
|
714 |
@node Stages |
@node Stages |
715 |
@section Stages in Using Bison |
@section Stages in Using Bison |
3235 |
|
|
3236 |
@table @code |
@table @code |
3237 |
@item %debug |
@item %debug |
3238 |
Output a definition of the macro @code{YYDEBUG} into the parser file, so |
In the parser file, define the macro @code{YYDEBUG} to 1 if it is not |
3239 |
that the debugging facilities are compiled. @xref{Debugging, ,Debugging |
already defined, so that the debugging facilities are compiled. |
3240 |
Your Parser}. |
@xref{Debugging, ,Debugging Your Parser}. |
3241 |
|
|
3242 |
@item %defines |
@item %defines |
3243 |
Write an extra output file containing macro definitions for the token |
Write an extra output file containing macro definitions for the token |
4925 |
runs, the @code{yydebug} parser-trace feature can help you figure out why. |
runs, the @code{yydebug} parser-trace feature can help you figure out why. |
4926 |
|
|
4927 |
To enable compilation of trace facilities, you must define the macro |
To enable compilation of trace facilities, you must define the macro |
4928 |
@code{YYDEBUG} when you compile the parser. You could use |
@code{YYDEBUG} to a nonzero value when you compile the parser. You |
4929 |
@samp{-DYYDEBUG=1} as a compiler option or you could put @samp{#define |
could use @samp{-DYYDEBUG=1} as a compiler option or you could put |
4930 |
YYDEBUG 1} in the C declarations section of the grammar file |
@samp{#define YYDEBUG 1} in the C declarations section of the grammar |
4931 |
(@pxref{C Declarations, ,The C Declarations Section}). Alternatively, use the @samp{-t} option when |
file (@pxref{C Declarations, ,The C Declarations Section}). |
4932 |
you run Bison (@pxref{Invocation, ,Invoking Bison}). We always define @code{YYDEBUG} so that |
Alternatively, use the @samp{-t} option when you run Bison |
4933 |
debugging is always possible. |
(@pxref{Invocation, ,Invoking Bison}) or the @code{%debug} declaration |
4934 |
|
(@pxref{Decl Summary, ,Bison Declaration Summary}). We suggest that |
4935 |
|
you always define @code{YYDEBUG} so that debugging is always possible. |
4936 |
|
|
4937 |
The trace facility outputs messages with macro calls of the form |
The trace facility outputs messages with macro calls of the form |
4938 |
@code{YYFPRINTF (YYSTDERR, @var{format}, @var{args})} where |
@code{YYFPRINTF (YYSTDERR, @var{format}, @var{args})} where |
4939 |
@var{format} and @var{args} are the usual @code{printf} format and |
@var{format} and @var{args} are the usual @code{printf} format and |
4940 |
arguments. If you define @code{YYDEBUG} but do not define |
arguments. If you define @code{YYDEBUG} to a nonzero value but do not |
4941 |
@code{YYFPRINTF}, @code{<stdio.h>} is automatically included and the |
define @code{YYFPRINTF}, @code{<stdio.h>} is automatically included |
4942 |
macros are defined to @code{fprintf} and @code{stderr}. In the same |
and the macros are defined to @code{fprintf} and @code{stderr}. In |
4943 |
situation, C++ parsers include @code{<cstdio.h>} instead, and use |
the same situation, C++ parsers include @code{<cstdio.h>} instead, and |
4944 |
@code{std::fprintf} and @code{std::stderr}. |
use @code{std::fprintf} and @code{std::stderr}. |
4945 |
|
|
4946 |
Once you have compiled the program with trace facilities, the way to |
Once you have compiled the program with trace facilities, the way to |
4947 |
request a trace is to store a nonzero value in the variable @code{yydebug}. |
request a trace is to store a nonzero value in the variable @code{yydebug}. |
5102 |
|
|
5103 |
@item -t |
@item -t |
5104 |
@itemx --debug |
@itemx --debug |
5105 |
Output a definition of the macro @code{YYDEBUG} into the parser file, so |
In the parser file, define the macro @code{YYDEBUG} to 1 if it is not |
5106 |
that the debugging facilities are compiled. @xref{Debugging, ,Debugging |
already defined, so that the debugging facilities are compiled. |
5107 |
Your Parser}. |
@xref{Debugging, ,Debugging Your Parser}. |
5108 |
|
|
5109 |
@item --locations |
@item --locations |
5110 |
Pretend that @code{%locations} was specified. @xref{Decl Summary}. |
Pretend that @code{%locations} was specified. @xref{Decl Summary}. |