From 9dcb193aebe8c1520a4bfc9d9a8b3c401efb7a33 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 5 Jul 2012 09:37:20 +0200 Subject: [PATCH 01/12] gnulib: update. * bootstrap, gnulib: Update. * cfg.mk (syntax-check): Don't check "error" usage in bison.texi. --- bootstrap | 11 ++++++----- cfg.mk | 2 +- gnulib | 2 +- m4/.gitignore | 1 + 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bootstrap b/bootstrap index ce37a2c0..e9849102 100755 --- a/bootstrap +++ b/bootstrap @@ -1,6 +1,6 @@ #! /bin/sh # Print a version string. -scriptversion=2012-05-15.06; # UTC +scriptversion=2012-07-03.20; # UTC # Bootstrap this package from checked-out sources. @@ -215,7 +215,7 @@ find_tool () eval "export $find_tool_envvar" } -# Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6. +# Find sha1sum, named gsha1sum on MacPorts, and shasum on Mac OS X 10.6. find_tool SHA1SUM sha1sum gsha1sum shasum # Override the default configuration, if necessary. @@ -230,7 +230,6 @@ esac test -z "${gnulib_extra_files}" && \ gnulib_extra_files=" $build_aux/install-sh - $build_aux/missing $build_aux/mdate-sh $build_aux/texinfo.tex $build_aux/depcomp @@ -855,7 +854,8 @@ echo "$0: $gnulib_tool $gnulib_tool_options --import ..." $gnulib_tool $gnulib_tool_options --import $gnulib_modules && for file in $gnulib_files; do - symlink_to_dir "$GNULIB_SRCDIR" $file || exit + symlink_to_dir "$GNULIB_SRCDIR" $file \ + || { echo "$0: failed to symlink $file" 1>&2; exit 1; } done bootstrap_post_import_hook \ @@ -896,7 +896,8 @@ for file in $gnulib_extra_files; do build-aux/*) dst=$build_aux/${file#build-aux/};; *) dst=$file;; esac - symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit + symlink_to_dir "$GNULIB_SRCDIR" $file $dst \ + || { echo "$0: failed to symlink $file" 1>&2; exit 1; } done if test $with_gettext = yes; then diff --git a/cfg.mk b/cfg.mk index 31a2532f..222d3bc3 100644 --- a/cfg.mk +++ b/cfg.mk @@ -72,5 +72,5 @@ $(call exclude, \ require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \ space_tab=^tests/(input|c\+\+)\.at$$ \ trailing_blank=^src/parse-gram.[ch]$$ \ - unmarked_diagnostics=^djgpp/ \ + unmarked_diagnostics=^(djgpp/|doc/bison.texi$$) \ ) diff --git a/gnulib b/gnulib index b42157dd..31ec8584 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit b42157dd01e3243646f5a8270c09ee125a8aca21 +Subproject commit 31ec8584048ce391f1ff4fb26fde3c7389c656f3 diff --git a/m4/.gitignore b/m4/.gitignore index d47aee02..dc915a40 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -178,3 +178,4 @@ /xstrndup.m4 /off_t.m4 /sys_types_h.m4 +/fseterr.m4 From e358222ba8056b962878b61b3825acaed8b9d9be Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 5 Jul 2012 10:30:09 +0200 Subject: [PATCH 02/12] api.prefix: improve the documentation for YYDEBUG. * doc/bison.texi: Explain how api.prefix is applied to YYDEBUG. --- doc/bison.texi | 82 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 23 deletions(-) diff --git a/doc/bison.texi b/doc/bison.texi index fbe780cd..a53b52fc 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -5074,9 +5074,11 @@ default location or at the location specified by @var{qualifier}. @end deffn @deffn {Directive} %debug -In the parser implementation file, define the macro @code{YYDEBUG} to -1 if it is not already defined, so that the debugging facilities are -compiled. @xref{Tracing, ,Tracing Your Parser}. +In the parser implementation file, define the macro @code{YYDEBUG} (or +@code{@var{prefix}DEBUG} with @samp{%define api.prefix @var{prefix}}), see +@ref{Multiple Parsers, ,Multiple Parsers in the Same Program}) to 1 if it is +not already defined, so that the debugging facilities are compiled. +@xref{Tracing, ,Tracing Your Parser}. @end deffn @deffn {Directive} %define @var{variable} @@ -5314,6 +5316,8 @@ Some of the accepted @var{variable}s are: @item Accepted Values: String @item Default Value: @code{yy} + +@item History: introduced in Bison 2.6 @end itemize @c ================================================== api.pure @@ -5596,20 +5600,22 @@ also need to avoid conflicts on types and macros (e.g., @code{YYSTYPE}) exported in the generated header. The easy way to do this is to define the @code{%define} variable -@code{api.prefix} (possibly using the option -@samp{-Dapi.prefix=@var{prefix}}, see @ref{Invocation, ,Invoking Bison}). -This renames the interface functions and variables of the Bison parser to -start with @var{prefix} instead of @samp{yy}, and all the macros to start by -@var{PREFIX} (i.e., @var{prefix} upper cased) instead of @samp{YY}. You can -use this to give each parser distinct names that do not conflict. +@code{api.prefix}. With different @code{api.prefix}s it is guaranteed that +headers do not conflict when included together, and that compiled objects +can be linked together too. Specifying @samp{%define api.prefix +@var{prefix}} (or passing the option @samp{-Dapi.prefix=@var{prefix}}, see +@ref{Invocation, ,Invoking Bison}) renames the interface functions and +variables of the Bison parser to start with @var{prefix} instead of +@samp{yy}, and all the macros to start by @var{PREFIX} (i.e., @var{prefix} +upper-cased) instead of @samp{YY}. The renamed symbols include @code{yyparse}, @code{yylex}, @code{yyerror}, @code{yynerrs}, @code{yylval}, @code{yylloc}, @code{yychar} and @code{yydebug}. If you use a push parser, @code{yypush_parse}, @code{yypull_parse}, @code{yypstate}, @code{yypstate_new} and @code{yypstate_delete} will also be renamed. The renamed macros include -@code{YYSTYPE}, @code{YYSTYPE_IS_TRIVIAL}, @code{YYSTYPE_IS_DECLARED}, -@code{YYLTYPE}, @code{YYLTYPE_IS_TRIVIAL}, and @code{YYLTYPE_IS_DECLARED}. +@code{YYSTYPE}, @code{YYLTYPE}, and @code{YYDEBUG}, which is treated +specifically --- more about this below. For example, if you use @samp{%define api.prefix c}, the names become @code{cparse}, @code{clex}, @dots{}, @code{CSTYPE}, @code{CLTYPE}, and so @@ -5641,9 +5647,33 @@ extern CSTYPE clval; int cparse (void); @end example -Previously, a similar feature was provided by the obsoleted directive -@code{%name-prefix} (@pxref{Table of Symbols, ,Bison Symbols}) and option -@code{--name-prefix} (@pxref{Bison Options}). +The macro @code{YYDEBUG} is commonly used to enable the tracing support in +parsers. To comply with this tradition, when @code{api.prefix} is used, +@code{YYDEBUG} (not renamed) is used as a default value: + +@example +/* Enabling traces. */ +#ifndef CDEBUG +# if defined YYDEBUG +# if YYDEBUG +# define CDEBUG 1 +# else +# define CDEBUG 0 +# endif +# else +# define CDEBUG 0 +# endif +#endif +#if CDEBUG +extern int cdebug; +#endif +@end example + +@sp 2 + +Prior to Bison 2.6, a feature similar to @code{api.prefix} was provided by +the obsolete directive @code{%name-prefix} (@pxref{Table of Symbols, ,Bison +Symbols}) and the option @code{--name-prefix} (@pxref{Bison Options}). @node Interface @chapter Parser C-Language Interface @@ -8468,18 +8498,24 @@ parser. This is compliant with POSIX Yacc. You could use YYDEBUG 1} in the prologue of the grammar file (@pxref{Prologue, , The Prologue}). -@item the option @option{-t}, @option{--debug} -Use the @samp{-t} option when you run Bison (@pxref{Invocation, -,Invoking Bison}). This is POSIX compliant too. +If the @code{%define} variable @code{api.prefix} is used (@xref{Multiple +Parsers, ,Multiple Parsers in the Same Program}), for instance @samp{%define +api.prefix x}, then if @code{CDEBUG} is defined, its value controls the +tracing feature (enabled iff nonzero); otherwise tracing is enabled iff +@code{YYDEBUG} is nonzero. + +@item the option @option{-t} (POSIX Yacc compliant) +@itemx the option @option{--debug} (Bison extension) +Use the @samp{-t} option when you run Bison (@pxref{Invocation, ,Invoking +Bison}). With @samp{%define api.prefix c}, it defines @code{CDEBUG} to 1, +otherwise it defines @code{YYDEBUG} to 1. @item the directive @samp{%debug} @findex %debug -Add the @code{%debug} directive (@pxref{Decl Summary, ,Bison -Declaration Summary}). This is a Bison extension, which will prove -useful when Bison will output parsers for languages that don't use a -preprocessor. Unless POSIX and Yacc portability matter to -you, this is -the preferred solution. +Add the @code{%debug} directive (@pxref{Decl Summary, ,Bison Declaration +Summary}). This is a Bison extension, especially useful for languages that +don't use a preprocessor. Unless POSIX and Yacc portability matter to you, +this is the preferred solution. @end table We suggest that you always enable the debug option so that debugging is From c2425191273451f8c254c6907da1558a09192291 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 5 Jul 2012 10:30:47 +0200 Subject: [PATCH 03/12] NEWS: minor changes. * NEWS: style changes. --- NEWS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index ec4e33a5..dfdbe24d 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ GNU Bison NEWS * Noteworthy changes in release ?.? (????-??-??) [?] -** Future changes +** Future Changes The next major release of Bison will drop support for the following deprecated features. Please report disagreements to bug-bison@gnu.org. @@ -32,7 +32,7 @@ GNU Bison NEWS because existing versions of ylwrap (e.g., Automake 1.12.1) do not support it. -** Headers +** Generated Parser Headers *** Guards (yacc.c, glr.c, glr.cc) From 2a824fae30d1cea0f1e85eee3ce42d5c120299d6 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 5 Jul 2012 11:11:38 +0200 Subject: [PATCH 04/12] skeletons: style changes. * data/bison.m4: Define default values after having defined the support macros. Kill a dead comment. --- data/bison.m4 | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/data/bison.m4 b/data/bison.m4 index a5c1ee73..9a66d884 100644 --- a/data/bison.m4 +++ b/data/bison.m4 @@ -183,21 +183,6 @@ m4_define([b4_fatal_at], m4_exit(1)]) -## ---------------- ## -## Default values. ## -## ---------------- ## - -# m4_define_default([b4_lex_param], []) dnl breaks other skeletons -m4_define_default([b4_pre_prologue], []) -m4_define_default([b4_post_prologue], []) -m4_define_default([b4_epilogue], []) -m4_define_default([b4_parse_param], []) - -# The initial column and line. -m4_define_default([b4_location_initial_column], [1]) -m4_define_default([b4_location_initial_line], [1]) - - ## ------------ ## ## Data Types. ## ## ------------ ## @@ -258,10 +243,6 @@ b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated. b4_error_verbose_if([m4_define([b4_token_table_flag], [1])]) -## ------------------------- ## -## Assigning token numbers. ## -## ------------------------- ## - ## ----------- ## ## Synclines. ## @@ -580,3 +561,18 @@ m4_wrap_lifo([ b4_check_user_names_wrap([[define]], [[variable]]) b4_check_user_names_wrap([[code]], [[qualifier]]) ]) + + +## ---------------- ## +## Default values. ## +## ---------------- ## + +# m4_define_default([b4_lex_param], []) dnl breaks other skeletons +m4_define_default([b4_pre_prologue], []) +m4_define_default([b4_post_prologue], []) +m4_define_default([b4_epilogue], []) +m4_define_default([b4_parse_param], []) + +# The initial column and line. +m4_define_default([b4_location_initial_column], [1]) +m4_define_default([b4_location_initial_line], [1]) From ad60e80f3d13e8c4306a22a9d15863f73c576a27 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 5 Jul 2012 12:33:37 +0200 Subject: [PATCH 05/12] api.prefix: strengthen the tests and fix push-parsers. * tests/calc.at: Check api.prefix in addition to %name-prefix. * tests/headers.at: Check push parsers and pure interface. * tests/local.at: Use YYLTYPE renamed. * data/yacc.c (b4_declare_yyparse_push_): Handle api.prefix. * doc/bison.texi: Style changes. --- data/yacc.c | 19 ++++++----- doc/bison.texi | 6 ++-- tests/calc.at | 37 ++++++++++++---------- tests/headers.at | 82 +++++++++++++++++++++++++++--------------------- tests/local.at | 2 +- 5 files changed, 84 insertions(+), 62 deletions(-) diff --git a/data/yacc.c b/data/yacc.c index 2e46a1e2..5e77f844 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -230,22 +230,27 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[ # Declaration of yyparse (and dependencies) when using the push parser # (including in pull mode). m4_define([b4_declare_yyparse_push_], -[[typedef struct ]b4_prefix[pstate ]b4_prefix[pstate; +[[#ifndef YYPUSH_MORE_DEFINED +# define YYPUSH_MORE_DEFINED enum { YYPUSH_MORE = 4 }; +#endif + +typedef struct ]b4_prefix[pstate ]b4_prefix[pstate; + ]b4_pull_if([b4_c_function_decl([b4_prefix[parse]], [[int]], b4_parse_param) ])b4_c_function_decl([b4_prefix[push_parse]], [[int]], - [[b4_prefix[pstate *yyps]], [[yyps]]]b4_pure_if([, - [[[int yypushed_char]], [[yypushed_char]]], - [[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([, - [[[YYLTYPE const *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [, + [[b4_prefix[pstate *ps]], [[ps]]]b4_pure_if([, + [[[int pushed_char]], [[pushed_char]]], + [[b4_api_PREFIX[STYPE const *pushed_val]], [[pushed_val]]]b4_locations_if([, + [[b4_api_PREFIX[LTYPE const *pushed_loc]], [[pushed_loc]]]])])m4_ifset([b4_parse_param], [, b4_parse_param])) b4_pull_if([b4_c_function_decl([b4_prefix[pull_parse]], [[int]], - [[b4_prefix[pstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [, + [[b4_prefix[pstate *ps]], [[ps]]]m4_ifset([b4_parse_param], [, b4_parse_param]))]) b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]], [[[void]], []]) b4_c_function_decl([b4_prefix[pstate_delete]], [[void]], - [[b4_prefix[pstate *yyps]], [[yyps]]])dnl + [[b4_prefix[pstate *ps]], [[ps]]])dnl ]) # b4_declare_yyparse_ diff --git a/doc/bison.texi b/doc/bison.texi index a53b52fc..15ee270e 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -5790,9 +5790,9 @@ function is available if either the @code{%define api.push-pull push} or @xref{Push Decl, ,A Push Parser}. @deftypefun int yypush_parse (yypstate *yyps) -The value returned by @code{yypush_parse} is the same as for yyparse with the -following exception. @code{yypush_parse} will return YYPUSH_MORE if more input -is required to finish parsing the grammar. +The value returned by @code{yypush_parse} is the same as for yyparse with +the following exception: it returns @code{YYPUSH_MORE} if more input is +required to finish parsing the grammar. @end deftypefun @node Pull Parser Function diff --git a/tests/calc.at b/tests/calc.at index 58e7e895..e4cb07f1 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -59,7 +59,7 @@ int ]AT_NAME_PREFIX[parse (]AT_PARAM_IF([semantic_value *result, int *count]))[ { ]AT_NAME_PREFIX[::parser parser]AT_PARAM_IF([ (result, count)])[; -#if YYDEBUG +#if ]AT_API_PREFIX[DEBUG parser.set_debug_level (1); #endif return parser.parse (); @@ -113,7 +113,7 @@ static int get_char (]AT_YYLEX_FORMALS[); static void unget_char (]AT_YYLEX_PRE_FORMALS[ int c); ]AT_LOCATION_IF([ -static YYLTYPE last_yylloc; +static AT_YYLTYPE last_yylloc; ])[ static int get_char (]AT_YYLEX_FORMALS[) @@ -264,15 +264,11 @@ AT_SKEL_CC_IF( %code provides { -#include -/* The input. */ -extern FILE *input; -extern semantic_value global_result; -extern int global_count;]AT_SKEL_CC_IF([[ -#ifndef YYLTYPE -# define YYLTYPE ]AT_NAME_PREFIX[::parser::location_type -#endif -]])[ + #include + /* The input. */ + extern FILE *input; + extern semantic_value global_result; + extern int global_count; } %code @@ -285,7 +281,7 @@ FILE *input; static int power (int base, int exponent); ]AT_SKEL_CC_IF(, -[static void yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ]) +[static void yyerror (AT_YYERROR_ARG_LOC_IF([AT_YYLTYPE *llocp, ]) AT_PARAM_IF([semantic_value *result, int *count, ]) const char *s );])[ @@ -373,7 +369,7 @@ power (int base, int exponent) AT_YYERROR_DEFINE], [/* A C error reporting function. */ static void -yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ]) +yyerror (AT_YYERROR_ARG_LOC_IF([AT_YYLTYPE *llocp, ]) AT_PARAM_IF([semantic_value *result, int *count, ]) const char *s) { @@ -632,14 +628,16 @@ AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %locations]) AT_CHECK_CALC_LALR([%error-verbose %locations]) AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR([%error-verbose %locations %defines %define api.prefix "calc" %verbose %yacc]) 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 %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 %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) +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}]) # ----------------------- # @@ -661,6 +659,7 @@ AT_CHECK_CALC_GLR() AT_CHECK_CALC_GLR([%defines]) AT_CHECK_CALC_GLR([%locations]) AT_CHECK_CALC_GLR([%name-prefix "calc"]) +AT_CHECK_CALC_GLR([%define api.prefix "calc"]) AT_CHECK_CALC_GLR([%verbose]) AT_CHECK_CALC_GLR([%yacc]) AT_CHECK_CALC_GLR([%error-verbose]) @@ -672,10 +671,12 @@ AT_CHECK_CALC_GLR([%error-verbose %locations %defines %name-prefix "calc" %verbo AT_CHECK_CALC_GLR([%debug]) AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc]) AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) +AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) # ----------------------------- # @@ -697,11 +698,13 @@ m4_define([AT_CHECK_CALC_LALR1_CC], AT_CHECK_CALC_LALR1_CC([]) AT_CHECK_CALC_LALR1_CC([%define location_type Span]) AT_CHECK_CALC_LALR1_CC([%error-verbose %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR1_CC([%error-verbose %define api.prefix "calc" %verbose %yacc]) AT_CHECK_CALC_LALR1_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %define api.prefix "calc" %verbose %yacc]) AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) +AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) @@ -724,6 +727,7 @@ m4_define([AT_CHECK_CALC_GLR_CC], AT_CHECK_CALC_GLR_CC([]) AT_CHECK_CALC_GLR_CC([%define location_type Span]) AT_CHECK_CALC_GLR_CC([%error-verbose %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_GLR_CC([%error-verbose %define api.prefix "calc" %verbose %yacc]) AT_CHECK_CALC_GLR_CC([%debug]) AT_CHECK_CALC_GLR_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc]) @@ -731,3 +735,4 @@ AT_CHECK_CALC_GLR_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc]) AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc]) AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) +AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) diff --git a/tests/headers.at b/tests/headers.at index 70891292..07f1d1bc 100644 --- a/tests/headers.at +++ b/tests/headers.at @@ -124,15 +124,16 @@ AT_CLEANUP AT_SETUP([Several parsers]) -# AT_DATA_GRAMMAR_SEVERAL([PREFIX], [DIRECTIVES]) -# ----------------------------------------------- +# AT_TEST([PREFIX], [DIRECTIVES]) +# ------------------------------- # Generate and compile to *.o. Make sure there is no YY* nor yy* in # the header (but YYDEBUG and YYPARSE_PARAM). -m4_define([AT_DATA_GRAMMAR_SEVERAL], +m4_pushdef([AT_TEST], [AT_BISON_OPTION_PUSHDEFS([%define api.prefix "$1_" $2]) AT_DATA_GRAMMAR([$1.AT_SKEL_CC_IF([yy], [y])], [[%define api.prefix "$1_" $2 +%error-verbose %union { int integer; @@ -150,6 +151,8 @@ exp: | 'x' '4' { printf ("x4\n"); } | 'x' '5' { printf ("x5\n"); } | 'x' '6' { printf ("x6\n"); } +| 'x' '7' { printf ("x7\n"); } +| 'x' '8' { printf ("x8\n"); } ; %% @@ -162,15 +165,20 @@ AT_BISON_CHECK([-d -o AT_SKEL_CC_IF([$1.cc $1.yy], [$1.c $1.y])]) AT_SKEL_CC_IF([], [AT_CHECK([$EGREP yy $1.h], [1])]) -# Ignore comments. Ignore YYPARSE_PARAM. YYDEBUG (not renamed) can be -# read, but not changed. +# Ignore comments. Ignore YYPARSE_PARAM (obsolete) and +# YYPUSH_MORE(_DEFINED)? (whose definition is constant). +# +# YYDEBUG (not renamed) can be read, but not changed. AT_CHECK([[sed -ne 's,/\*[^*]*\*/,,g;s,//.*,,' \ -e '/YY/p' ]$1.AT_SKEL_CC_IF([hh], [h])[ | - $EGREP -wv '(YYPARSE_PARAM|defined YYDEBUG|if YYDEBUG)']], + $EGREP -wv 'YY(PARSE_PARAM|PUSH_MORE(_DEFINED)?)|(defined|if) YYDEBUG']], [1]) AT_LANG_COMPILE([$1.o]) + +AT_CHECK([[echo "$1" >>expout]]) + AT_BISON_OPTION_POPDEFS -]) +])# AT_TEST AT_DATA([main.cc], [AT_DATA_SOURCE_PROLOGUE @@ -180,47 +188,51 @@ AT_DATA([main.cc], #include "x2.h" #include "x3.h" #include "x4.h" + #include "x6.h" + #include "x7.h" + #include "x8.h" } #include "x5.hh" //#include "x6.hh" -#define ECHO(S) std::cerr << #S": " << S << std::endl; +#define RUN(S) \ + do { \ + int res = S; \ + if (res) \ + std::cerr << #S": " << res << std::endl; \ + } while (false) int main (void) { - ECHO(x1_parse()); - ECHO(x2_parse()); - ECHO(x3_parse()); - ECHO(x4_parse()); + RUN(x1_parse()); + RUN(x2_parse()); + RUN(x3_parse()); + RUN(x4_parse()); x5_::parser p5; - ECHO(p5.parse()); + RUN(p5.parse()); + RUN(x6_parse()); + RUN(x7_parse()); + RUN(x8_parse()); // x6_::parser p6; -// ECHO(p6.parse()); +// RUN(p6.parse()); return 0; } -]]) +]])# main.cc -AT_DATA_GRAMMAR_SEVERAL([x1], []) -AT_DATA_GRAMMAR_SEVERAL([x2], [%locations %debug]) -AT_DATA_GRAMMAR_SEVERAL([x3], [%glr-parser]) -AT_DATA_GRAMMAR_SEVERAL([x4], [%locations %debug %glr-parser]) -AT_DATA_GRAMMAR_SEVERAL([x5], [%locations %debug %language "c++"]) -#AT_DATA_GRAMMAR_SEVERAL([x5], [%locations %language "c++" %glr-parser]) +AT_TEST([x1], []) +AT_TEST([x2], [%locations %debug]) +AT_TEST([x3], [%glr-parser]) +AT_TEST([x4], [%locations %debug %glr-parser]) +AT_TEST([x5], [%locations %debug %language "c++"]) +AT_TEST([x6], [%define api.pure]) +AT_TEST([x7], [%define api.push-pull both]) +AT_TEST([x8], [%define api.pure %define api.push-pull both]) +#AT_TEST([x5], [%locations %language "c++" %glr-parser]) -AT_COMPILE_CXX([parser], [x1.o x2.o x3.o x4.o x5.o main.cc]) -AT_CHECK([./parser], [0], -[[x1 -x2 -x3 -x4 -x5 -]], -[[x1_parse(): 0 -x2_parse(): 0 -x3_parse(): 0 -x4_parse(): 0 -p5.parse(): 0 -]]) +AT_COMPILE_CXX([parser], [[x[1-8].o main.cc]]) +AT_CHECK([./parser], [0], [[expout]]) + +m4_popdef([AT_TEST]) AT_CLEANUP diff --git a/tests/local.at b/tests/local.at index 7a981c6d..e02bce0c 100644 --- a/tests/local.at +++ b/tests/local.at @@ -339,7 +339,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([YYLTYPE *llocp, ])[const char *msg]])[]dnl +[c], [AT_YYERROR_ARG_LOC_IF([AT_YYLTYPE *llocp, ])[const char *msg]])[]dnl ]) m4_define([AT_YYERROR_PROTOTYPE], From 32ae07efde7db078d48e95f29778e2227b0cf01b Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 5 Jul 2012 12:33:42 +0200 Subject: [PATCH 06/12] api.prefix: incompatible with %name-prefix. * data/bison.m4: Make it incompatible. * tests/input.at: Check that it is. --- data/bison.m4 | 8 ++++++++ tests/input.at | 31 ++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/data/bison.m4 b/data/bison.m4 index 9a66d884..178134a4 100644 --- a/data/bison.m4 +++ b/data/bison.m4 @@ -576,3 +576,11 @@ m4_define_default([b4_parse_param], []) # The initial column and line. m4_define_default([b4_location_initial_column], [1]) m4_define_default([b4_location_initial_line], [1]) + +# Sanity checks. +b4_percent_define_ifdef([api.prefix], +[m4_ifdef([b4_prefix], +[b4_complain_at(b4_percent_define_get_loc([api.prefix]), + [['%s' and '%s' cannot be used together]], + [%name-prefix], + [%define api.prefix])])]) diff --git a/tests/input.at b/tests/input.at index 0ed8635f..836ff6d6 100644 --- a/tests/input.at +++ b/tests/input.at @@ -69,7 +69,7 @@ AT_CLEANUP # _AT_UNUSED_VALUES_DECLARATIONS() -# -------------------------------------------- +# -------------------------------- # Generate the token, type, and destructor # declarations for the unused values tests. @@ -1340,3 +1340,32 @@ input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar AT_BISON_CHECK([[-Werror,no-all,yacc input.y]], [[1]], [[]], [[experr]]) AT_CLEANUP + + +## ------------------------------------------------------ ## +## %name-prefix and %define api.prefix are incompatible. ## +## ------------------------------------------------------ ## + +AT_SETUP([[%name-prefix and %define api.prefix are incompatible]]) + +# AT_TEST(DIRECTIVES, OPTIONS, ERROR-LOCATION) +# -------------------------------------------- +m4_pushdef([AT_TEST], +[AT_DATA([[input.y]], +[[$1 +%% +exp:; +]]) +AT_BISON_CHECK([[$2 input.y]], [[1]], [[]], +[[$3: '%name-prefix' and '%define api.prefix' cannot be used together +]]) +]) + +AT_TEST([%define api.prefix foo %name-prefix "bar"], [], [input.y:1.9-18]) +AT_TEST([], [-Dapi.prefix=foo -p bar], [:2]) +AT_TEST([%name-prefix "bar"], [-Dapi.prefix=foo], [:2]) +AT_TEST([%define api.prefix foo], [-p bar], [input.y:1.9-18]) + +m4_popdef([AT_TEST]) + +AT_CLEANUP From 916f26b65ad083aa2ef49cb11041c0c183460e99 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 5 Jul 2012 14:27:09 +0200 Subject: [PATCH 07/12] tests: fix SKIP_IF for Java. * tests/local.at (AT_JAVA_COMPILE): here. --- tests/local.at | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/local.at b/tests/local.at index e02bce0c..35d406fe 100644 --- a/tests/local.at +++ b/tests/local.at @@ -596,7 +596,8 @@ AT_CHECK(m4_join([ ], # is not installed. m4_define([AT_JAVA_COMPILE], [AT_KEYWORDS(java) -AT_SKIP_IF([[test -z "$CONF_JAVA$CONF_JAVAC"]]) +AT_SKIP_IF([[test -z "$CONF_JAVAC"]]) +AT_SKIP_IF([[test -z "$CONF_JAVA"]]) AT_CHECK([[$SHELL ../../../javacomp.sh ]$1], [[0]], [ignore], [ignore])]) From 7a9e6d65ea4e91760ad7a44c00ccbe422621b926 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 5 Jul 2012 15:24:34 +0200 Subject: [PATCH 08/12] gnulib: update. * gnulib/build-aux/do-release-commit-and-tag: Fix. --- gnulib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnulib b/gnulib index 31ec8584..be2b0391 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit 31ec8584048ce391f1ff4fb26fde3c7389c656f3 +Subproject commit be2b039116133e5fd07e07c5d272b8adb91d72b2 From 813f7d34824153ac3259fdd34fce5710d3b7606c Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 5 Jul 2012 16:09:17 +0200 Subject: [PATCH 09/12] build: fix gen-ChangeLog call. * Makefile.am: Be sure to catch errors, and fix option name --- Makefile.am | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Makefile.am b/Makefile.am index eef413fc..d5d3db28 100644 --- a/Makefile.am +++ b/Makefile.am @@ -66,13 +66,14 @@ update-package-copyright-year: gen_start_date = 2012-01-16 .PHONY: gen-ChangeLog gen-ChangeLog: - $(AM_V_GEN)if test -d $(srcdir)/.git; then \ - $(top_srcdir)/build-aux/gitlog-to-changelog \ - --strip-tab \ - --strip-cherry-picked \ - --no-cluster \ - --amend=$(srcdir)/build-aux/git-log-fix \ - --since=$(gen_start_date) > $(distdir)/cl-t; \ - rm -f $(distdir)/ChangeLog; \ - mv $(distdir)/cl-t $(distdir)/ChangeLog; \ + $(AM_V_GEN)if test -d $(srcdir)/.git; then \ + cl=$(distdir)/ChangeLog && \ + rm -f $$cl.tmp && \ + $(top_srcdir)/build-aux/gitlog-to-changelog \ + --strip-tab \ + --strip-cherry-pick \ + --no-cluster \ + --amend=$(srcdir)/build-aux/git-log-fix \ + --since=$(gen_start_date) > $$cl.tmp && \ + mv -f $$cl.tmp $$cl; \ fi From 47977a7e741f138b6272a999b1d8b4d9b80afac8 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 5 Jul 2012 16:20:44 +0200 Subject: [PATCH 10/12] version 2.5.90 * NEWS: Record release date. --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index dfdbe24d..d266d9d5 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ GNU Bison NEWS -* Noteworthy changes in release ?.? (????-??-??) [?] +* Noteworthy changes in release 2.5.90 (2012-07-05) [beta] ** Future Changes From aca4ddc75daaf5a9d9ce8f52e15e1f9c0ebab741 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 5 Jul 2012 16:29:06 +0200 Subject: [PATCH 11/12] maint: post-release administrivia * NEWS: Add header line for next release. * .prev-version: Record previous version. * cfg.mk (old_NEWS_hash): Auto-update. --- .prev-version | 2 +- NEWS | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.prev-version b/.prev-version index 73462a5a..b042f94e 100644 --- a/.prev-version +++ b/.prev-version @@ -1 +1 @@ -2.5.1 +2.5.90 diff --git a/NEWS b/NEWS index d266d9d5..24f43d51 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ GNU Bison NEWS +* Noteworthy changes in release ?.? (????-??-??) [?] + + * Noteworthy changes in release 2.5.90 (2012-07-05) [beta] ** Future Changes From a59a6ddef4a130b16d619e561a5d9886e305ac36 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 6 Jul 2012 10:14:49 +0200 Subject: [PATCH 12/12] maint: update release instructions * README-hacking: here. --- README-hacking | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README-hacking b/README-hacking index 5fab96c1..d06d1389 100644 --- a/README-hacking +++ b/README-hacking @@ -249,7 +249,10 @@ that the skeletons insert into generated parsers, and check all occurrences of PACKAGE_COPYRIGHT_YEAR in configure.ac. ** Update NEWS, commit and tag. -See do-release-commit-and-tag in README-release. +See do-release-commit-and-tag in README-release. For a while, we used +beta names such as "2.6_rc1". Now that we use gnulib in the release +procedure, we must use "2.5.90", which has the additional benefit of +being properly sorted in "git tag -l". ** make alpha, beta, or stable See README-release.