doc: formatting changes

* doc/bison.texi: No output changes.
This commit is contained in:
Akim Demaille
2019-12-13 18:20:41 +01:00
parent 7f01adced9
commit 0d73c39bb7

View File

@@ -10014,57 +10014,56 @@ always possible.
@findex YYFPRINTF @findex YYFPRINTF
The trace facility outputs messages with macro calls of the form The trace facility outputs messages with macro calls of the form
@code{YYFPRINTF (stderr, @var{format}, @var{args})} where @code{YYFPRINTF (stderr, @var{format}, @var{args})} where @var{format} and
@var{format} and @var{args} are the usual @code{printf} format and variadic @var{args} are the usual @code{printf} format and variadic arguments. If
arguments. If you define @code{YYDEBUG} to a nonzero value but do not you define @code{YYDEBUG} to a nonzero value but do not define
define @code{YYFPRINTF}, @code{<stdio.h>} is automatically included @code{YYFPRINTF}, @code{<stdio.h>} is automatically included and
and @code{YYFPRINTF} is defined to @code{fprintf}. @code{YYFPRINTF} is defined to @code{fprintf}.
Once you have compiled the program with trace facilities, the way to Once you have compiled the program with trace facilities, the way to request
request a trace is to store a nonzero value in the variable @code{yydebug}. a trace is to store a nonzero value in the variable @code{yydebug}. You can
You can do this by making the C code do it (in @code{main}, perhaps), or do this by making the C code do it (in @code{main}, perhaps), or you can
you can alter the value with a C debugger. alter the value with a C debugger.
Each step taken by the parser when @code{yydebug} is nonzero produces a Each step taken by the parser when @code{yydebug} is nonzero produces a line
line or two of trace information, written on @code{stderr}. The trace or two of trace information, written on @code{stderr}. The trace messages
messages tell you these things: tell you these things:
@itemize @bullet @itemize @bullet
@item @item
Each time the parser calls @code{yylex}, what kind of token was read. Each time the parser calls @code{yylex}, what kind of token was read.
@item @item
Each time a token is shifted, the depth and complete contents of the Each time a token is shifted, the depth and complete contents of the state
state stack (@pxref{Parser States}). stack (@pxref{Parser States}).
@item @item
Each time a rule is reduced, which rule it is, and the complete contents Each time a rule is reduced, which rule it is, and the complete contents of
of the state stack afterward. the state stack afterward.
@end itemize @end itemize
To make sense of this information, it helps to refer to the automaton To make sense of this information, it helps to refer to the automaton
description file (@pxref{Understanding, ,Understanding Your Parser}). description file (@pxref{Understanding, ,Understanding Your Parser}). This
This file shows the meaning of each state in terms of file shows the meaning of each state in terms of positions in various rules,
positions in various rules, and also what each state will do with each and also what each state will do with each possible input token. As you
possible input token. As you read the successive trace messages, you read the successive trace messages, you can see that the parser is
can see that the parser is functioning according to its specification in functioning according to its specification in the listing file. Eventually
the listing file. Eventually you will arrive at the place where you will arrive at the place where something undesirable happens, and you
something undesirable happens, and you will see which parts of the will see which parts of the grammar are to blame.
grammar are to blame.
The parser implementation file is a C/C++/Java program and you can use The parser implementation file is a C/C++/Java program and you can use
debuggers on it, but it's not easy to interpret what it is doing. The debuggers on it, but it's not easy to interpret what it is doing. The
parser function is a finite-state machine interpreter, and aside from parser function is a finite-state machine interpreter, and aside from the
the actions it executes the same code over and over. Only the values actions it executes the same code over and over. Only the values of
of variables show where in the grammar it is working. variables show where in the grammar it is working.
@node Mfcalc Traces @node Mfcalc Traces
@subsection Enabling Debug Traces for @code{mfcalc} @subsection Enabling Debug Traces for @code{mfcalc}
The debugging information normally gives the token type of each token read, The debugging information normally gives the token type of each token read,
but not its semantic value. The @code{%printer} directive allows specify but not its semantic value. The @code{%printer} directive allows specify
how semantic values are reported, see @ref{Printer Decl, , Printing how semantic values are reported, see @ref{Printer Decl, , Printing Semantic
Semantic Values}. Values}.
As a demonstration of @code{%printer}, consider the multi-function As a demonstration of @code{%printer}, consider the multi-function
calculator, @code{mfcalc} (@pxref{Multi-function Calc}). To enable run-time calculator, @code{mfcalc} (@pxref{Multi-function Calc}). To enable run-time