doc: formatting changes

* doc/bison.texi: here.
No change in content.
This commit is contained in:
Akim Demaille
2019-12-07 14:41:50 +01:00
parent 472531dc72
commit 5e71eef267

View File

@@ -367,9 +367,9 @@ Debugging Your Parser
Tracing Your Parser Tracing Your Parser
* Enabling Traces:: Activating run-time trace support * Enabling Traces:: Activating run-time trace support
* Mfcalc Traces:: Extending @code{mfcalc} to support traces * Mfcalc Traces:: Extending @code{mfcalc} to support traces
* The YYPRINT Macro:: Obsolete interface for semantic value reports * The YYPRINT Macro:: Obsolete interface for semantic value reports
Invoking Bison Invoking Bison
@@ -2897,25 +2897,25 @@ of line.
@cindex Prologue @cindex Prologue
@cindex declarations @cindex declarations
The @var{Prologue} section contains macro definitions and declarations The @var{Prologue} section contains macro definitions and declarations of
of functions and variables that are used in the actions in the grammar functions and variables that are used in the actions in the grammar rules.
rules. These are copied to the beginning of the parser implementation These are copied to the beginning of the parser implementation file so that
file so that they precede the definition of @code{yyparse}. You can they precede the definition of @code{yyparse}. You can use @samp{#include}
use @samp{#include} to get the declarations from a header file. If to get the declarations from a header file. If you don't need any C
you don't need any C declarations, you may omit the @samp{%@{} and declarations, you may omit the @samp{%@{} and @samp{%@}} delimiters that
@samp{%@}} delimiters that bracket this section. bracket this section.
The @var{Prologue} section is terminated by the first occurrence The @var{Prologue} section is terminated by the first occurrence of
of @samp{%@}} that is outside a comment, a string literal, or a @samp{%@}} that is outside a comment, a string literal, or a character
character constant. constant.
You may have more than one @var{Prologue} section, intermixed with the You may have more than one @var{Prologue} section, intermixed with the
@var{Bison declarations}. This allows you to have C and Bison @var{Bison declarations}. This allows you to have C and Bison declarations
declarations that refer to each other. For example, the @code{%union} that refer to each other. For example, the @code{%union} declaration may
declaration may use types defined in a header file, and you may wish to use types defined in a header file, and you may wish to prototype functions
prototype functions that take arguments of type @code{YYSTYPE}. This that take arguments of type @code{YYSTYPE}. This can be done with two
can be done with two @var{Prologue} blocks, one before and one after the @var{Prologue} blocks, one before and one after the @code{%union}
@code{%union} declaration. declaration.
@example @example
@group @group
@@ -2943,12 +2943,11 @@ can be done with two @var{Prologue} blocks, one before and one after the
@dots{} @dots{}
@end example @end example
When in doubt, it is usually safer to put prologue code before all When in doubt, it is usually safer to put prologue code before all Bison
Bison declarations, rather than after. For example, any definitions declarations, rather than after. For example, any definitions of feature
of feature test macros like @code{_GNU_SOURCE} or test macros like @code{_GNU_SOURCE} or @code{_POSIX_C_SOURCE} should appear
@code{_POSIX_C_SOURCE} should appear before all Bison declarations, as before all Bison declarations, as feature test macros can affect the
feature test macros can affect the behavior of Bison-generated behavior of Bison-generated @code{#include} directives.
@code{#include} directives.
@node Prologue Alternatives @node Prologue Alternatives
@subsection Prologue Alternatives @subsection Prologue Alternatives
@@ -2960,12 +2959,11 @@ feature test macros can affect the behavior of Bison-generated
@findex %code top @findex %code top
The functionality of @var{Prologue} sections can often be subtle and The functionality of @var{Prologue} sections can often be subtle and
inflexible. As an alternative, Bison provides a @code{%code} inflexible. As an alternative, Bison provides a @code{%code} directive with
directive with an explicit qualifier field, which identifies the an explicit qualifier field, which identifies the purpose of the code and
purpose of the code and thus the location(s) where Bison should thus the location(s) where Bison should generate it. For C/C++, the
generate it. For C/C++, the qualifier can be omitted for the default qualifier can be omitted for the default location, or it can be one of
location, or it can be one of @code{requires}, @code{provides}, @code{requires}, @code{provides}, @code{top}. @xref{%code Summary}.
@code{top}. @xref{%code Summary}.
Look again at the example of the previous section: Look again at the example of the previous section:
@@ -3060,21 +3058,20 @@ the same time:
@end example @end example
@noindent @noindent
In this way, @code{%code top} and the unqualified @code{%code} achieve the same In this way, @code{%code top} and the unqualified @code{%code} achieve the
functionality as the two kinds of @var{Prologue} sections, but it's always same functionality as the two kinds of @var{Prologue} sections, but it's
explicit which kind you intend. always explicit which kind you intend. Moreover, both kinds are always
Moreover, both kinds are always available even in the absence of @code{%union}. available even in the absence of @code{%union}.
The @code{%code top} block above logically contains two parts. The The @code{%code top} block above logically contains two parts. The first
first two lines before the warning need to appear near the top of the two lines before the warning need to appear near the top of the parser
parser implementation file. The first line after the warning is implementation file. The first line after the warning is required by
required by @code{YYSTYPE} and thus also needs to appear in the parser @code{YYSTYPE} and thus also needs to appear in the parser implementation
implementation file. However, if you've instructed Bison to generate file. However, if you've instructed Bison to generate a parser header file
a parser header file (@pxref{Decl Summary, ,%defines}), you probably (@pxref{Decl Summary, ,%defines}), you probably want that line to appear
want that line to appear before the @code{YYSTYPE} definition in that before the @code{YYSTYPE} definition in that header file as well. The
header file as well. The @code{YYLTYPE} definition should also appear @code{YYLTYPE} definition should also appear in the parser header file to
in the parser header file to override the default @code{YYLTYPE} override the default @code{YYLTYPE} definition there.
definition there.
In other words, in the @code{%code top} block above, all but the first two In other words, in the @code{%code top} block above, all but the first two
lines are dependency code required by the @code{YYSTYPE} and @code{YYLTYPE} lines are dependency code required by the @code{YYSTYPE} and @code{YYLTYPE}