From dbb998364f6a3057ab65a5ed4b6190396cf5eaf2 Mon Sep 17 00:00:00 2001 From: Theophile Ranquet Date: Fri, 23 Nov 2012 16:23:27 +0000 Subject: [PATCH 1/5] local.at: improvements * tests/local.at (AT_YYERROR_FORMALS): Make llocp const. (AT_PURE_AND_LOC_IF, AT_GLR_OR_PARAM_IF): Remove, expand... (AT_YYERROR_ARG_LOC_IF): Here, and use m4_join for readability. --- tests/local.at | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/tests/local.at b/tests/local.at index efba29dc..b7cefaaf 100644 --- a/tests/local.at +++ b/tests/local.at @@ -151,10 +151,6 @@ m4_pushdef([AT_PURE_IF], [m4_bmatch([$3], [%define *api\.pure\|%pure-parser], [m4_bmatch([$3], [%define *api\.pure *"?false"?], [$2], [$1])], [$2])]) -m4_pushdef([AT_PURE_AND_LOC_IF], -[m4_bmatch([$3], [%locations], [AT_PURE_IF($@)], [$2])]) -m4_pushdef([AT_GLR_OR_PARAM_IF], -[m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])]) m4_pushdef([AT_NAME_PREFIX], [m4_bmatch([$3], [\(%define api\.prefix\|%name-prefix\) ".*"], [m4_bregexp([$3], [\(%define api\.prefix\|%name-prefix\) "\([^""]*\)"], [\2])], @@ -165,17 +161,28 @@ m4_pushdef([AT_API_prefix], [yy])]) m4_pushdef([AT_API_PREFIX], [m4_toupper(AT_API_prefix)]) -# yyerror receives the location if %location & %pure & (%glr or %parse-param). +# yyerror receives the location if %location, and if the parser is pure. For +# historical reasons, with the "yacc.c" skeleton, the location is not passed +# unless an additional "%parse-param" is present, or if the purity is defined +# as "full". m4_pushdef([AT_YYERROR_ARG_LOC_IF], -[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])], - [$2])]) -# yyerror always sees the locations (when activated), except if -# (yacc & pure & !param). FIXME: This is wrong. See the manual. +[AT_LOCATION_IF([AT_PURE_IF([m4_bmatch([$3], + m4_quote(m4_join([\|], + [%glr-parser], + [%parse-param], + [%skeleton "?glr.c"?])), + [$1], [$2])], + [$2])], + [$2])]) + +# yyerror always sees the locations (when activated) if the parser is impure. +# When the parser is pure, yyerror sees the location if it is received as an +# argument. m4_pushdef([AT_YYERROR_SEES_LOC_IF], -[AT_LOCATION_IF([AT_YACC_IF([AT_PURE_IF([AT_PARAM_IF([$1], [$2])], - [$1])], - [$1])], - [$2])]) +[AT_LOCATION_IF([AT_YACC_IF([AT_PURE_IF([AT_YYERROR_ARG_LOC_IF([$1], [$2])], + [$1])], + [$1])], + [$2])]) # The interface is pure: either because %define api.pure, or because we # are using the C++ parsers. @@ -244,8 +251,6 @@ m4_popdef([AT_YYERROR_ARG_LOC_IF]) m4_popdef([AT_API_PREFIX]) m4_popdef([AT_API_prefix]) m4_popdef([AT_NAME_PREFIX]) -m4_popdef([AT_GLR_OR_PARAM_IF]) -m4_popdef([AT_PURE_AND_LOC_IF]) m4_popdef([AT_LOCATION_TYPE_IF]) m4_popdef([AT_LOCATION_IF]) m4_popdef([AT_PARSE_PARAMS]) @@ -358,7 +363,7 @@ static # Must be called inside a AT_BISON_OPTION_PUSHDEFS/POPDEFS pair. m4_define([AT_YYERROR_FORMALS], [m4_case(AT_LANG, -[c], [AT_YYERROR_ARG_LOC_IF([AT_YYLTYPE *llocp, ])AT_PARSE_PARAMS [const char *msg]])[]dnl +[c], [AT_YYERROR_ARG_LOC_IF([AT_YYLTYPE const * const llocp, ])AT_PARSE_PARAMS [const char *msg]])[]dnl ]) m4_define([AT_YYERROR_PROTOTYPE], From 6428a8a4a569b0b7ac1b84bdd78efc3fe18160ca Mon Sep 17 00:00:00 2001 From: Theophile Ranquet Date: Fri, 23 Nov 2012 17:30:47 +0000 Subject: [PATCH 2/5] yacc.c: support "%define api.pure full" This makes the interface for yyerror() pure without the need for a spurious parse_param. * data/yacc.c (b4_pure_if, b4_pure_flag): New definition, accept three states. (b4_yacc_pure_if): Rename as... (b4_yyerror_arg_loc_if): This, and use b4_pure_flag. * tests/actions.at (%define api.pure): Modernize. * test/calc.at (Simple LALR Calculator): Modernize. * tests/local.at (AT_YYERROR_ARG_LOC_IF): Adjust. --- data/yacc.c | 34 +++++++++++++++++++++++----------- tests/actions.at | 17 +++++++++-------- tests/calc.at | 8 ++++---- tests/local.at | 2 ++ 4 files changed, 38 insertions(+), 23 deletions(-) diff --git a/data/yacc.c b/data/yacc.c index bbc9d915..0f315523 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -65,24 +65,36 @@ m4_define_default([b4_stack_depth_init], [200]) ## ------------------------ ## b4_percent_define_default([[api.pure]], [[false]]) -b4_define_flag_if([pure]) -m4_define([b4_pure_flag], - [b4_percent_define_flag_if([[api.pure]], [[1]], [[0]])]) +b4_percent_define_check_values([[[[api.pure]], + [[false]], [[true]], [[]], [[full]]]]) -# b4_yacc_pure_if(IF-TRUE, IF-FALSE) -# ---------------------------------- -# Expand IF-TRUE, if %pure-parser and %parse-param, IF-FALSE otherwise. -m4_define([b4_yacc_pure_if], -[b4_pure_if([m4_ifset([b4_parse_param], - [$1], [$2])], - [$2])]) +m4_define([b4_pure_flag], [[0]]) +m4_case(b4_percent_define_get([[api.pure]]), + [false], [m4_define([b4_pure_flag], [[0]])], + [true], [m4_define([b4_pure_flag], [[1]])], + [], [m4_define([b4_pure_flag], [[1]])], + [full], [m4_define([b4_pure_flag], [[2]])]) +m4_define([b4_pure_if], +[m4_case(b4_pure_flag, + [0], [$2], + [1], [$1], + [2], [$1])]) + [m4_fatal([invalid api.pure value: ]$1)])]) + +# b4_yyerror_arg_loc_if(ARG) +# -------------------------- +# Expand ARG iff yyerror is to be given a location as argument. +m4_define([b4_yyerror_arg_loc_if], +[b4_locations_if([m4_case(b4_pure_flag, + [1], [m4_ifset([b4_parse_param], [$1])], + [2], [$1])])]) # b4_yyerror_args # --------------- # Arguments passed to yyerror: user args plus yylloc. m4_define([b4_yyerror_args], -[b4_yacc_pure_if([b4_locations_if([&yylloc, ])])dnl +[b4_yyerror_arg_loc_if([&yylloc, ])dnl m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])]) diff --git a/tests/actions.at b/tests/actions.at index 78977c86..e6df7551 100644 --- a/tests/actions.at +++ b/tests/actions.at @@ -79,7 +79,7 @@ AT_CLEANUP m4_pushdef([AT_TEST], [AT_SETUP([Initial location: $1 $2]) -AT_BISON_OPTION_PUSHDEFS([%locations %skeleton "$1" $2 %parse-param { int x }]) +AT_BISON_OPTION_PUSHDEFS([%locations %skeleton "$1" $2]) AT_DATA_GRAMMAR([[input.y]], [[%defines /* FIXME: Required by lalr1.cc in Bison 2.6. */ %locations @@ -87,7 +87,6 @@ AT_DATA_GRAMMAR([[input.y]], %skeleton "$1" ]$2[ ]$3[ -%parse-param { int x } // Useless, but used to force yyerror purity. %code { # include @@ -113,11 +112,11 @@ exp: { ]AT_SKEL_CC_IF([[std::cerr << @$ << std::endl]], int main (void) {]AT_SKEL_CC_IF([[ - yy::parser p (0); + yy::parser p; p.set_debug_level (!!getenv("YYDEBUG")); return p.parse ();]], [[ yydebug = !!getenv("YYDEBUG"); - return !!yyparse (0);]])[ + return !!yyparse (]AT_PARAM_IF([0])[);]])[ } ]]) @@ -132,10 +131,12 @@ AT_CLEANUP ## FIXME: test Java, and iterate over skeletons. AT_TEST([yacc.c]) -AT_TEST([yacc.c], [%define api.pure]) +AT_TEST([yacc.c], [%define api.pure full]) +AT_TEST([yacc.c], [%define api.pure %parse-param { int x }]) AT_TEST([yacc.c], [%define api.push-pull both]) -AT_TEST([yacc.c], [%define api.push-pull both %define api.pure]) +AT_TEST([yacc.c], [%define api.push-pull both %define api.pure full]) AT_TEST([glr.c]) +AT_TEST([glr.c], [%define api.pure]) AT_TEST([lalr1.cc]) AT_TEST([glr.cc]) @@ -146,7 +147,7 @@ AT_TEST([glr.cc]) ## Weirdly enough, to trigger the warning with GCC 4.7, we must not ## use fprintf, so run the test twice: once to check the warning ## (absence thereof), and another time to check the value. -AT_TEST([yacc.c], [%define api.pure], +AT_TEST([yacc.c], [%define api.pure full], [[%{ # define YYLTYPE int # define YY_LOCATION_PRINT(Stream, Loc) \ @@ -157,7 +158,7 @@ AT_TEST([yacc.c], [%define api.pure], ]], [@&t@]) -AT_TEST([yacc.c], [%define api.pure], +AT_TEST([yacc.c], [%define api.pure full], [[%{ # define YYLTYPE int # define YY_LOCATION_PRINT(Stream, Loc) \ diff --git a/tests/calc.at b/tests/calc.at index 4ab725b3..f72836ee 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -604,8 +604,8 @@ AT_CHECK_CALC_LALR([%verbose]) AT_CHECK_CALC_LALR([%yacc]) AT_CHECK_CALC_LALR([%error-verbose]) -AT_CHECK_CALC_LALR([%define api.pure %locations]) -AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %locations]) +AT_CHECK_CALC_LALR([%define api.pure full %locations]) +AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure full %locations]) AT_CHECK_CALC_LALR([%error-verbose %locations]) AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc]) @@ -615,8 +615,8 @@ AT_CHECK_CALC_LALR([%debug]) AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR([%define api.pure full %verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure full %verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc]) AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) diff --git a/tests/local.at b/tests/local.at index b7cefaaf..48afab83 100644 --- a/tests/local.at +++ b/tests/local.at @@ -168,6 +168,7 @@ m4_pushdef([AT_API_PREFIX], m4_pushdef([AT_YYERROR_ARG_LOC_IF], [AT_LOCATION_IF([AT_PURE_IF([m4_bmatch([$3], m4_quote(m4_join([\|], + [%define api.pure "?full"?], [%glr-parser], [%parse-param], [%skeleton "?glr.c"?])), @@ -355,6 +356,7 @@ static }]dnl ]) +# AT_YYERROR_FORMALS # AT_YYERROR_PROTOTYPE # AT_YYERROR_DECLARE_EXTERN # AT_YYERROR_DECLARE From 1f1bd5729743e155e71767810eaef22bd84e340b Mon Sep 17 00:00:00 2001 From: Theophile Ranquet Date: Mon, 26 Nov 2012 18:17:15 +0100 Subject: [PATCH 3/5] doc: introduce api.pure full, rearrange some examples * NEWS: Add entry. * doc/bison.texi (%define Summary): Show the old Yacc behaviour. (Parser Function): Move parse-param examples here. (Pure Calling): Remove parse-param examples. (Error Reporting): Don't show the old behavior, stick to 'full'. --- NEWS | 11 ++++ doc/bison.texi | 141 ++++++++++++++++++++++++++----------------------- 2 files changed, 86 insertions(+), 66 deletions(-) diff --git a/NEWS b/NEWS index 3789e92d..2cd57c28 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,17 @@ GNU Bison NEWS * Noteworthy changes in release ?.? (????-??-??) [?] +** New value for %define variable: api.pure full + + The %define variable api.pure requests a pure (reentrant) parser. However, + for historical reasons, using it in a location-tracking Yacc parser resulted + in an yyerror function that did not take a location as a parameter. With this + new value, the user may request a better pure parser, where yyerror does take + a location as a parameter (in location-tracking parsers). + + The use of "%define api.pure true" is deprecated in favor of this new + "%define api.pure full". + ** Changes in the format of error messages This used to be the format of many error reports: diff --git a/doc/bison.texi b/doc/bison.texi index f2d3dbc5..32396a89 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -4866,6 +4866,7 @@ may override this restriction with the @code{%start} declaration as follows: @cindex reentrant parser @cindex pure parser @findex %define api.pure +@findex %define api.pure full A @dfn{reentrant} program is one which does not alter in the course of execution; in other words, it consists entirely of @dfn{pure} (read-only) @@ -4885,7 +4886,7 @@ declaration @code{%define api.pure} says that you want the parser to be reentrant. It looks like this: @example -%define api.pure +%define api.pure full @end example The result is that the communication variables @code{yylval} and @@ -4935,7 +4936,7 @@ compatibility with the impure Yacc pull mode interface. Unless you know what you are doing, your declarations should look like this: @example -%define api.pure +%define api.pure full %define api.push-pull push @end example @@ -5008,8 +5009,8 @@ yypull_parse (ps); /* Will call the lexer */ yypstate_delete (ps); @end example -Adding the @code{%define api.pure} declaration does exactly the same thing to -the generated parser with @code{%define api.push-pull both} as it did for +Adding the @code{%define api.pure full} declaration does exactly the same thing +to the generated parser with @code{%define api.push-pull both} as it did for @code{%define api.push-pull push}. @node Decl Summary @@ -5373,9 +5374,40 @@ Some of the accepted @var{variable}s are: @item Purpose: Request a pure (reentrant) parser program. @xref{Pure Decl, ,A Pure (Reentrant) Parser}. -@item Accepted Values: Boolean +@item Accepted Values: @code{true}, @code{false}, @code{full} + +The value may be omitted: this is equivalent to specifying @code{true}, as is +the case for Boolean values. + +When @code{%define api.pure full} is used, the parser is made reentrant. This +changes the signature for yylex (@pxref{Pure Calling}), and also that of +yyerror when the tracking of locations has been activated, as shown below. + +The @code{true} value is very similar to the @code{full} value, the only +difference is in the signature of @code{yyerror} on Yacc parsers without +@code{%parse-param}, for historical reasons. + +I.e., if @samp{%locations %define api.pure} is passed then the prototypes for +@code{yyerror} are: + +@example +void yyerror (char const *msg); /* Yacc parsers. */ +void yyerror (YYLTYPE *locp, char const *msg); /* GLR parsers. */ +@end example + +But if @samp{%locations %define api.pure %parse-param @{int *nastiness@}} is +used, then both parsers have the same signature: + +@example +void yyerror (YYLTYPE *llocp, int *nastiness, char const *msg); +@end example + +(@pxref{Error Reporting, ,The Error +Reporting Function @code{yyerror}}) @item Default Value: @code{false} + +@item History: the @code{full} value was introduced in Bison 2.7 @end itemize @c ================================================== api.push-pull @@ -5820,6 +5852,27 @@ In the grammar actions, use expressions like this to refer to the data: exp: @dots{} @{ @dots{}; *randomness += 1; @dots{} @} @end example +@noindent +Using the following: +@example +%parse-param @{int *randomness@} +@end example + +Results in these signatures: +@example +void yyerror (int *randomness, const char *msg); +int yyparse (int *randomness); +@end example + +@noindent +Or, if both @code{%define api.pure full} (or just @code{%define api.pure}) +and @code{%locations} are used: + +@example +void yyerror (YYLTYPE *llocp, int *randomness, const char *msg); +int yyparse (int *randomness); +@end example + @node Push Parser Function @section The Push Parser Function @code{yypush_parse} @findex yypush_parse @@ -6071,7 +6124,7 @@ The data type of @code{yylloc} has the name @code{YYLTYPE}. @node Pure Calling @subsection Calling Conventions for Pure Parsers -When you use the Bison declaration @code{%define api.pure} to request a +When you use the Bison declaration @code{%define api.pure full} to request a pure, reentrant parser, the global communication variables @code{yylval} and @code{yylloc} cannot be used. (@xref{Pure Decl, ,A Pure (Reentrant) Parser}.) In such parsers the two global variables are replaced by @@ -6106,35 +6159,25 @@ Declare that the braced-code @var{argument-declaration} is an additional @code{yylex} argument declaration. @end deffn +@noindent For instance: @example -%parse-param @{int *nastiness@} %lex-param @{int *nastiness@} -%parse-param @{int *randomness@} @end example @noindent -results in the following signatures: +results in the following signature: @example -int yylex (int *nastiness); -int yyparse (int *nastiness, int *randomness); -@end example - -If @code{%define api.pure} is added: - -@example -int yylex (YYSTYPE *lvalp, int *nastiness); -int yyparse (int *nastiness, int *randomness); +int yylex (int *nastiness); @end example @noindent -and finally, if both @code{%define api.pure} and @code{%locations} are used: +If @code{%define api.pure full} (or just @code{%define api.pure}) is added: @example -int yylex (YYSTYPE *lvalp, YYLTYPE *llocp, int *nastiness); -int yyparse (int *nastiness, int *randomness); +int yylex (YYSTYPE *lvalp, int *nastiness); @end example @node Error Reporting @@ -6194,50 +6237,16 @@ error recovery if you have written suitable error recovery grammar rules immediately return 1. Obviously, in location tracking pure parsers, @code{yyerror} should have -an access to the current location. -This is indeed the case for the GLR -parsers, but not for the Yacc parser, for historical reasons. I.e., if -@samp{%locations %define api.pure} is passed then the prototypes for -@code{yyerror} are: +an access to the current location. With @code{%define api.pure}, this is +indeed the case for the GLR parsers, but not for the Yacc parser, for +historical reasons, and this is the why @code{%define api.pure full} should be +prefered over @code{%define api.pure}. + +When @code{%locations %define api.pure full} is used, @code{yyerror} has the +following signature: @example -void yyerror (char const *msg); /* Yacc parsers. */ -void yyerror (YYLTYPE *locp, char const *msg); /* GLR parsers. */ -@end example - -If @samp{%parse-param @{int *nastiness@}} is used, then: - -@example -void yyerror (int *nastiness, char const *msg); /* Yacc parsers. */ -void yyerror (int *nastiness, char const *msg); /* GLR parsers. */ -@end example - -Finally, GLR and Yacc parsers share the same @code{yyerror} calling -convention for absolutely pure parsers, i.e., when the calling -convention of @code{yylex} @emph{and} the calling convention of -@code{%define api.pure} are pure. -I.e.: - -@example -/* Location tracking. */ -%locations -/* Pure yylex. */ -%define api.pure -%lex-param @{int *nastiness@} -/* Pure yyparse. */ -%parse-param @{int *nastiness@} -%parse-param @{int *randomness@} -@end example - -@noindent -results in the following signatures for all the parser kinds: - -@example -int yylex (YYSTYPE *lvalp, YYLTYPE *llocp, int *nastiness); -int yyparse (int *nastiness, int *randomness); -void yyerror (YYLTYPE *locp, - int *nastiness, int *randomness, - char const *msg); +void yyerror (YYLTYPE *locp, char const *msg); @end example @noindent @@ -9790,7 +9799,7 @@ described by @var{m}. The parser invokes the scanner by calling @code{yylex}. Contrary to C parsers, C++ parsers are always pure: there is no point in using the -@code{%define api.pure} directive. Therefore the interface is as follows. +@code{%define api.pure full} directive. Therefore the interface is as follows. @deftypemethod {parser} {int} yylex (semantic_type* @var{yylval}, location_type* @var{yylloc}, @var{type1} @var{arg1}, ...) Return the next token. Its type is the return value, its semantic @@ -10353,7 +10362,7 @@ You can create documentation for generated parsers using Javadoc. Contrary to C parsers, Java parsers do not use global variables; the state of the parser is always local to an instance of the parser class. Therefore, all Java parsers are ``pure'', and the @code{%pure-parser} -and @code{%define api.pure} directives does not do anything when used in +and @code{%define api.pure full} directives does not do anything when used in Java. Push parsers are currently unsupported in Java and @code{%define @@ -10936,7 +10945,7 @@ or @quotation My parser includes support for an @samp{#include}-like feature, in which case I run @code{yyparse} from @code{yyparse}. This fails -although I did specify @samp{%define api.pure}. +although I did specify @samp{%define api.pure full}. @end quotation These problems typically come not from Bison itself, but from From 371f1b2b7bdba58cd8dc1b4dc91c30f2d0bc9cf2 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 29 Nov 2012 14:09:34 +0100 Subject: [PATCH 4/5] doc: improve the index * doc/bison.texi: Fix uses of "deffn" so that the arguments of the directives do not show in the index. Remove a duplicate entry for api.pure. --- doc/bison.texi | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/bison.texi b/doc/bison.texi index 32396a89..21ce3929 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -4866,7 +4866,6 @@ may override this restriction with the @code{%start} declaration as follows: @cindex reentrant parser @cindex pure parser @findex %define api.pure -@findex %define api.pure full A @dfn{reentrant} program is one which does not alter in the course of execution; in other words, it consists entirely of @dfn{pure} (read-only) @@ -7364,7 +7363,7 @@ mysterious behavior altogether. You simply need to activate a more powerful parser table construction algorithm by using the @code{%define lr.type} directive. -@deffn {Directive} {%define lr.type @var{TYPE}} +@deffn {Directive} {%define lr.type} @var{TYPE} Specify the type of parser tables within the LR(1) family. The accepted values for @var{TYPE} are: @@ -7553,7 +7552,7 @@ split the parse instead. To adjust which states have default reductions enabled, use the @code{%define lr.default-reductions} directive. -@deffn {Directive} {%define lr.default-reductions @var{WHERE}} +@deffn {Directive} {%define lr.default-reductions} @var{WHERE} Specify the kind of states that are permitted to contain default reductions. The accepted values of @var{WHERE} are: @itemize @@ -7593,7 +7592,7 @@ that solves these problems for canonical LR, IELR, and LALR without sacrificing @code{%nonassoc}, default reductions, or state merging. You can enable LAC with the @code{%define parse.lac} directive. -@deffn {Directive} {%define parse.lac @var{VALUE}} +@deffn {Directive} {%define parse.lac} @var{VALUE} Enable LAC to improve syntax error handling. @itemize @item @code{none} (default) @@ -7689,7 +7688,7 @@ resolution because they are useless in the generated parser. However, keeping unreachable states is sometimes useful when trying to understand the relationship between the parser and the grammar. -@deffn {Directive} {%define lr.keep-unreachable-states @var{VALUE}} +@deffn {Directive} {%define lr.keep-unreachable-states} @var{VALUE} Request that Bison allow unreachable states to remain in the parser tables. @var{VALUE} must be a Boolean. The default is @code{false}. @end deffn From 511dd971ba0dcba64c5a113ee7b0fc40ff4e2943 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 29 Nov 2012 14:35:48 +0100 Subject: [PATCH 5/5] doc: minor fixes * doc/bison.texi: Use stderr for error messages. Meta-variables are usually spelled in lower case. Use @code for function names. --- doc/bison.texi | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/doc/bison.texi b/doc/bison.texi index 21ce3929..fc880315 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -2452,7 +2452,7 @@ function that initializes the symbol table. Here it is, and void yyerror (char const *s) @{ - printf ("%s\n", s); + fprintf (stderr, "%s\n", s); @} @end group @@ -5379,8 +5379,9 @@ The value may be omitted: this is equivalent to specifying @code{true}, as is the case for Boolean values. When @code{%define api.pure full} is used, the parser is made reentrant. This -changes the signature for yylex (@pxref{Pure Calling}), and also that of -yyerror when the tracking of locations has been activated, as shown below. +changes the signature for @code{yylex} (@pxref{Pure Calling}), and also that of +@code{yyerror} when the tracking of locations has been activated, as shown +below. The @code{true} value is very similar to the @code{full} value, the only difference is in the signature of @code{yyerror} on Yacc parsers without @@ -7363,9 +7364,9 @@ mysterious behavior altogether. You simply need to activate a more powerful parser table construction algorithm by using the @code{%define lr.type} directive. -@deffn {Directive} {%define lr.type} @var{TYPE} +@deffn {Directive} {%define lr.type} @var{type} Specify the type of parser tables within the LR(1) family. The accepted -values for @var{TYPE} are: +values for @var{type} are: @itemize @item @code{lalr} (default) @@ -7552,9 +7553,9 @@ split the parse instead. To adjust which states have default reductions enabled, use the @code{%define lr.default-reductions} directive. -@deffn {Directive} {%define lr.default-reductions} @var{WHERE} +@deffn {Directive} {%define lr.default-reductions} @var{where} Specify the kind of states that are permitted to contain default reductions. -The accepted values of @var{WHERE} are: +The accepted values of @var{where} are: @itemize @item @code{most} (default for LALR and IELR) @item @code{consistent} @@ -7592,7 +7593,7 @@ that solves these problems for canonical LR, IELR, and LALR without sacrificing @code{%nonassoc}, default reductions, or state merging. You can enable LAC with the @code{%define parse.lac} directive. -@deffn {Directive} {%define parse.lac} @var{VALUE} +@deffn {Directive} {%define parse.lac} @var{value} Enable LAC to improve syntax error handling. @itemize @item @code{none} (default) @@ -7688,9 +7689,9 @@ resolution because they are useless in the generated parser. However, keeping unreachable states is sometimes useful when trying to understand the relationship between the parser and the grammar. -@deffn {Directive} {%define lr.keep-unreachable-states} @var{VALUE} +@deffn {Directive} {%define lr.keep-unreachable-states} @var{value} Request that Bison allow unreachable states to remain in the parser tables. -@var{VALUE} must be a Boolean. The default is @code{false}. +@var{value} must be a Boolean. The default is @code{false}. @end deffn There are a few caveats to consider: