X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/aef3da86899c5f2cd4eed728b63bd82413106a43..136a0f766b38072ec6ac6c386b230e04d4146151:/doc/bison.texinfo diff --git a/doc/bison.texinfo b/doc/bison.texinfo index 013847b5..bcff2ea5 100644 --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@ -2674,22 +2674,17 @@ of feature test macros like @code{_GNU_SOURCE} or feature test macros can affect the behavior of Bison-generated @code{#include} directives. -@findex %before-header -@findex %start-header -@findex %after-header +@findex %requires +@findex %code If you've instructed Bison to generate a header file (@pxref{Table of Symbols, ,%defines}), you probably want @code{#include "ptypes.h"} to appear in that header file as well. -In that case, use @code{%before-header}, @code{%start-header}, and -@code{%after-header} instead of @var{Prologue} sections -(@pxref{Table of Symbols, ,%start-header}): +In that case, use @code{%requires}, @code{%provides}, and +@code{%code} instead of @var{Prologue} sections +(@pxref{Table of Symbols, ,%requires}): @smallexample -%before-header @{ - #include -@} - -%start-header @{ +%requires @{ #include "ptypes.h" @} %union @{ @@ -2697,7 +2692,9 @@ In that case, use @code{%before-header}, @code{%start-header}, and tree t; /* @r{@code{tree} is defined in @file{ptypes.h}.} */ @} -%after-header @{ +%code @{ + #include + static void print_token_value (FILE *, int, YYSTYPE); #define YYPRINT(F, N, L) print_token_value (F, N, L) @} @@ -4327,11 +4324,11 @@ typically needs to be able to refer to the above-mentioned declarations and to the token type codes. @xref{Token Values, ,Semantic Values of Tokens}. -@findex %start-header -@findex %end-header -If you have declared @code{%start-header} or @code{%end-header}, the output +@findex %requires +@findex %provides +If you have declared @code{%requires} or @code{%provides}, the output header also contains their code. -@xref{Table of Symbols, ,%start-header}. +@xref{Table of Symbols, ,%requires}. @end deffn @deffn {Directive} %destructor @@ -6374,8 +6371,7 @@ As documented elsewhere (@pxref{Algorithm, ,The Bison Parser Algorithm}) Bison parsers are @dfn{shift/reduce automata}. In some cases (much more frequent than one would hope), looking at this automaton is required to tune or simply fix a parser. Bison provides two different -representation of it, either textually or graphically (as a @acronym{VCG} -file). +representation of it, either textually or graphically (as a DOT file). The textual file is generated when the options @option{--report} or @option{--verbose} are specified, see @xref{Invocation, , Invoking @@ -7073,10 +7069,11 @@ The other output files' names are constructed from @var{file} as described under the @samp{-v} and @samp{-d} options. @item -g -Output a @acronym{VCG} definition of the @acronym{LALR}(1) grammar -automaton computed by Bison. If the grammar file is @file{foo.y}, the -@acronym{VCG} output file will -be @file{foo.vcg}. +Output a graphical representation of the @acronym{LALR}(1) grammar +automaton computed by Bison, in @uref{http://www.graphviz.org/, Graphviz} +@uref{http://www.graphviz.org/doc/info/lang.html, @acronym{DOT}} format. +If the grammar file is @file{foo.y}, the output file will +be @file{foo.dot}. @item --graph=@var{graph-file} The behavior of @var{--graph} is the same than @samp{-g}. The only @@ -7560,18 +7557,18 @@ the grammar for. @end example @noindent -@findex %start-header +@findex %requires Then come the declarations/inclusions needed to define the @code{%union}. Because the parser uses the parsing driver and reciprocally, both cannot include the header of the other. Because the driver's header needs detailed knowledge about the parser class (in particular its inner types), it is the parser's header which will simply use a forward declaration of the driver. -@xref{Table of Symbols, ,%start-header}. +@xref{Table of Symbols, ,%requires}. @comment file: calc++-parser.yy @example -%start-header @{ +%requires @{ # include class calcxx_driver; @} @@ -7630,13 +7627,13 @@ them. @end example @noindent -@findex %after-header -The code between @samp{%after-header @{} and @samp{@}} is output in the +@findex %code +The code between @samp{%code @{} and @samp{@}} is output in the @file{*.cc} file; it needs detailed knowledge about the driver. @comment file: calc++-parser.yy @example -%after-header @{ +%code @{ # include "calc++-driver.hh" @} @end example @@ -8308,49 +8305,35 @@ $end}, where @var{start} is the start symbol. @xref{Start Decl, , The Start-Symbol}. It cannot be used in the grammar. @end deffn -@deffn {Directive} %after-header @{@var{code}@} +@deffn {Directive} %code @{@var{code}@} Specifies code to be inserted into the code file after the contents of the header file. -@xref{Table of Symbols, ,%start-header}. +@xref{Table of Symbols, ,%requires}. @end deffn -@deffn {Directive} %before-header @{@var{code}@} -Specifies code to be inserted into the code file before the contents of the -header file. -@xref{Table of Symbols, ,%start-header}. -@end deffn - -@deffn {Directive} %end-header @{@var{code}@} +@deffn {Directive} %provides @{@var{code}@} Specifies code to be inserted both into the header file (if generated; @pxref{Table of Symbols, ,%defines}) and into the code file after any Bison-generated definitions. -@xref{Table of Symbols, ,%start-header}. +@xref{Table of Symbols, ,%requires}. @end deffn -@deffn {Directive} %start-header @{@var{code}@} +@deffn {Directive} %requires @{@var{code}@} Specifies code to be inserted both into the header file (if generated; @pxref{Table of Symbols, ,%defines}) and into the code file before any Bison-generated definitions. @cindex Prologue -@findex %before-header @findex %union -@findex %end-header -@findex %after-header +@findex %provides +@findex %code For example, the following declaration order in the grammar file reflects the order in which Bison will output these code blocks. However, you are free to declare these code blocks in your grammar file in whatever order is most convenient for you: @smallexample -%before-header @{ - /* Bison treats this block like a pre-prologue block: it inserts it - * into the code file before the contents of the header file. It - * does *not* insert it into the header file. This is a good place - * to put #include's that you want at the top of your code file. A - * common example is `#include "system.h"'. */ -@} -%start-header @{ +%requires @{ /* Bison inserts this block into both the header file and the code * file. In both files, the point of insertion is before any * Bison-generated token, semantic type, location type, and class @@ -8359,17 +8342,17 @@ convenient for you: @} %union @{ /* Unlike the traditional Yacc prologue blocks, the output order - * for the %*-header blocks is not affected by their declaration - * position relative to any %union in the grammar file. */ + * for %requires, %provides or %code blocks is not affected by their + * declaration position relative to any %union in the grammar file. */ @} -%end-header @{ +%provides @{ /* Bison inserts this block into both the header file and the code * file. In both files, the point of insertion is after the * Bison-generated definitions. This is a good place to declare or * define public functions or data structures that depend on the * Bison-generated definitions. */ @} -%after-header @{ +%code @{ /* Bison treats this block like a post-prologue block: it inserts * it into the code file after the contents of the header file. It * does *not* insert it into the header file. This is a good place @@ -8931,9 +8914,9 @@ grammatically indivisible. The piece of text it represents is a token. @c LocalWords: strncmp intval tindex lvalp locp llocp typealt YYBACKUP @c LocalWords: YYEMPTY YYEOF YYRECOVERING yyclearin GE def UMINUS maybeword @c LocalWords: Johnstone Shamsa Sadaf Hussain Tomita TR uref YYMAXDEPTH -@c LocalWords: YYINITDEPTH stmnts ref stmnt initdcl maybeasm VCG notype +@c LocalWords: YYINITDEPTH stmnts ref stmnt initdcl maybeasm notype @c LocalWords: hexflag STR exdent itemset asis DYYDEBUG YYFPRINTF args -@c LocalWords: infile ypp yxx outfile itemx vcg tex leaderfill +@c LocalWords: infile ypp yxx outfile itemx tex leaderfill @c LocalWords: hbox hss hfill tt ly yyin fopen fclose ofirst gcc ll @c LocalWords: yyrestart nbar yytext fst snd osplit ntwo strdup AST @c LocalWords: YYSTACK DVI fdl printindex