]> git.saurik.com Git - bison.git/commitdiff
Merge remote-tracking branch 'origin/maint'
authorAkim Demaille <akim@lrde.epita.fr>
Tue, 19 Jun 2012 15:35:53 +0000 (17:35 +0200)
committerAkim Demaille <akim@lrde.epita.fr>
Tue, 19 Jun 2012 16:17:09 +0000 (18:17 +0200)
* origin/maint:
  maint: formatting changes.
  tests: support api.prefix.
  tests: pacify font-lock-mode.
  tests: remove test covered elsewhere.
  tests: factor the declaration/definition of yyerror and yylex.
  regen.
  tests: portability issues.
  tests: call the parser from another compilation unit.
  glr.c, yacc.c: declare yydebug in the header.
  skeletons: use header guards.
  tests: improve AT_FULL_COMPILE.
  tests: reorder.
  tests: strengthen the test on generated headers inclusion
  yacc.c: instead of duplicating y.tab.h inside y.tac.c, include it.
  yacc.c: factor.

Conflicts:
NEWS
data/glr.c
data/yacc.c
src/parse-gram.c
src/parse-gram.h
tests/conflicts.at
tests/regression.at

14 files changed:
1  2 
NEWS
data/c.m4
data/glr.c
data/glr.cc
data/yacc.c
tests/actions.at
tests/calc.at
tests/conflicts.at
tests/glr-regression.at
tests/input.at
tests/local.at
tests/named-refs.at
tests/regression.at
tests/torture.at

diff --combined NEWS
index 79fdb8ef5418cab9c0ecf2278c4866944dc256dd,9c5d67b7e52fa246e9593fde2a6b4a95a10c2580..7b75972c4ace5457e59ee46acdc29c20c208ab9e
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -2,72 -2,45 +2,113 @@@ GNU Bison NEW
  
  * Noteworthy changes in release ?.? (????-??-??) [?]
  
-       %lex-param   {arg1_type *arg1}
-       %lex-param   {arg2_type *arg2}
-       %parse-param {arg1_type *arg1}
-       %parse-param {arg2_type *arg2}
 +** Additional yylex/yyparse arguments
 +
 +  The new directive %param declare additional argument to both yylex
 +  and yyparse.  The %lex-param, %parse-param, and %param directives
 +  support one or more arguments.  Instead of
 +
-       %param {arg1_type *arg1} {arg2_type *arg2}
++    %lex-param   {arg1_type *arg1}
++    %lex-param   {arg2_type *arg2}
++    %parse-param {arg1_type *arg1}
++    %parse-param {arg2_type *arg2}
 +
 +  one may now declare
 +
-       %token FILE for ERROR
-       %define api.tokens.prefix "TOK_"
-       %%
-       start: FILE for ERROR;
++    %param {arg1_type *arg1} {arg2_type *arg2}
 +
 +** Java skeleton improvements
 +
 +  The constants for token names were moved to the Lexer interface.
 +  Also, it is possible to add code to the parser's constructors using
 +  "%code init" and "%define init_throws".
 +
 +** C++ skeleton improvements
 +
 +  The C++ parser features a syntax_error exception, which can be
 +  thrown from the scanner or from user rules to raise syntax errors.
 +  This facilitates reporting errors caught in sub-functions (e.g.,
 +  rejecting too large integral literals from a conversion function
 +  used by the scanner, or rejecting invalid combinations from a
 +  factory invoked by the user actions).
 +
 +** Variable api.tokens.prefix
 +
 +  The variable api.tokens.prefix changes the way tokens are identified in
 +  the generated files.  This is especially useful to avoid collisions
 +  with identifiers in the target language.  For instance
 +
++    %token FILE for ERROR
++    %define api.tokens.prefix "TOK_"
++    %%
++    start: FILE for ERROR;
 +
 +  will generate the definition of the symbols TOK_FILE, TOK_for, and
 +  TOK_ERROR in the generated sources.  In particular, the scanner must
 +  use these prefixed token names, although the grammar itself still
 +  uses the short names (as in the sample rule given above).
 +
 +** Variable api.namespace
 +
 +  The "namespace" variable is renamed "api.namespace".  Backward
 +  compatibility is ensured, but upgrading is recommended.
 +
 +** Variable parse.error
 +
 +  The variable error controls the verbosity of error messages.  The
 +  use of the %error-verbose directive is deprecated in favor of
 +  %define parse.error "verbose".
 +
 +** Semantic predicates
 +
 +  The new, experimental, semantic-predicate feature allows actions of
 +  the form %?{ BOOLEAN-EXPRESSION }, which cause syntax errors (as for
 +  YYERROR) if the expression evaluates to 0, and are evaluated immediately
 +  in GLR parsers, rather than being deferred.  The result is that they
 +  allow the programmer to prune possible parses based on the values of
 +  runtime expressions.
 +
++* Noteworthy changes in release ?.? (????-??-??) [?]
++
+ ** Future changes:
+   The next major release will drop support for generating parsers in K&R C,
+   and remove the definition of yystype (removal announced since Bison
+   1.875).
+ ** The generated header is included (yacc.c)
+   Instead of duplicating the content of the generated header (definition of
+   YYSTYPE, yyltype etc.), the generated parser now includes it, as was
+   already the case for GLR or C++ parsers.
+ ** Headers (yacc.c, glr.c, glr.cc)
+ *** Guards
+   The generated headers are now guarded, as is already the case for C++
+   parsers (lalr1.cc).  For intance, with --defines=foo.h:
+     #ifndef YY_FOO_H
+     # define YY_FOO_H
+     ...
+     #endif /* !YY_FOO_H  */
+ *** New declarations
+   The generated header now declares yydebug and yyparse.  Both honor
+   --name-prefix=bar_, and yield
+     int bar_parse (void);
+   rather than
+     #define yyparse bar_parse
+     int yyparse (void);
+   in order to facilitate the inclusion of several parser headers inside a
+   single compilation unit.
  * Noteworthy changes in release 2.5.1 (2012-06-05) [stable]
  
  ** Future changes:
    The header files such as "parser.hh", "location.hh", etc. used a constant
    name for preprocessor guards, for instance:
  
 -    #ifndef BISON_LOCATION_HH
 -    # define BISON_LOCATION_HH
 -    ...
 -    #endif // !BISON_LOCATION_HH
 +  #ifndef BISON_LOCATION_HH
 +  # define BISON_LOCATION_HH
 +  ...
 +  #endif // !BISON_LOCATION_HH
  
    The inclusion guard is now computed from "PREFIX/FILE-NAME", where lower
    case characters are converted to upper case, and series of
  
    With "bison -o lang++/parser.cc", "location.hh" would now include:
  
 -    #ifndef YY_LANG_LOCATION_HH
 -    # define YY_LANG_LOCATION_HH
 -    ...
 -    #endif // !YY_LANG_LOCATION_HH
 +  #ifndef YY_LANG_LOCATION_HH
 +  # define YY_LANG_LOCATION_HH
 +  ...
 +  #endif // !YY_LANG_LOCATION_HH
  
  *** C++ locations:
  
    to use it.  If, for instance, your location structure has "first"
    and "last" members, instead of
  
 -    # define YYLLOC_DEFAULT(Current, Rhs, N)                             \
 -      do                                                                 \
 -        if (N)                                                           \
 -          {                                                              \
 -            (Current).first = (Rhs)[1].location.first;                   \
 -            (Current).last  = (Rhs)[N].location.last;                    \
 -          }                                                              \
 -        else                                                             \
 -          {                                                              \
 -            (Current).first = (Current).last = (Rhs)[0].location.last;   \
 -          }                                                              \
 -      while (false)
 +      # define YYLLOC_DEFAULT(Current, Rhs, N)                             \
 +        do                                                                 \
 +          if (N)                                                           \
 +            {                                                              \
 +              (Current).first = (Rhs)[1].location.first;                   \
 +              (Current).last  = (Rhs)[N].location.last;                    \
 +            }                                                              \
 +          else                                                             \
 +            {                                                              \
 +              (Current).first = (Current).last = (Rhs)[0].location.last;   \
 +            }                                                              \
 +        while (false)
  
    use:
  
 -    # define YYLLOC_DEFAULT(Current, Rhs, N)                             \
 -      do                                                                 \
 -        if (N)                                                           \
 -          {                                                              \
 -            (Current).first = YYRHSLOC (Rhs, 1).first;                   \
 -            (Current).last  = YYRHSLOC (Rhs, N).last;                    \
 -          }                                                              \
 -        else                                                             \
 -          {                                                              \
 -            (Current).first = (Current).last = YYRHSLOC (Rhs, 0).last;   \
 -          }                                                              \
 -      while (false)
 +      # define YYLLOC_DEFAULT(Current, Rhs, N)                             \
 +        do                                                                 \
 +          if (N)                                                           \
 +            {                                                              \
 +              (Current).first = YYRHSLOC (Rhs, 1).first;                   \
 +              (Current).last  = YYRHSLOC (Rhs, N).last;                    \
 +            }                                                              \
 +          else                                                             \
 +            {                                                              \
 +              (Current).first = (Current).last = YYRHSLOC (Rhs, 0).last;   \
 +            }                                                              \
 +        while (false)
  
  ** YYLLOC_DEFAULT in C++:
  
  ** Incorrect "Token not used"
    On a grammar such as
  
 -    %token useless useful
 -    %%
 -    exp: '0' %prec useful;
 +           %token useless useful
 +           %%
 +           exp: '0' %prec useful;
  
    where a token was used to set the precedence of the last rule,
    bison reported both "useful" and "useless" as useless tokens.
    the user symbol is used in the reports, the graphs, and the verbose
    error messages instead of "$end", which remains being the default.
    For instance
 -    %token MYEOF 0
 +     %token MYEOF 0
    or
 -    %token MYEOF 0 "end of file"
 +     %token MYEOF 0 "end of file"
  
  ** Semantic parser
    This old option, which has been broken for ages, is removed.
    Previous versions don't complain when there is a type clash on
    the default action if the rule has a mid-rule action, such as in:
  
 -    %type <foo> bar
 -    %%
 -    bar: '0' {} '0';
 +      %type <foo> bar
 +      %%
 +      bar: '0' {} '0';
  
    This is fixed.
  
diff --combined data/c.m4
index 2b7e9d63c9523372a5a78807e56eb1ec36db8f7c,78b123252833690f0df1d8aa44611ec32e8deb07..2601d561945d0b6adc35c888da540742f9a1ea5f
+++ b/data/c.m4
@@@ -48,34 -48,11 +48,34 @@@ m4_define([b4_cpp_guard_close]
  ## Identification.  ##
  ## ---------------- ##
  
 -# b4_comment(TEXT)
 -# ----------------
 -m4_define([b4_comment], [/* m4_bpatsubst([$1], [
 -], [
 -   ])  */])
 +# b4_comment_(TEXT, OPEN, CONTINUE, END)
 +# -------------------------------------
 +# Put TEXT in comment.  Avoid trailing spaces: don't indent empty lines.
 +# Avoid adding indentation to the first line, as the indentation comes
 +# from OPEN.  That's why we don't patsubst([$1], [^\(.\)], [   \1]).
 +#
 +# Prefix all the output lines with PREFIX.
 +m4_define([b4_comment_], [$2[]m4_bpatsubst([$1], [
 +\(.\)], [
 +$3\1])$4])
 +
 +
 +# b4_c_comment(TEXT, [PREFIX])
 +# ----------------------------
 +# Put TEXT in comment.  Avoid trailing spaces: don't indent empty lines.
 +# Avoid adding indentation to the first line, as the indentation comes
 +# from "/*".  That's why we don't patsubst([$1], [^\(.\)], [   \1]).
 +#
 +# Prefix all the output lines with PREFIX.
 +m4_define([b4_c_comment],
 +[b4_comment_([$1], [$2/* ], [$2   ], [$2  */])])
 +
 +
 +# b4_comment(TEXT, [PREFIX])
 +# --------------------------
 +# By default, C comments.
 +m4_define([b4_comment], [b4_c_comment($@)])
 +
  
  # b4_identification
  # -----------------
@@@ -102,7 -79,7 +102,7 @@@ m4_define([b4_identification]
  #define YYPULL ]b4_pull_flag])[
  
  /* Using locations.  */
 -#define YYLSP_NEEDED ]b4_locations_flag[
 +#define YYLSP_NEEDED ]b4_locations_if([1], [0])[
  ]])
  
  
@@@ -147,13 -124,11 +147,13 @@@ m4_popdef([$2])dn
  m4_popdef([$1])dnl
  ])])
  
 -# b4_parse_param_use
 -# ------------------
 -# `YYUSE' all the parse-params.
 +# b4_parse_param_use([VAL], [LOC])
 +# --------------------------------
 +# `YYUSE' VAL, LOC if locations are enabled, and all the parse-params.
  m4_define([b4_parse_param_use],
 -[b4_parse_param_for([Decl], [Formal], [  YYUSE (Formal);
 +[m4_ifvaln([$1], [  YYUSE([$1]);])dnl
 +b4_locations_if([m4_ifvaln([$2], [  YYUSE ([$2]);])])dnl
 +b4_parse_param_for([Decl], [Formal], [  YYUSE (Formal);
  ])dnl
  ])
  
@@@ -175,7 -150,7 +175,7 @@@ m4_define([b4_int_type]
  
         m4_eval([0 <= $1]),                [1], [unsigned int],
  
 -                                             [int])])
 +                                               [int])])
  
  
  # b4_int_type_for(NAME)
@@@ -224,16 -199,6 +224,16 @@@ m4_define([b4_null_define]
  # Return a null pointer constant.
  m4_define([b4_null], [YY_NULL])
  
 +# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
 +# -------------------------------------------------------------
 +# Define "yy<TABLE-NAME>" which contents is CONTENT.
 +m4_define([b4_integral_parser_table_define],
 +[m4_ifvaln([$3], [b4_c_comment([$3], [  ])])dnl
 +static const b4_int_type_for([$2]) yy$1[[]] =
 +{
 +  $2
 +};dnl
 +])
  
  
  ## ------------------------- ##
  # -----------------------------------------
  # Output the definition of this token as #define.
  m4_define([b4_token_define],
 -[#define $1 $2
 +[#define b4_percent_define_get([api.tokens.prefix])$1 $2
  ])
  
  
@@@ -262,7 -227,7 +262,7 @@@ m4_map([b4_token_define], [$@])]
  # ---------------------------------------
  # Output the definition of this token as an enum.
  m4_define([b4_token_enum],
 -[$1 = $2])
 +[b4_percent_define_get([api.tokens.prefix])$1 = $2])
  
  
  # b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
@@@ -278,7 -243,7 +278,7 @@@ m4_define([b4_token_enums]
     enum yytokentype {
  m4_map_sep([     b4_token_enum], [,
  ],
 -         [$@])
 +           [$@])
     };
  #endif
  ])])
@@@ -293,21 -258,6 +293,21 @@@ m4_define([b4_token_enums_defines]
  ])
  
  
 +## ----------------- ##
 +## Semantic Values.  ##
 +## ----------------- ##
 +
 +
 +# b4_symbol_value(VAL, [TYPE])
 +# ----------------------------
 +# Given a semantic value VAL ($$, $1 etc.), extract its value of type
 +# TYPE if TYPE is given, otherwise just return VAL.  The result can be
 +# used safetly, it is put in parens to avoid nasty precedence issues.
 +# TYPE is *not* put in braces, provide some if needed.
 +m4_define([b4_symbol_value],
 +[($1[]m4_ifval([$2], [.$2]))])
 +
 +
  
  ## --------------------------------------------- ##
  ## Defining C functions in both K&R and ANSI-C.  ##
@@@ -357,7 -307,7 +357,7 @@@ $1 (b4_c_ansi_formals(m4_shift2($@)))[]
  m4_define([b4_c_ansi_formals],
  [m4_if([$#], [0], [void],
         [$#$1], [1], [void],
 -             [m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
 +               [m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
  
  m4_define([b4_c_ansi_formal],
  [$1])
@@@ -378,9 -328,9 +378,9 @@@ m4_define([b4_c_knr_formal_name]
  # Output the K&R argument declarations.
  m4_define([b4_c_knr_formal_decls],
  [m4_map_sep([b4_c_knr_formal_decl],
 -          [
 +            [
  ],
 -          [$@])])
 +            [$@])])
  
  m4_define([b4_c_knr_formal_decl],
  [    $1;])
  # -----------------------------------------------------------
  # Declare the function NAME.
  m4_define([b4_c_function_decl],
 -[#if defined __STDC__ || defined __cplusplus
 +[#if b4_c_modern
  b4_c_ansi_function_decl($@)
  #else
  $2 $1 ();
@@@ -455,17 -405,24 +455,17 @@@ m4_define([b4_sync_start], [[#]line $1 
  m4_define([b4_case],
  [  case $1:
  $2
 +b4_syncline([@oline@], [@ofile@])
      break;])
  
 -# b4_symbol_actions(FILENAME, LINENO,
 -#                   SYMBOL-TAG, SYMBOL-NUM,
 -#                   SYMBOL-ACTION, SYMBOL-TYPENAME)
 -# -------------------------------------------------
 -m4_define([b4_symbol_actions],
 -[m4_pushdef([b4_dollar_dollar],
 -   [m4_ifval([$6], [(yyvaluep->$6)], [(*yyvaluep)])])dnl
 -m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl
 -      case $4: /* $3 */
 -b4_syncline([$2], [$1])
 -      $5;
 +
 +# b4_predicate_case(LABEL, CONDITIONS)
 +# ------------------------------------
 +m4_define([b4_predicate_case],
 +[  case $1:
 +    if (! ($2)) YYERROR;
  b4_syncline([@oline@], [@ofile@])
 -      break;
 -m4_popdef([b4_at_dollar])dnl
 -m4_popdef([b4_dollar_dollar])dnl
 -])
 +    break;])
  
  
  # b4_yydestruct_generate(FUNCTION-DECLARATOR)
@@@ -487,16 -444,20 +487,16 @@@ m4_define_default([b4_yydestruct_genera
  b4_locations_if(            [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl
  m4_ifset([b4_parse_param], [, b4_parse_param]))[
  {
 -  YYUSE (yyvaluep);
 -]b4_locations_if([  YYUSE (yylocationp);
 -])dnl
 -b4_parse_param_use[]dnl
 -[
 -  if (!yymsg)
 +]b4_parse_param_use([yyvaluep], [yylocationp])dnl
 +[  if (!yymsg)
      yymsg = "Deleting";
    YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
  
    switch (yytype)
      {
 -]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
 -      default:
 -      break;
 +]b4_symbol_foreach([b4_symbol_destructor])dnl
 +[      default:
 +        break;
      }
  }]dnl
  ])
@@@ -516,28 -477,30 +516,28 @@@ m4_define_default([b4_yy_symbol_print_g
  /*ARGSUSED*/
  ]$1([yy_symbol_value_print],
      [static void],
 -             [[FILE *yyoutput],                       [yyoutput]],
 -             [[int yytype],                           [yytype]],
 -             [[YYSTYPE const * const yyvaluep],       [yyvaluep]][]dnl
 +               [[FILE *yyoutput],                       [yyoutput]],
 +               [[int yytype],                           [yytype]],
 +               [[YYSTYPE const * const yyvaluep],       [yyvaluep]][]dnl
  b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
  m4_ifset([b4_parse_param], [, b4_parse_param]))[
  {
    FILE *yyo = yyoutput;
 -  YYUSE (yyo);
 -  if (!yyvaluep)
 -    return;
 -]b4_locations_if([  YYUSE (yylocationp);
 -])dnl
 -b4_parse_param_use[]dnl
 -[# ifdef YYPRINT
 +]b4_parse_param_use([yyo], [yylocationp])dnl
 +[  if (!yyvaluep)
 +    return;]
 +dnl glr.c does not feature yytoknum.
 +m4_if(b4_skeleton, ["yacc.c"],
 +[[# ifdef YYPRINT
    if (yytype < YYNTOKENS)
      YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
 -# else
 -  YYUSE (yyoutput);
  # endif
 -  switch (yytype)
 +]])dnl
 +[  switch (yytype)
      {
 -]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
 +]b4_symbol_foreach([b4_symbol_printer])dnl
  [      default:
 -      break;
 +        break;
      }
  }
  
  
  ]$1([yy_symbol_print],
      [static void],
 -             [[FILE *yyoutput],                       [yyoutput]],
 -             [[int yytype],                           [yytype]],
 -             [[YYSTYPE const * const yyvaluep],       [yyvaluep]][]dnl
 +               [[FILE *yyoutput],                       [yyoutput]],
 +               [[int yytype],                           [yytype]],
 +               [[YYSTYPE const * const yyvaluep],       [yyvaluep]][]dnl
  b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
  m4_ifset([b4_parse_param], [, b4_parse_param]))[
  {
@@@ -604,3 -567,15 +604,15 @@@ typedef struct YYLTYP
  # define YYLTYPE_IS_TRIVIAL 1
  #endif]])
  ])
 -# define YYDEBUG ]b4_debug_flag[
+ # b4_declare_yydebug
+ # ------------------
+ m4_define([b4_declare_yydebug],
+ [[/* Enabling traces.  */
+ #ifndef YYDEBUG
++# define YYDEBUG ]b4_parse_trace_if([1], [0])[
+ #endif
+ #if YYDEBUG
+ extern int ]b4_prefix[debug;
+ #endif][]dnl
+ ])
diff --combined data/glr.c
index 1463a9a7f6def1f343befbcd466b2dfe4ce4b9fa,9bbf9a72e936aae0092fc18bf0598f792adc11c3..f4efca2c02a4379bd40484c944ce21b5f4219c19
@@@ -123,15 -123,7 +123,15 @@@ m4_define([b4_locuser_args]
  # --------------------
  # Expansion of $<TYPE>$.
  m4_define([b4_lhs_value],
 -[((*yyvalp)[]m4_ifval([$1], [.$1]))])
 +[b4_symbol_value([(*yyvalp)], [$1])])
 +
 +
 +# b4_rhs_data(RULE-LENGTH, NUM)
 +# -----------------------------
 +# Expand to the semantic stack place that contains value and location
 +# of symbol number NUM in a rule of length RULE-LENGTH.
 +m4_define([b4_rhs_data],
 +[((yyGLRStackItem const *)yyvsp)@{YYFILL (b4_subtract([$2], [$1]))@}.yystate])
  
  
  # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
  # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
  # symbols on RHS.
  m4_define([b4_rhs_value],
 -[(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3]))])
 +[b4_symbol_value([b4_rhs_data([$1], [$2]).yysemantics.yysval], [$3])])
  
  
  
@@@ -159,7 -151,7 +159,7 @@@ m4_define([b4_lhs_location]
  # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
  # on RHS.
  m4_define([b4_rhs_location],
 -[(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yyloc)])
 +[(b4_rhs_data([$1], [$2]).yyloc)])
  
  
  ## -------------- ##
  # Declaration that might either go into the header (if --defines)
  # or open coded in the parser body.
  m4_define([b4_shared_declarations],
- [b4_percent_code_get([[requires]])[
+ [b4_declare_yydebug[
+ ]b4_percent_code_get([[requires]])[
  ]b4_token_enums(b4_tokens)[
  ]b4_declare_yylstype[
+ ]b4_c_ansi_function_decl(b4_prefix[parse], [int], b4_parse_param)[
  ]b4_percent_code_get([[provides]])[]dnl
  ])
  
@@@ -211,19 -205,14 +213,14 @@@ m4_if(b4_prefix, [yy], []
  ]b4_null_define[
  
  ]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
 -               [b4_shared_declarations])[
 +              [b4_shared_declarations])[
  
- /* Enabling traces.  */
- #ifndef YYDEBUG
- # define YYDEBUG ]b4_parse_trace_if([1], [0])[
- #endif
  /* Enabling verbose error messages.  */
  #ifdef YYERROR_VERBOSE
  # undef YYERROR_VERBOSE
  # define YYERROR_VERBOSE 1
  #else
 -# define YYERROR_VERBOSE ]b4_error_verbose_flag[
 +# define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[
  #endif
  
  /* Enabling the token table.  */
@@@ -358,6 -347,19 +355,6 @@@ static const ]b4_int_type_for([b4_trans
  };
  
  #if YYDEBUG
 -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
 -   YYRHS.  */
 -static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
 -{
 -  ]b4_prhs[
 -};
 -
 -/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
 -static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
 -{
 -  ]b4_rhs[
 -};
 -
  /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
  static const ]b4_int_type_for([b4_rline])[ yyrline[] =
  {
@@@ -374,10 -376,17 +371,10 @@@ static const char *const yytname[] 
  };
  #endif
  
 -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 -static const ]b4_int_type_for([b4_r1])[ yyr1[] =
 -{
 -  ]b4_r1[
 -};
 +#define YYPACT_NINF ]b4_pact_ninf[
 +#define YYTABLE_NINF ]b4_table_ninf[
  
 -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
 -static const ]b4_int_type_for([b4_r2])[ yyr2[] =
 -{
 -  ]b4_r2[
 -};
 +]b4_parser_tables_define[
  
  /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none).  */
  static const ]b4_int_type_for([b4_dprec])[ yydprec[] =
@@@ -391,11 -400,41 +388,11 @@@ static const ]b4_int_type_for([b4_merge
    ]b4_merger[
  };
  
 -/* YYDEFACT[S] -- default reduction number in state S.  Performed when
 -   YYTABLE doesn't specify something else to do.  Zero means the default
 -   is an error.  */
 -static const ]b4_int_type_for([b4_defact])[ yydefact[] =
 +/* YYIMMEDIATE[RULE-NUM] -- True iff rule #RULE-NUM is not to be deferred, as
 +   in the case of predicates.  */
 +static const yybool yyimmediate[] =
  {
 -  ]b4_defact[
 -};
 -
 -/* YYPDEFGOTO[NTERM-NUM].  */
 -static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] =
 -{
 -  ]b4_defgoto[
 -};
 -
 -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
 -   STATE-NUM.  */
 -#define YYPACT_NINF ]b4_pact_ninf[
 -static const ]b4_int_type_for([b4_pact])[ yypact[] =
 -{
 -  ]b4_pact[
 -};
 -
 -/* YYPGOTO[NTERM-NUM].  */
 -static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] =
 -{
 -  ]b4_pgoto[
 -};
 -
 -/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
 -   positive, shift that token.  If negative, reduce the rule which
 -   number is the opposite.  If YYTABLE_NINF, syntax error.  */
 -#define YYTABLE_NINF ]b4_table_ninf[
 -static const ]b4_int_type_for([b4_table])[ yytable[] =
 -{
 -  ]b4_table[
 +  ]b4_immediate[
  };
  
  /* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
@@@ -416,10 -455,20 +413,7 @@@ dnl We probably ought to introduce a ty
  {
    ]b4_conflicting_rules[
  };
 -
 -static const ]b4_int_type_for([b4_check])[ yycheck[] =
 -{
 -  ]b4_check[
 -};
 -
 -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
 -   symbol of state STATE-NUM.  */
 -static const ]b4_int_type_for([b4_stos])[ yystos[] =
 -{
 -  ]b4_stos[
 -};
 -
  \f
- /* Prevent warning if -Wmissing-prototypes.  */
- ]b4_c_ansi_function_decl([yyparse], [int], b4_parse_param)[
  /* Error token number */
  #define YYTERROR 1
  
@@@ -497,12 -546,9 +491,12 @@@ static const int YYEMPTY = -2
  
  typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
  
 -#define YYCHK(YYE)                                                           \
 -   do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; }       \
 -   while (YYID (0))
 +#define YYCHK(YYE)                              \
 +  do {                                          \
 +    YYRESULTTAG yychk_flag = YYE;               \
 +    if (yychk_flag != yyok)                     \
 +      return yychk_flag;                        \
 +  } while (YYID (0))
  
  #if YYDEBUG
  
  # endif
  
  # define YYDPRINTF(Args)                        \
 -do {                                            \
 -  if (yydebug)                                  \
 -    YYFPRINTF Args;                             \
 -} while (YYID (0))
 +  do {                                          \
 +    if (yydebug)                                \
 +      YYFPRINTF Args;                           \
 +  } while (YYID (0))
  
  ]b4_yy_symbol_print_generate([b4_c_ansi_function_def])[
  
 -# define YY_SYMBOL_PRINT(Title, Type, Value, Location)          \
 -do {                                                            \
 -  if (yydebug)                                                  \
 -    {                                                           \
 -      YYFPRINTF (stderr, "%s ", Title);                         \
 -      yy_symbol_print (stderr, Type, Value]b4_locuser_args([Location])[);        \
 -      YYFPRINTF (stderr, "\n");                                 \
 -    }                                                           \
 -} while (YYID (0))
 +# define YY_SYMBOL_PRINT(Title, Type, Value, Location)                  \
 +  do {                                                                  \
 +    if (yydebug)                                                        \
 +      {                                                                 \
 +        YYFPRINTF (stderr, "%s ", Title);                               \
 +        yy_symbol_print (stderr, Type, Value]b4_locuser_args([Location])[);        \
 +        YYFPRINTF (stderr, "\n");                                       \
 +      }                                                                 \
 +  } while (YYID (0))
  
  /* Nonzero means print parse trace.  It is left uninitialized so that
     multiple parsers can coexist.  */
@@@ -563,7 -609,13 +557,7 @@@ int yydebug
  #define YYHEADROOM 2
  
  #ifndef YYSTACKEXPANDABLE
 -# if (! defined __cplusplus \
 -      || (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
 -          && ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))
  #  define YYSTACKEXPANDABLE 1
 -# else
 -#  define YYSTACKEXPANDABLE 0
 -# endif
  #endif
  
  #if YYSTACKEXPANDABLE
@@@ -660,7 -712,7 +654,7 @@@ typedef int yyStateNum
  typedef int yyRuleNum;
  
  /** Grammar symbol */
 -typedef short int yySymbol;
 +typedef int yySymbol;
  
  /** Item references, as in LALR(1) machine */
  typedef short int yyItemNum;
@@@ -681,7 -733,7 +675,7 @@@ struct yyGLRState 
    yyStateNum yylrState;
    /** Preceding state in this stack */
    yyGLRState* yypred;
 -  /** Source position of the first token produced by my symbol */
 +  /** Source position of the last token produced by my symbol */
    size_t yyposn;
    union {
      /** First in a chain of alternative reductions producing the
@@@ -793,16 -845,9 +787,16 @@@ yyfillin (yyGLRStackItem *yyvsp, int yy
    yyGLRState *s = yyvsp[yylow0].yystate.yypred;
    for (i = yylow0-1; i >= yylow1; i -= 1)
      {
 -      YYASSERT (s->yyresolved);
 -      yyvsp[i].yystate.yyresolved = yytrue;
 -      yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval;]b4_locations_if([[
 +#if YYDEBUG
 +      yyvsp[i].yystate.yylrState = s->yylrState;
 +#endif
 +      yyvsp[i].yystate.yyresolved = s->yyresolved;
 +      if (s->yyresolved)
 +        yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval;
 +      else
 +        /* The effect of using yysval or yyloc (in an immediate rule) is
 +         * undefined.  */
 +        yyvsp[i].yystate.yysemantics.yyfirstVal = YY_NULL;]b4_locations_if([[
        yyvsp[i].yystate.yyloc = s->yyloc;]])[
        s = yyvsp[i].yystate.yypred = s->yypred;
      }
@@@ -837,7 -882,7 +831,7 @@@ yyuserAction (yyRuleNum yyn, int yyrhsl
    yybool yynormal __attribute__ ((__unused__)) =
      (yystackp->yysplitPoint == YY_NULL);
    int yylow;
 -]b4_parse_param_use[]dnl
 +]b4_parse_param_use([yyvalp], [yylocp])dnl
  [# undef yyerrok
  # define yyerrok (yystackp->yyerrState = 0)
  # undef YYACCEPT
@@@ -940,7 -985,7 +934,7 @@@ yydestroyGLRState (char const *yymsg, y
      }
  }
  
 -/** Left-hand-side symbol for rule #RULE.  */
 +/** Left-hand-side symbol for rule #YYRULE.  */
  static inline yySymbol
  yylhsNonterm (yyRuleNum yyrule)
  {
  #define yypact_value_is_default(yystate) \
    ]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[
  
 -/** True iff LR state STATE has only a default reduction (regardless
 +/** True iff LR state YYSTATE has only a default reduction (regardless
   *  of token).  */
  static inline yybool
  yyisDefaultedState (yyStateNum yystate)
    return yypact_value_is_default (yypact[yystate]);
  }
  
 -/** The default reduction for STATE, assuming it has one.  */
 +/** The default reduction for YYSTATE, assuming it has one.  */
  static inline yyRuleNum
  yydefaultAction (yyStateNum yystate)
  {
   *    R < 0:  Reduce on rule -R.
   *    R = 0:  Error.
   *    R > 0:  Shift to state R.
 - *  Set *CONFLICTS to a pointer into yyconfl to 0-terminated list of
 - *  conflicting reductions.
 + *  Set *YYCONFLICTS to a pointer into yyconfl to a 0-terminated list
 + *  of conflicting reductions.
   */
  static inline void
  yygetLRActions (yyStateNum yystate, int yytoken,
  static inline yyStateNum
  yyLRgotoState (yyStateNum yystate, yySymbol yylhs)
  {
 -  int yyr;
 -  yyr = yypgoto[yylhs - YYNTOKENS] + yystate;
 +  int yyr = yypgoto[yylhs - YYNTOKENS] + yystate;
    if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate)
      return yytable[yyr];
    else
@@@ -1023,10 -1069,9 +1017,10 @@@ yyisErrorAction (int yyaction
  
                                  /* GLRStates */
  
 -/** Return a fresh GLRStackItem.  Callers should call
 - * YY_RESERVE_GLRSTACK afterwards to make sure there is sufficient
 - * headroom.  */
 +/** Return a fresh GLRStackItem in YYSTACKP.  The item is an LR state
 + *  if YYISSTATE, and otherwise a semantic option.  Callers should call
 + *  YY_RESERVE_GLRSTACK afterwards to make sure there is sufficient
 + *  headroom.  */
  
  static inline yyGLRStackItem*
  yynewGLRStackItem (yyGLRStack* yystackp, yybool yyisState)
  }
  
  /** Add a new semantic action that will execute the action for rule
 - *  RULENUM on the semantic values in RHS to the list of
 - *  alternative actions for STATE.  Assumes that RHS comes from
 - *  stack #K of *STACKP. */
 + *  YYRULE on the semantic values in YYRHS to the list of
 + *  alternative actions for YYSTATE.  Assumes that YYRHS comes from
 + *  stack #YYK of *YYSTACKP. */
  static void
  yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate,
 -                     yyGLRState* rhs, yyRuleNum yyrule)
 +                     yyGLRState* yyrhs, yyRuleNum yyrule)
  {
    yySemanticOption* yynewOption =
      &yynewGLRStackItem (yystackp, yyfalse)->yyoption;
 -  yynewOption->yystate = rhs;
 +  yynewOption->yystate = yyrhs;
    yynewOption->yyrule = yyrule;
    if (yystackp->yytops.yylookaheadNeeds[yyk])
      {
  
                                  /* GLRStacks */
  
 -/** Initialize SET to a singleton set containing an empty stack.  */
 +/** Initialize YYSET to a singleton set containing an empty stack.  */
  static yybool
  yyinitStateSet (yyGLRStateSet* yyset)
  {
@@@ -1092,8 -1137,8 +1086,8 @@@ static void yyfreeStateSet (yyGLRStateS
    YYFREE (yyset->yylookaheadNeeds);
  }
  
 -/** Initialize STACK to a single empty stack, with total maximum
 - *  capacity for all stacks of SIZE.  */
 +/** Initialize *YYSTACKP to a single empty stack, with total maximum
 + *  capacity for all stacks of YYSIZE.  */
  static yybool
  yyinitGLRStack (yyGLRStack* yystackp, size_t yysize)
  {
  # define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
    &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
  
 -/** If STACK is expandable, extend it.  WARNING: Pointers into the
 +/** If *YYSTACKP is expandable, extend it.  WARNING: Pointers into the
      stack from outside should be considered invalid after this call.
      We always expand when there are 1 or fewer items left AFTER an
      allocation, so that we can avoid having external pointers exist
@@@ -1185,9 -1230,9 +1179,9 @@@ yyfreeGLRStack (yyGLRStack* yystackp
    yyfreeStateSet (&yystackp->yytops);
  }
  
 -/** Assuming that S is a GLRState somewhere on STACK, update the
 - *  splitpoint of STACK, if needed, so that it is at least as deep as
 - *  S.  */
 +/** Assuming that YYS is a GLRState somewhere on *YYSTACKP, update the
 + *  splitpoint of *YYSTACKP, if needed, so that it is at least as deep as
 + *  YYS.  */
  static inline void
  yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
  {
      yystackp->yysplitPoint = yys;
  }
  
 -/** Invalidate stack #K in STACK.  */
 +/** Invalidate stack #YYK in *YYSTACKP.  */
  static inline void
  yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
  {
    yystackp->yytops.yystates[yyk] = YY_NULL;
  }
  
 -/** Undelete the last stack that was marked as deleted.  Can only be
 -    done once after a deletion, and only when all other stacks have
 +/** Undelete the last stack in *YYSTACKP that was marked as deleted.  Can
 +    only be done once after a deletion, and only when all other stacks have
      been deleted.  */
  static void
  yyundeleteLastStack (yyGLRStack* yystackp)
@@@ -1254,9 -1299,8 +1248,9 @@@ yyremoveDeletes (yyGLRStack* yystackp
      }
  }
  
 -/** Shift to a new state on stack #K of STACK, corresponding to LR state
 - * LRSTATE, at input position POSN, with (resolved) semantic value SVAL.  */
 +/** Shift to a new state on stack #YYK of *YYSTACKP, corresponding to LR
 + * state YYLRSTATE, at input position YYPOSN, with (resolved) semantic
 + * value *YYVALP and source location *YYLOCP.  */
  static inline void
  yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
              size_t yyposn,
    YY_RESERVE_GLRSTACK (yystackp);
  }
  
 -/** Shift stack #K of YYSTACK, to a new state corresponding to LR
 +/** Shift stack #YYK of *YYSTACKP, to a new state corresponding to LR
   *  state YYLRSTATE, at input position YYPOSN, with the (unresolved)
   *  semantic value of YYRHS under the action for YYRULE.  */
  static inline void
  yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
 -                 size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule)
 +                 size_t yyposn, yyGLRState* yyrhs, yyRuleNum yyrule)
  {
    yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
  
    yystackp->yytops.yystates[yyk] = yynewState;
  
    /* Invokes YY_RESERVE_GLRSTACK.  */
 -  yyaddDeferredAction (yystackp, yyk, yynewState, rhs, yyrule);
 +  yyaddDeferredAction (yystackp, yyk, yynewState, yyrhs, yyrule);
  }
  
 -/** Pop the symbols consumed by reduction #RULE from the top of stack
 - *  #K of STACK, and perform the appropriate semantic action on their
 +#if !YYDEBUG
 +# define YY_REDUCE_PRINT(Args)
 +#else
 +# define YY_REDUCE_PRINT(Args)          \
 +do {                                    \
 +  if (yydebug)                          \
 +    yy_reduce_print Args;               \
 +} while (YYID (0))
 +
 +/*----------------------------------------------------------------------.
 +| Report that stack #YYK of *YYSTACKP is going to be reduced by YYRULE. |
 +`----------------------------------------------------------------------*/
 +
 +/*ARGSUSED*/ static inline void
 +yy_reduce_print (int yynormal, yyGLRStackItem* yyvsp, size_t yyk,
 +                 yyRuleNum yyrule]b4_user_formals[)
 +{
 +  int yynrhs = yyrhsLength (yyrule);]b4_locations_if([
 +  int yylow = 1;])[
 +  int yyi;
 +  YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
 +             (unsigned long int) yyk, yyrule - 1,
 +             (unsigned long int) yyrline[yyrule]);
 +  if (! yynormal)
 +    yyfillin (yyvsp, 1, -yynrhs);
 +  /* The symbols being reduced.  */
 +  for (yyi = 0; yyi < yynrhs; yyi++)
 +    {
 +      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
 +      yy_symbol_print (stderr,
 +                       yystos[yyvsp[yyi - yynrhs + 1].yystate.yylrState],
 +                       &yyvsp[yyi - yynrhs + 1].yystate.yysemantics.yysval
 +                       ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
 +                       b4_user_args[);
 +      if (!yyvsp[yyi - yynrhs + 1].yystate.yyresolved)
 +        YYFPRINTF (stderr, " (unresolved)");
 +      YYFPRINTF (stderr, "\n");
 +    }
 +}
 +#endif
 +
 +/** Pop the symbols consumed by reduction #YYRULE from the top of stack
 + *  #YYK of *YYSTACKP, and perform the appropriate semantic action on their
   *  semantic values.  Assumes that all ambiguities in semantic values
 - *  have been previously resolved.  Set *VALP to the resulting value,
 - *  and *LOCP to the computed location (if any).  Return value is as
 + *  have been previously resolved.  Set *YYVALP to the resulting value,
 + *  and *YYLOCP to the computed location (if any).  Return value is as
   *  for userAction.  */
  static inline YYRESULTTAG
  yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
    if (yystackp->yysplitPoint == YY_NULL)
      {
        /* Standard special case: single stack.  */
 -      yyGLRStackItem* rhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
 +      yyGLRStackItem* yyrhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
        YYASSERT (yyk == 0);
        yystackp->yynextFree -= yynrhs;
        yystackp->yyspaceLeft += yynrhs;
        yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate;
 -      return yyuserAction (yyrule, yynrhs, rhs, yystackp,
 +      YY_REDUCE_PRINT ((1, yyrhs, yyk, yyrule]b4_user_args[));
 +      return yyuserAction (yyrule, yynrhs, yyrhs, yystackp,
                             yyvalp]b4_locuser_args[);
      }
    else
      {
 -      /* At present, doAction is never called in nondeterministic
 -       * mode, so this branch is never taken.  It is here in
 -       * anticipation of a future feature that will allow immediate
 -       * evaluation of selected actions in nondeterministic mode.  */
        int yyi;
        yyGLRState* yys;
        yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
          }
        yyupdateSplit (yystackp, yys);
        yystackp->yytops.yystates[yyk] = yys;
 +      YY_REDUCE_PRINT ((0, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, yyk, yyrule]b4_user_args[));
        return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
                             yystackp, yyvalp]b4_locuser_args[);
      }
  }
  
 -#if !YYDEBUG
 -# define YY_REDUCE_PRINT(Args)
 -#else
 -# define YY_REDUCE_PRINT(Args)          \
 -do {                                    \
 -  if (yydebug)                          \
 -    yy_reduce_print Args;               \
 -} while (YYID (0))
 -
 -/*----------------------------------------------------------.
 -| Report that the RULE is going to be reduced on stack #K.  |
 -`----------------------------------------------------------*/
 -
 -/*ARGSUSED*/ static inline void
 -yy_reduce_print (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
 -                 YYSTYPE* yyvalp]b4_locuser_formals[)
 -{
 -  int yynrhs = yyrhsLength (yyrule);
 -  yybool yynormal __attribute__ ((__unused__)) =
 -    (yystackp->yysplitPoint == YY_NULL);
 -  yyGLRStackItem* yyvsp = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
 -  int yylow = 1;
 -  int yyi;
 -  YYUSE (yyvalp);]b4_locations_if([
 -  YYUSE (yylocp);])[
 -]b4_parse_param_use[]dnl
 -[  YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
 -             (unsigned long int) yyk, yyrule - 1,
 -             (unsigned long int) yyrline[yyrule]);
 -  /* The symbols being reduced.  */
 -  for (yyi = 0; yyi < yynrhs; yyi++)
 -    {
 -      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
 -      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
 -                       &]b4_rhs_value(yynrhs, yyi + 1)[
 -                       ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
 -                       b4_user_args[);
 -      YYFPRINTF (stderr, "\n");
 -    }
 -}
 -#endif
 -
 -/** Pop items off stack #K of STACK according to grammar rule RULE,
 +/** Pop items off stack #YYK of *YYSTACKP according to grammar rule YYRULE,
   *  and push back on the resulting nonterminal symbol.  Perform the
 - *  semantic action associated with RULE and store its value with the
 - *  newly pushed state, if FORCEEVAL or if STACK is currently
 + *  semantic action associated with YYRULE and store its value with the
 + *  newly pushed state, if YYFORCEEVAL or if *YYSTACKP is currently
   *  unambiguous.  Otherwise, store the deferred semantic action with
   *  the new state.  If the new state would have an identical input
   *  position, LR state, and predecessor to an existing state on the stack,
 - *  it is identified with that existing state, eliminating stack #K from
 - *  the STACK.  In this case, the (necessarily deferred) semantic value is
 + *  it is identified with that existing state, eliminating stack #YYK from
 + *  *YYSTACKP.  In this case, the semantic value is
   *  added to the options for the existing state's semantic value.
   */
  static inline YYRESULTTAG
@@@ -1402,18 -1449,11 +1396,18 @@@ yyglrReduce (yyGLRStack* yystackp, size
  
    if (yyforceEval || yystackp->yysplitPoint == YY_NULL)
      {
 +      YYRESULTTAG yyflag;
        YYSTYPE yysval;]b4_locations_if([
        YYLTYPE yyloc;])[
  
 -      YY_REDUCE_PRINT ((yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[));
 -      YYCHK (yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[));
 +      yyflag = yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[);
 +      if (yyflag == yyerr && yystackp->yysplitPoint != YY_NULL)
 +        {
 +          YYDPRINTF ((stderr, "Parse on stack %lu rejected by rule #%d.\n",
 +                     (unsigned long int) yyk, yyrule - 1));
 +        }
 +      if (yyflag != yyok)
 +        return yyflag;
        YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyrule], &yysval, &yyloc);
        yyglrShift (yystackp, yyk,
                    yyLRgotoState (yystackp->yytops.yystates[yyk]->yylrState,
        yyupdateSplit (yystackp, yys);
        yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
        YYDPRINTF ((stderr,
 -                  "Reduced stack %lu by rule #%d; action deferred.  Now in state %d.\n",
 +                  "Reduced stack %lu by rule #%d; action deferred.  "
 +                  "Now in state %d.\n",
                    (unsigned long int) yyk, yyrule - 1, yynewLRState));
        for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
          if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULL)
@@@ -1508,7 -1547,7 +1502,7 @@@ yysplitStack (yyGLRStack* yystackp, siz
    return yystackp->yytops.yysize-1;
  }
  
 -/** True iff Y0 and Y1 represent identical options at the top level.
 +/** True iff YYY0 and YYY1 represent identical options at the top level.
   *  That is, they represent the same rule applied to RHS symbols
   *  that produce the same terminal symbols.  */
  static yybool
@@@ -1530,8 -1569,8 +1524,8 @@@ yyidenticalOptions (yySemanticOption* y
      return yyfalse;
  }
  
 -/** Assuming identicalOptions (Y0,Y1), destructively merge the
 - *  alternative semantic values for the RHS-symbols of Y1 and Y0.  */
 +/** Assuming identicalOptions (YYY0,YYY1), destructively merge the
 + *  alternative semantic values for the RHS-symbols of YYY1 and YYY0.  */
  static void
  yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
  {
@@@ -1610,11 -1649,11 +1604,11 @@@ static YYRESULTTAG yyresolveValue (yyGL
                                     yyGLRStack* yystackp]b4_user_formals[);
  
  
 -/** Resolve the previous N states starting at and including state S.  If result
 - *  != yyok, some states may have been left unresolved possibly with empty
 - *  semantic option chains.  Regardless of whether result = yyok, each state
 - *  has been left with consistent data so that yydestroyGLRState can be invoked
 - *  if necessary.  */
 +/** Resolve the previous YYN states starting at and including state YYS
 + *  on *YYSTACKP. If result != yyok, some states may have been left
 + *  unresolved possibly with empty semantic option chains.  Regardless
 + *  of whether result = yyok, each state has been left with consistent
 + *  data so that yydestroyGLRState can be invoked if necessary.  */
  static YYRESULTTAG
  yyresolveStates (yyGLRState* yys, int yyn,
                   yyGLRStack* yystackp]b4_user_formals[)
    return yyok;
  }
  
 -/** Resolve the states for the RHS of OPT, perform its user action, and return
 - *  the semantic value and location.  Regardless of whether result = yyok, all
 - *  RHS states have been destroyed (assuming the user action destroys all RHS
 +/** Resolve the states for the RHS of YYOPT on *YYSTACKP, perform its
 + *  user action, and return the semantic value and location in *YYVALP
 + *  and *YYLOCP.  Regardless of whether result = yyok, all RHS states
 + *  have been destroyed (assuming the user action destroys all RHS
   *  semantic values if invoked).  */
  static YYRESULTTAG
  yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp,
@@@ -1706,11 -1744,11 +1700,11 @@@ yyreportTree (yySemanticOption* yyx, in
          {
            if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn)
              YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "",
 -                       yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]));
 +                       yytokenName (yystos[yystates[yyi]->yylrState]));
            else
              YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "",
 -                       yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]),
 -                       (unsigned long int) (yystates[yyi - 1]->yyposn + 1),
 +                       yytokenName (yystos[yystates[yyi]->yylrState]),
 +                       (unsigned long int) (yystates[yyi-1]->yyposn + 1),
                         (unsigned long int) yystates[yyi]->yyposn);
          }
        else
@@@ -1739,9 -1777,9 +1733,9 @@@ yyreportAmbiguity (yySemanticOption* yy
    return yyabort;
  }]b4_locations_if([[
  
 -/** Starting at and including state S1, resolve the location for each of the
 - *  previous N1 states that is unresolved.  The first semantic option of a state
 - *  is always chosen.  */
 +/** Resolve the locations for each of the YYN1 states in *YYSTACKP,
 + *  ending at YYS1.  Has no effect on previously resolved states.
 + *  The first semantic option of a state is always chosen.  */
  static void
  yyresolveLocations (yyGLRState* yys1, int yyn1,
                      yyGLRStack *yystackp]b4_user_formals[)
      }
  }]])[
  
 -/** Resolve the ambiguity represented in state S, perform the indicated
 - *  actions, and set the semantic value of S.  If result != yyok, the chain of
 - *  semantic options in S has been cleared instead or it has been left
 - *  unmodified except that redundant options may have been removed.  Regardless
 - *  of whether result = yyok, S has been left with consistent data so that
 +/** Resolve the ambiguity represented in state YYS in *YYSTACKP,
 + *  perform the indicated actions, and set the semantic value of YYS.
 + *  If result != yyok, the chain of semantic options in YYS has been
 + *  cleared instead or it has been left unmodified except that
 + *  redundant options may have been removed.  Regardless of whether
 + *  result = yyok, YYS has been left with consistent data so that
   *  yydestroyGLRState can be invoked if necessary.  */
  static YYRESULTTAG
  yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
@@@ -1938,6 -1975,10 +1932,6 @@@ static YYRESULTTA
  yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
                     size_t yyposn]b4_pure_formals[)
  {
 -  int yyaction;
 -  const short int* yyconflicts;
 -  yyRuleNum yyrule;
 -
    while (yystackp->yytops.yystates[yyk] != YY_NULL)
      {
        yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState;
  
        if (yyisDefaultedState (yystate))
          {
 -          yyrule = yydefaultAction (yystate);
 +          YYRESULTTAG yyflag;
 +          yyRuleNum yyrule = yydefaultAction (yystate);
            if (yyrule == 0)
              {
                YYDPRINTF ((stderr, "Stack %lu dies.\n",
                yymarkStackDeleted (yystackp, yyk);
                return yyok;
              }
 -          YYCHK (yyglrReduce (yystackp, yyk, yyrule, yyfalse]b4_user_args[));
 +          yyflag = yyglrReduce (yystackp, yyk, yyrule, yyimmediate[yyrule]]b4_user_args[);
 +          if (yyflag == yyerr)
 +            {
 +              YYDPRINTF ((stderr,
 +                          "Stack %lu dies "
 +                          "(predicate failure or explicit user error).\n",
 +                          (unsigned long int) yyk));
 +              yymarkStackDeleted (yystackp, yyk);
 +              return yyok;
 +            }
 +          if (yyflag != yyok)
 +            return yyflag;
          }
        else
          {
            yySymbol yytoken;
 +          int yyaction;
 +          const short int* yyconflicts;
 +
            yystackp->yytops.yylookaheadNeeds[yyk] = yytrue;
            if (yychar == YYEMPTY)
              {
  
            while (*yyconflicts != 0)
              {
 +              YYRESULTTAG yyflag;
                size_t yynewStack = yysplitStack (yystackp, yyk);
                YYDPRINTF ((stderr, "Splitting off stack %lu from %lu.\n",
                            (unsigned long int) yynewStack,
                            (unsigned long int) yyk));
 -              YYCHK (yyglrReduce (yystackp, yynewStack,
 -                                  *yyconflicts, yyfalse]b4_user_args[));
 -              YYCHK (yyprocessOneStack (yystackp, yynewStack,
 -                                        yyposn]b4_pure_args[));
 +              yyflag = yyglrReduce (yystackp, yynewStack,
 +                                    *yyconflicts,
 +                                    yyimmediate[*yyconflicts]]b4_user_args[);
 +              if (yyflag == yyok)
 +                YYCHK (yyprocessOneStack (yystackp, yynewStack,
 +                                          yyposn]b4_pure_args[));
 +              else if (yyflag == yyerr)
 +                {
 +                  YYDPRINTF ((stderr, "Stack %lu dies.\n",
 +                              (unsigned long int) yynewStack));
 +                  yymarkStackDeleted (yystackp, yynewStack);
 +                }
 +              else
 +                return yyflag;
                yyconflicts += 1;
              }
  
                break;
              }
            else
 -            YYCHK (yyglrReduce (yystackp, yyk, -yyaction,
 -                                yyfalse]b4_user_args[));
 +            {
 +              YYRESULTTAG yyflag = yyglrReduce (yystackp, yyk, -yyaction,
 +                                                yyimmediate[-yyaction]]b4_user_args[);
 +              if (yyflag == yyerr)
 +                {
 +                  YYDPRINTF ((stderr,
 +                              "Stack %lu dies "
 +                              "(predicate failure or explicit user error).\n",
 +                              (unsigned long int) yyk));
 +                  yymarkStackDeleted (yystackp, yyk);
 +                  break;
 +                }
 +              else if (yyflag != yyok)
 +                return yyflag;
 +            }
          }
      }
    return yyok;
@@@ -2297,6 -2299,7 +2291,6 @@@ yyrecoverSyntaxError (yyGLRStack* yysta
      }                                                                        \
    } while (YYID (0))
  
 -
  /*----------.
  | yyparse.  |
  `----------*/
@@@ -2618,7 -2621,9 +2612,7 @@@ yypdumpstack (yyGLRStack* yystackp
    YYFPRINTF (stderr, "\n");
  }
  #endif
 -]
 -
 -b4_epilogue
 +]b4_epilogue[]dnl
  dnl
  dnl glr.cc produces its own header.
  dnl
@@@ -2626,15 -2631,12 +2620,12 @@@ m4_if(b4_skeleton, ["glr.c"]
  [b4_defines_if(
  [@output(b4_spec_defines_file@)@
  b4_copyright([Skeleton interface for Bison GLR parsers in C],
-              [2002-2012])
- b4_shared_declarations
- b4_pure_if([],
- [[extern YYSTYPE ]b4_prefix[lval;]])
- b4_locations_if([b4_pure_if([],
- [extern YYLTYPE ]b4_prefix[lloc;])
- ])
- ])])[]dnl
+              [2002-2012])[
+ ]b4_cpp_guard_open([b4_spec_defines_file])[
+ ]b4_shared_declarations[
+ ]b4_pure_if([], [[extern YYSTYPE ]b4_prefix[lval;
+ ]b4_locations_if([[extern YYLTYPE ]b4_prefix[lloc;]])])[
+ ]b4_cpp_guard_close([b4_spec_defines_file])[
+ ]])])
  m4_divert_pop(0)
diff --combined data/glr.cc
index 117c7148a5d1fdc879580e7fcb6b8624bc207745,0bc1f9fa53e0958e926d3ba3921259d0ce08097e..9a9d7764b06ba71f130daeddc9351c6ead09f52a
@@@ -1,3 -1,5 +1,3 @@@
 -                                                                    -*- C -*-
 -
  # C++ GLR skeleton for Bison
  
  # Copyright (C) 2002-2012 Free Software Foundation, Inc.
@@@ -27,7 -29,7 +27,7 @@@
  #
  #   The additional arguments are stored as members of the parser
  #   object, yyparser.  The C routines need to carry yyparser
 -#   throughout the C parser; that easy: just let yyparser become an
 +#   throughout the C parser; that's easy: make yyparser an
  #   additional parse-param.  But because the C++ skeleton needs to
  #   know the "real" original parse-param, we save them
  #   (b4_parse_param_orig).  Note that b4_parse_param is overquoted
  # The locations
  #
  #   We use location.cc just like lalr1.cc, but because glr.c stores
 -#   the locations in a (C++) union, the position and location classes
 +#   the locations in a union, the position and location classes
  #   must not have a constructor.  Therefore, contrary to lalr1.cc, we
  #   must not define "b4_location_constructors".  As a consequence the
  #   user must initialize the first positions (in particular the
  #   filename member).
  
  # We require a pure interface using locations.
 -m4_define([b4_locations_flag], [1])
 +m4_define([b4_percent_define(locations)], [])
  m4_define([b4_pure_flag],      [1])
  
  # The header is mandatory.
@@@ -126,7 -128,8 +126,7 @@@ m4_pushdef([b4_parse_param], m4_defn([b
    ]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
      :])[
  #if YYDEBUG
 -    ]m4_ifset([b4_parse_param], [  ], [ :])[yydebug_ (false),
 -      yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
 +    ]m4_ifset([b4_parse_param], [  ], [ :])[yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
  #endif]b4_parse_param_cons[
    {
    }
      YYUSE (yyo);
      switch (yytype)
        {
 -  ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
 +]b4_symbol_foreach([b4_symbol_printer])dnl
  [        default:
            break;
        }
    ]b4_parser_class_name[::debug_level_type
    ]b4_parser_class_name[::debug_level () const
    {
 -    return yydebug_;
 +    return yydebug;
    }
  
    void
    ]b4_parser_class_name[::set_debug_level (debug_level_type l)
    {
 -    yydebug_ = l;
 +    yydebug = l;
    }
  
  #endif
  ]m4_popdef([b4_parse_param])dnl
  b4_namespace_close[
 -
  ]])
  
  
@@@ -222,27 -226,25 +222,26 @@@ m4_popdef([b4_parse_param]
  m4_divert_push(0)
  @output(b4_spec_defines_file@)@
  b4_copyright([Skeleton interface for Bison GLR parsers in C++],
 -             [2002-2006, 2009-2012])[
 +             [2002-2012])[
  
  /* C++ GLR parser skeleton written by Akim Demaille.  */
  
- #ifndef PARSER_HEADER_H
- # define PARSER_HEADER_H
+ ]b4_cpp_guard_open([b4_spec_defines_file])[
  
  ]b4_percent_code_get([[requires]])[
  
 +#include <stdexcept>
  #include <string>
  #include <iostream>
  ]b4_percent_define_ifdef([[location_type]], [],
                           [[#include "location.hh"]])[
  
  /* Using locations.  */
 -#define YYLSP_NEEDED ]b4_locations_flag[
 +#define YYLSP_NEEDED ]b4_locations_if([1], [0])[
  
  /* Enabling traces.  */
  #ifndef YYDEBUG
 -# define YYDEBUG ]b4_debug_flag[
 +# define YYDEBUG ]b4_parse_trace_if([1], [0])[
  #endif
  
  /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
    class ]b4_parser_class_name[
    {
    public:
 -    /// Symbol semantic values.
 -#ifndef YYSTYPE
 -]m4_ifdef([b4_stype],
 -[    union semantic_type
 -    {
 -b4_user_stype
 -    };],
 -[m4_if(b4_tag_seen_flag, 0,
 -[[    typedef int semantic_type;]],
 -[[    typedef YYSTYPE semantic_type;]])])[
 -#else
 -    typedef YYSTYPE semantic_type;
 -#endif
 -    /// Symbol locations.
 -    typedef ]b4_percent_define_get([[location_type]],
 -                                   [[location]])[ location_type;
 -    /// Tokens.
 -    struct token
 -    {
 -      ]b4_token_enums(b4_tokens)[
 -    };
 -    /// Token type.
 -    typedef token::yytokentype token_type;
 +]b4_public_types_declare[
  
      /// Build a parser object.
      ]b4_parser_class_name[ (]b4_parse_param_decl[);
      /// Set the current debugging level.
      void set_debug_level (debug_level_type l);
  
 -  private:
 -
    public:
      /// Report a syntax error.
      /// \param loc    where the syntax error is found.
      /// \param msg    a description of the syntax error.
      virtual void error (const location_type& loc, const std::string& msg);
 -  private:
  
  #if YYDEBUG
    public:
                                     const location_type* yylocationp);
    private:
      /* Debugging.  */
 -    int yydebug_;
      std::ostream* yycdebug_;
  #endif
  
@@@ -333,8 -361,6 +332,6 @@@ b4_percent_define_flag_if([[global_toke
  #endif
  
  ]b4_namespace_close[
- ]b4_percent_code_get([[provides]])[]dnl
- [#endif /* ! defined PARSER_HEADER_H */]
- m4_divert_pop(0)
+ ]b4_percent_code_get([[provides]])[
+ ]b4_cpp_guard_close([b4_spec_defines_file])[
+ ]m4_divert_pop(0)
diff --combined data/yacc.c
index 922a4ebec9d1b365fcd39b07dd8de461ebefb247,30c5f672aff3a5f3ee959b5f3bfeeccab33617a3..56be747aecf8a8650cabccda43748af0789b2da1
@@@ -1,12 -1,10 +1,12 @@@
                                                               -*- C -*-
 -
  # Yacc compatible skeleton for Bison
  
  # Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation,
  # Inc.
  
 +m4_pushdef([b4_copyright_years],
 +           [1984, 1989-1990, 2000-2012])
 +
  # This program is free software: you can redistribute it and/or modify
  # it under the terms of the GNU General Public License as published by
  # the Free Software Foundation, either version 3 of the License, or
@@@ -76,8 -74,8 +76,8 @@@ m4_define([b4_pure_flag]
  # 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])])
 +                      [$1], [$2])],
 +            [$2])])
  
  
  # b4_yyerror_args
@@@ -117,7 -115,7 +117,7 @@@ m4_define([b4_int_type]
  
         m4_eval([0 <= $1]),                [1], [unsigned int],
  
 -                                             [int])])
 +                                               [int])])
  
  
  ## ----------------- ##
  # --------------------
  # Expansion of $<TYPE>$.
  m4_define([b4_lhs_value],
 -[(yyval[]m4_ifval([$1], [.$1]))])
 +[b4_symbol_value(yyval, [$1])])
  
  
  # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
  # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
  # symbols on RHS.
  m4_define([b4_rhs_value],
 -[(yyvsp@{($2) - ($1)@}m4_ifval([$3], [.$3]))])
 +          [b4_symbol_value([yyvsp@{b4_subtract([$2], [$1])@}], [$3])])
  
  
  
@@@ -157,7 -155,7 +157,7 @@@ m4_define([b4_lhs_location]
  # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
  # on RHS.
  m4_define([b4_rhs_location],
 -[(yylsp@{($2) - ($1)@})])
 +          [(yylsp@{b4_subtract([$2], [$1])@})])
  
  
  ## -------------- ##
@@@ -226,6 -224,62 +226,62 @@@ m4_define([b4_declare_parser_state_vari
      yytype_int16 *yyes;
      YYSIZE_T yyes_capacity;]])])
  
+ # b4_declare_yyparse_push_
+ # ------------------------
+ m4_define([b4_declare_yyparse_push_],
+ [[typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
+ enum { YYPUSH_MORE = 4 };
+ ]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_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_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_declare_yyparse_
+ # -------------------
+ # When not the push parser.
+ m4_define([b4_declare_yyparse_],
+ [[#ifdef YYPARSE_PARAM
+ ]b4_c_function_decl(b4_prefix[parse], [int],
+                     [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[
+ #else /* ! YYPARSE_PARAM */
+ ]b4_c_function_decl(b4_prefix[parse], [int], b4_parse_param)[
+ #endif /* ! YYPARSE_PARAM */]dnl
+ ])
+ # b4_declare_yyparse
+ # ------------------
+ m4_define([b4_declare_yyparse],
+ [b4_push_if([b4_declare_yyparse_push_],
+             [b4_declare_yyparse_])[]dnl
+ ])
+ # b4_shared_declarations
+ # ----------------------
+ # Declaration that might either go into the header (if --defines)
+ # or open coded in the parser body.
+ m4_define([b4_shared_declarations],
+ [b4_declare_yydebug[
+ ]b4_percent_code_get([[requires]])[
+ ]b4_token_enums_defines(b4_tokens)[
+ ]b4_declare_yylstype[
+ ]b4_declare_yyparse[
+ ]b4_percent_code_get([[provides]])[]dnl
+ ])
  ## -------------- ##
  ## Output files.  ##
  ## -------------- ##
  m4_changecom()
  m4_divert_push(0)dnl
  @output(b4_parser_file_name@)@
 -b4_copyright([Bison implementation for Yacc-like parsers in C],
 -             [1984, 1989-1990, 2000-2012])[
 +b4_copyright([Bison implementation for Yacc-like parsers in C])[
  
  /* C LALR(1) parser skeleton written by Richard Stallman, by
     simplifying the original so-called "semantic" parser.  */
@@@ -269,17 -324,12 +325,12 @@@ m4_if(b4_prefix, [yy], []
  
  ]b4_null_define[
  
- /* Enabling traces.  */
- #ifndef YYDEBUG
- # define YYDEBUG ]b4_parse_trace_if([1], [0])[
- #endif
  /* Enabling verbose error messages.  */
  #ifdef YYERROR_VERBOSE
  # undef YYERROR_VERBOSE
  # define YYERROR_VERBOSE 1
  #else
 -# define YYERROR_VERBOSE ]b4_error_verbose_flag[
 +# define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[
  #endif
  
  /* Enabling the token table.  */
  # define YYTOKEN_TABLE ]b4_token_table[
  #endif
  
- ]b4_percent_code_get([[requires]])[
- ]b4_token_enums_defines(b4_tokens)[
- ]b4_declare_yylstype[
- ]b4_push_if([[
- #ifndef YYPUSH_DECLS
- #  define YYPUSH_DECLS
- struct yypstate;
- typedef struct yypstate yypstate;
- enum { YYPUSH_MORE = 4 };
- ]b4_pull_if([b4_c_function_decl([[yyparse]], [[int]], b4_parse_param)
- ])b4_c_function_decl([[yypush_parse]], [[int]],
-   [[[yypstate *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_parse_param]))
- b4_pull_if([b4_c_function_decl([[yypull_parse]], [[int]],
-   [[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
-   b4_parse_param]))])
- b4_c_function_decl([[yypstate_new]], [[yypstate *]], [[[void]], []])
- b4_c_function_decl([[yypstate_delete]], [[void]],
-                    [[[yypstate *yyps]], [[yyps]]])[
- #endif]])
- b4_percent_code_get([[provides]])[]dnl
+ ]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
+                [b4_shared_declarations])[
  
[/* Copy the second part of user declarations.  */
+ /* Copy the second part of user declarations.  */
  ]b4_user_post_prologue
  b4_percent_code_get[]dnl
  
@@@ -439,7 -465,7 +466,7 @@@ b4_push_if([], [b4_lac_if([], [
  #  endif
  #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
         && ! ((defined YYMALLOC || defined malloc) \
 -           && (defined YYFREE || defined free)))
 +             && (defined YYFREE || defined free)))
  #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  #   ifndef EXIT_SUCCESS
  #    define EXIT_SUCCESS 0
@@@ -464,8 -490,8 +491,8 @@@ void free (void *); /* INFRINGES ON USE
  
  #if (! defined yyoverflow \
       && (! defined __cplusplus \
 -       || (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
 -           && ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
 +         || (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
 +             && ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
  
  /* A type that is properly aligned for any stack member.  */
  union yyalloc
     elements in the stack, and YYPTR gives the new location of the
     stack.  Advance YYPTR to a properly aligned location for the next
     stack.  */
 -# define YYSTACK_RELOCATE(Stack_alloc, Stack)                         \
 -    do                                                                        \
 -      {                                                                       \
 -      YYSIZE_T yynewbytes;                                            \
 -      YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
 -      Stack = &yyptr->Stack_alloc;                                    \
 -      yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
 -      yyptr += yynewbytes / sizeof (*yyptr);                          \
 -      }                                                                       \
 +# define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
 +    do                                                                  \
 +      {                                                                 \
 +        YYSIZE_T yynewbytes;                                            \
 +        YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
 +        Stack = &yyptr->Stack_alloc;                                    \
 +        yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
 +        yyptr += yynewbytes / sizeof (*yyptr);                          \
 +      }                                                                 \
      while (YYID (0))
  
  #endif
  #define YYNNTS  ]b4_nterms_number[
  /* YYNRULES -- Number of rules.  */
  #define YYNRULES  ]b4_rules_number[
 -/* YYNRULES -- Number of states.  */
 +/* YYNSTATES -- Number of states.  */
  #define YYNSTATES  ]b4_states_number[
  
 -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
 +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
 +   by yylex, with out-of-bounds checking.  */
  #define YYUNDEFTOK  ]b4_undef_token_number[
  #define YYMAXUTOK   ]b4_user_token_number_max[
  
 -#define YYTRANSLATE(YYX)                                              \
 +#define YYTRANSLATE(YYX)                                                \
    ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
  
 -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
 +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
 +   as returned by yylex, without out-of-bounds checking.  */
  static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
  {
    ]b4_translate[
  };
  
  #if YYDEBUG
 -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
 -   YYRHS.  */
 -static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
 -{
 -  ]b4_prhs[
 -};
 -
 -/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
 -static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
 -{
 -  ]b4_rhs[
 -};
 -
 -/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 -static const ]b4_int_type_for([b4_rline])[ yyrline[] =
 -{
 -  ]b4_rline[
 -};
 +]b4_integral_parser_table_define([rline], [b4_rline],
 +     [YYRLINE[YYN] -- Source line where rule number YYN was defined.])[
  #endif
  
  #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
@@@ -572,34 -612,89 +599,34 @@@ static const char *const yytname[] 
  #endif
  
  # ifdef YYPRINT
 -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
 -   token YYLEX-NUM.  */
 +/* YYTOKNUM[NUM] -- (External) token number corresponding to the
 +   (internal) symbol number NUM (which must be that of a token).  */
  static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
  {
    ]b4_toknum[
  };
  # endif
  
 -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 -static const ]b4_int_type_for([b4_r1])[ yyr1[] =
 -{
 -  ]b4_r1[
 -};
 -
 -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
 -static const ]b4_int_type_for([b4_r2])[ yyr2[] =
 -{
 -  ]b4_r2[
 -};
 -
 -/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
 -   Performed when YYTABLE doesn't specify something else to do.  Zero
 -   means the default is an error.  */
 -static const ]b4_int_type_for([b4_defact])[ yydefact[] =
 -{
 -  ]b4_defact[
 -};
 -
 -/* YYDEFGOTO[NTERM-NUM].  */
 -static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] =
 -{
 -  ]b4_defgoto[
 -};
 -
 -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
 -   STATE-NUM.  */
  #define YYPACT_NINF ]b4_pact_ninf[
 -static const ]b4_int_type_for([b4_pact])[ yypact[] =
 -{
 -  ]b4_pact[
 -};
 -
 -/* YYPGOTO[NTERM-NUM].  */
 -static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] =
 -{
 -  ]b4_pgoto[
 -};
 -
 -/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
 -   positive, shift that token.  If negative, reduce the rule which
 -   number is the opposite.  If YYTABLE_NINF, syntax error.  */
 -#define YYTABLE_NINF ]b4_table_ninf[
 -static const ]b4_int_type_for([b4_table])[ yytable[] =
 -{
 -  ]b4_table[
 -};
  
  #define yypact_value_is_default(yystate) \
    ]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[
  
 +#define YYTABLE_NINF ]b4_table_ninf[
 +
  #define yytable_value_is_error(yytable_value) \
    ]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[
  
 -static const ]b4_int_type_for([b4_check])[ yycheck[] =
 -{
 -  ]b4_check[
 -};
 -
 -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
 -   symbol of state STATE-NUM.  */
 -static const ]b4_int_type_for([b4_stos])[ yystos[] =
 -{
 -  ]b4_stos[
 -};
 +]b4_parser_tables_define[
  
 -#define yyerrok               (yyerrstatus = 0)
 -#define yyclearin     (yychar = YYEMPTY)
 -#define YYEMPTY               (-2)
 -#define YYEOF         0
 +#define yyerrok         (yyerrstatus = 0)
 +#define yyclearin       (yychar = YYEMPTY)
 +#define YYEMPTY         (-2)
 +#define YYEOF           0
  
 -#define YYACCEPT      goto yyacceptlab
 -#define YYABORT               goto yyabortlab
 -#define YYERROR               goto yyerrorlab
 +#define YYACCEPT        goto yyacceptlab
 +#define YYABORT         goto yyabortlab
 +#define YYERROR         goto yyerrorlab
  
  
  /* Like YYERROR except do call yyerror.  This remains here temporarily
     in Bison 2.4.2's NEWS entry, where a plan to phase it out is
     discussed.  */
  
 -#define YYFAIL                goto yyerrlab
 +#define YYFAIL          goto yyerrlab
  #if defined YYFAIL
    /* This is here to suppress warnings from the GCC cpp's
       -Wunused-macros.  Normally we don't worry about that warning, but
    else                                                          \
      {                                                           \
        yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
 -      YYERROR;                                                        \
 -    }                                                         \
 +      YYERROR;                                                  \
 +    }                                                           \
  while (YYID (0))
  
  
 -#define YYTERROR      1
 -#define YYERRCODE     256
 +#define YYTERROR        1
 +#define YYERRCODE       256
  
  
  /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
  
  #define YYRHSLOC(Rhs, K) ((Rhs)[K])
  #ifndef YYLLOC_DEFAULT
 -# define YYLLOC_DEFAULT(Current, Rhs, N)                              \
 -    do                                                                        \
 +# define YYLLOC_DEFAULT(Current, Rhs, N)                                \
 +    do                                                                  \
        if (YYID (N))                                                    \
 -      {                                                               \
 -        (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
 -        (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
 -        (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
 -        (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
 -      }                                                               \
 -      else                                                            \
 -      {                                                               \
 -        (Current).first_line   = (Current).last_line   =              \
 -          YYRHSLOC (Rhs, 0).last_line;                                \
 -        (Current).first_column = (Current).last_column =              \
 -          YYRHSLOC (Rhs, 0).last_column;                              \
 -      }                                                               \
 +        {                                                               \
 +          (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
 +          (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
 +          (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
 +          (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
 +        }                                                               \
 +      else                                                              \
 +        {                                                               \
 +          (Current).first_line   = (Current).last_line   =              \
 +            YYRHSLOC (Rhs, 0).last_line;                                \
 +          (Current).first_column = (Current).last_column =              \
 +            YYRHSLOC (Rhs, 0).last_column;                              \
 +        }                                                               \
      while (YYID (0))
  #endif]b4_locations_if([[
  
  
  #ifndef YY_LOCATION_PRINT
  # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
 -#  define YY_LOCATION_PRINT(File, Loc)                        \
 -     fprintf (File, "%d.%d-%d.%d",                    \
 -            (Loc).first_line, (Loc).first_column,     \
 -            (Loc).last_line,  (Loc).last_column)
 +#  define YY_LOCATION_PRINT(File, Loc)                  \
 +     fprintf (File, "%d.%d-%d.%d",                      \
 +              (Loc).first_line, (Loc).first_column,     \
 +              (Loc).last_line,  (Loc).last_column)
  # else
  #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
  # endif
  #  define YYFPRINTF fprintf
  # endif
  
 -# define YYDPRINTF(Args)                      \
 -do {                                          \
 -  if (yydebug)                                        \
 -    YYFPRINTF Args;                           \
 +# define YYDPRINTF(Args)                        \
 +do {                                            \
 +  if (yydebug)                                  \
 +    YYFPRINTF Args;                             \
  } while (YYID (0))
  
 -# define YY_SYMBOL_PRINT(Title, Type, Value, Location)                          \
 -do {                                                                    \
 -  if (yydebug)                                                                  \
 -    {                                                                   \
 -      YYFPRINTF (stderr, "%s ", Title);                                         \
 -      yy_symbol_print (stderr,                                                  \
 -                Type, Value]b4_locations_if([, Location])[]b4_user_args[); \
 -      YYFPRINTF (stderr, "\n");                                                 \
 -    }                                                                   \
 +# define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
 +do {                                                                      \
 +  if (yydebug)                                                            \
 +    {                                                                     \
 +      YYFPRINTF (stderr, "%s ", Title);                                   \
 +      yy_symbol_print (stderr,                                            \
 +                  Type, Value]b4_locations_if([, Location])[]b4_user_args[); \
 +      YYFPRINTF (stderr, "\n");                                           \
 +    }                                                                     \
  } while (YYID (0))
  
  ]b4_yy_symbol_print_generate([b4_c_function_def])[
  `------------------------------------------------------------------*/
  
  ]b4_c_function_def([yy_stack_print], [static void],
 -                 [[yytype_int16 *yybottom], [yybottom]],
 -                 [[yytype_int16 *yytop],    [yytop]])[
 +                   [[yytype_int16 *yybottom], [yybottom]],
 +                   [[yytype_int16 *yytop],    [yytop]])[
  {
    YYFPRINTF (stderr, "Stack now");
    for (; yybottom <= yytop; yybottom++)
    YYFPRINTF (stderr, "\n");
  }
  
 -# define YY_STACK_PRINT(Bottom, Top)                          \
 -do {                                                          \
 -  if (yydebug)                                                        \
 -    yy_stack_print ((Bottom), (Top));                         \
 +# define YY_STACK_PRINT(Bottom, Top)                            \
 +do {                                                            \
 +  if (yydebug)                                                  \
 +    yy_stack_print ((Bottom), (Top));                           \
  } while (YYID (0))
  
  
  `------------------------------------------------*/
  
  ]b4_c_function_def([yy_reduce_print], [static void],
 -                 [[YYSTYPE *yyvsp], [yyvsp]],
 +                   [[yytype_int16 *yyssp], [yyssp]],
 +                   [[YYSTYPE *yyvsp], [yyvsp]],
      b4_locations_if([[[YYLTYPE *yylsp], [yylsp]],
 -                 ])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
 -                 b4_parse_param]))[
 +                   ])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
 +                   b4_parse_param]))[
  {
 +  unsigned long int yylno = yyrline[yyrule];
    int yynrhs = yyr2[yyrule];
    int yyi;
 -  unsigned long int yylno = yyrline[yyrule];
    YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
 -           yyrule - 1, yylno);
 +             yyrule - 1, yylno);
    /* The symbols being reduced.  */
    for (yyi = 0; yyi < yynrhs; yyi++)
      {
        YYFPRINTF (stderr, "   $%d = ", yyi + 1);
 -      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
 -                     &]b4_rhs_value(yynrhs, yyi + 1)[
 -                     ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
 -                     b4_user_args[);
 +      yy_symbol_print (stderr,
 +                       yystos[yyssp[yyi + 1 - yynrhs]],
 +                       &]b4_rhs_value(yynrhs, yyi + 1)[
 +                       ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
 +                       b4_user_args[);
        YYFPRINTF (stderr, "\n");
      }
  }
  
 -# define YY_REDUCE_PRINT(Rule)                \
 -do {                                  \
 -  if (yydebug)                                \
 -    yy_reduce_print (yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
 +# define YY_REDUCE_PRINT(Rule)          \
 +do {                                    \
 +  if (yydebug)                          \
 +    yy_reduce_print (yyssp, yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
  } while (YYID (0))
  
  /* Nonzero means print parse trace.  It is left uninitialized so that
@@@ -798,7 -891,7 +825,7 @@@ int yydebug
  
  
  /* YYINITDEPTH -- initial size of the parser's stacks.  */
 -#ifndef       YYINITDEPTH
 +#ifndef YYINITDEPTH
  # define YYINITDEPTH ]b4_stack_depth_init[
  #endif
  
@@@ -1105,27 -1198,27 +1132,27 @@@ yytnamerr (char *yyres, const char *yys
        char const *yyp = yystr;
  
        for (;;)
 -      switch (*++yyp)
 -        {
 -        case '\'':
 -        case ',':
 -          goto do_not_strip_quotes;
 -
 -        case '\\':
 -          if (*++yyp != '\\')
 -            goto do_not_strip_quotes;
 -          /* Fall through.  */
 -        default:
 -          if (yyres)
 -            yyres[yyn] = *yyp;
 -          yyn++;
 -          break;
 -
 -        case '"':
 -          if (yyres)
 -            yyres[yyn] = '\0';
 -          return yyn;
 -        }
 +        switch (*++yyp)
 +          {
 +          case '\'':
 +          case ',':
 +            goto do_not_strip_quotes;
 +
 +          case '\\':
 +            if (*++yyp != '\\')
 +              goto do_not_strip_quotes;
 +            /* Fall through.  */
 +          default:
 +            if (yyres)
 +              yyres[yyn] = *yyp;
 +            yyn++;
 +            break;
 +
 +          case '"':
 +            if (yyres)
 +              yyres[yyn] = '\0';
 +            return yyn;
 +          }
      do_not_strip_quotes: ;
      }
  
@@@ -1298,20 -1391,12 +1325,12 @@@ yysyntax_error (YYSIZE_T *yymsg_alloc, 
  }
  #endif /* YYERROR_VERBOSE */
  
- ]b4_yydestruct_generate([b4_c_function_def])b4_push_if([], [[
+ ]b4_yydestruct_generate([b4_c_function_def])[
  
- /* Prevent warnings from -Wmissing-prototypes.  */
- #ifdef YYPARSE_PARAM
- ]b4_c_function_decl([yyparse], [int],
-                     [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[
- #else /* ! YYPARSE_PARAM */
- ]b4_c_function_decl([yyparse], [int], b4_parse_param)[
- #endif /* ! YYPARSE_PARAM */]])b4_pure_if([], [
+ ]b4_pure_if([], [
  
  b4_declare_scanner_communication_variables])[]b4_push_if([[
  
  struct yypstate
    {]b4_declare_parser_state_variables[
      /* Used to determine if this is the first time this instance has
@@@ -1528,26 -1613,26 +1547,26 @@@ m4_ifdef([b4_at_dollar_used], [[  yylsp
  
  #ifdef yyoverflow
        {
 -      /* Give user a chance to reallocate the stack.  Use copies of
 -         these so that the &'s don't force the real ones into
 -         memory.  */
 -      YYSTYPE *yyvs1 = yyvs;
 -      yytype_int16 *yyss1 = yyss;]b4_locations_if([
 -      YYLTYPE *yyls1 = yyls;])[
 -
 -      /* Each stack pointer address is followed by the size of the
 -         data in use in that stack, in bytes.  This used to be a
 -         conditional around just the two extra args, but that might
 -         be undefined if yyoverflow is a macro.  */
 -      yyoverflow (YY_("memory exhausted"),
 -                  &yyss1, yysize * sizeof (*yyssp),
 -                  &yyvs1, yysize * sizeof (*yyvsp),]b4_locations_if([
 -                  &yyls1, yysize * sizeof (*yylsp),])[
 -                  &yystacksize);
 +        /* Give user a chance to reallocate the stack.  Use copies of
 +           these so that the &'s don't force the real ones into
 +           memory.  */
 +        YYSTYPE *yyvs1 = yyvs;
 +        yytype_int16 *yyss1 = yyss;]b4_locations_if([
 +        YYLTYPE *yyls1 = yyls;])[
 +
 +        /* Each stack pointer address is followed by the size of the
 +           data in use in that stack, in bytes.  This used to be a
 +           conditional around just the two extra args, but that might
 +           be undefined if yyoverflow is a macro.  */
 +        yyoverflow (YY_("memory exhausted"),
 +                    &yyss1, yysize * sizeof (*yyssp),
 +                    &yyvs1, yysize * sizeof (*yyvsp),]b4_locations_if([
 +                    &yyls1, yysize * sizeof (*yylsp),])[
 +                    &yystacksize);
  ]b4_locations_if([
 -      yyls = yyls1;])[
 -      yyss = yyss1;
 -      yyvs = yyvs1;
 +        yyls = yyls1;])[
 +        yyss = yyss1;
 +        yyvs = yyvs1;
        }
  #else /* no yyoverflow */
  # ifndef YYSTACK_RELOCATE
  # else
        /* Extend the stack our own way.  */
        if (YYMAXDEPTH <= yystacksize)
 -      goto yyexhaustedlab;
 +        goto yyexhaustedlab;
        yystacksize *= 2;
        if (YYMAXDEPTH < yystacksize)
 -      yystacksize = YYMAXDEPTH;
 +        yystacksize = YYMAXDEPTH;
  
        {
 -      yytype_int16 *yyss1 = yyss;
 -      union yyalloc *yyptr =
 -        (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
 -      if (! yyptr)
 -        goto yyexhaustedlab;
 -      YYSTACK_RELOCATE (yyss_alloc, yyss);
 -      YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
 -      YYSTACK_RELOCATE (yyls_alloc, yyls);])[
 +        yytype_int16 *yyss1 = yyss;
 +        union yyalloc *yyptr =
 +          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
 +        if (! yyptr)
 +          goto yyexhaustedlab;
 +        YYSTACK_RELOCATE (yyss_alloc, yyss);
 +        YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
 +        YYSTACK_RELOCATE (yyls_alloc, yyls);])[
  #  undef YYSTACK_RELOCATE
 -      if (yyss1 != yyssa)
 -        YYSTACK_FREE (yyss1);
 +        if (yyss1 != yyssa)
 +          YYSTACK_FREE (yyss1);
        }
  # endif
  #endif /* no yyoverflow */
        yylsp = yyls + yysize - 1;])[
  
        YYDPRINTF ((stderr, "Stack size increased to %lu\n",
 -                (unsigned long int) yystacksize));
 +                  (unsigned long int) yystacksize));
  
        if (yyss + yystacksize - 1 <= yyssp)
 -      YYABORT;
 +        YYABORT;
      }
  
    YYDPRINTF ((stderr, "Entering state %d\n", yystate));
@@@ -1820,20 -1905,20 +1839,20 @@@ yyerrlab
    if (yyerrstatus == 3)
      {
        /* If just tried and failed to reuse lookahead token after an
 -       error, discard it.  */
 +         error, discard it.  */
  
        if (yychar <= YYEOF)
 -      {
 -        /* Return failure if at end of input.  */
 -        if (yychar == YYEOF)
 -          YYABORT;
 -      }
 +        {
 +          /* Return failure if at end of input.  */
 +          if (yychar == YYEOF)
 +            YYABORT;
 +        }
        else
 -      {
 -        yydestruct ("Error: discarding",
 -                    yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
 -        yychar = YYEMPTY;
 -      }
 +        {
 +          yydestruct ("Error: discarding",
 +                      yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
 +          yychar = YYEMPTY;
 +        }
      }
  
    /* Else will try to reuse lookahead token after shifting the error
@@@ -1866,29 -1951,29 +1885,29 @@@ yyerrorlab
  | yyerrlab1 -- common code for both syntax error and YYERROR.  |
  `-------------------------------------------------------------*/
  yyerrlab1:
 -  yyerrstatus = 3;    /* Each real token shifted decrements this.  */
 +  yyerrstatus = 3;      /* Each real token shifted decrements this.  */
  
    for (;;)
      {
        yyn = yypact[yystate];
        if (!yypact_value_is_default (yyn))
 -      {
 -        yyn += YYTERROR;
 -        if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
 -          {
 -            yyn = yytable[yyn];
 -            if (0 < yyn)
 -              break;
 -          }
 -      }
 +        {
 +          yyn += YYTERROR;
 +          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
 +            {
 +              yyn = yytable[yyn];
 +              if (0 < yyn)
 +                break;
 +            }
 +        }
  
        /* Pop the current state because it cannot handle the error token.  */
        if (yyssp == yyss)
 -      YYABORT;
 +        YYABORT;
  
  ]b4_locations_if([[      yyerror_range[1] = *yylsp;]])[
        yydestruct ("Error: popping",
 -                yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
 +                  yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
        YYPOPSTACK (1);
        yystate = *yyssp;
        YY_STACK_PRINT (yyss, yyssp);
@@@ -1953,7 -2038,7 +1972,7 @@@ yyreturn
    while (yyssp != yyss)
      {
        yydestruct ("Cleanup: popping",
 -                yystos[*yyssp], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
 +                  yystos[*yyssp], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
        YYPOPSTACK (1);
      }
  #ifndef yyoverflow
@@@ -1973,40 -2058,17 +1992,16 @@@ yypushreturn:]])
    return YYID (yyresult);
  }
  
 -
 -]b4_epilogue
 +]b4_epilogue[]dnl
  b4_defines_if(
  [@output(b4_spec_defines_file@)@
- b4_copyright([Bison interface for Yacc-like parsers in C])dnl
- b4_percent_code_get([[requires]])[]dnl
 -b4_copyright([Bison interface for Yacc-like parsers in C],
 -             [1984, 1989-1990, 2000-2012])[
++b4_copyright([Bison interface for Yacc-like parsers in C])[
  
b4_token_enums_defines(b4_tokens)[
- ]b4_declare_yylstype[
]b4_cpp_guard_open([b4_spec_defines_file])[
+ ]b4_shared_declarations[
  ]b4_pure_if([], [[extern YYSTYPE ]b4_prefix[lval;
- ]b4_locations_if([[extern YYLTYPE ]b4_prefix[lloc;]])])dnl
- b4_push_if([[
- #ifndef YYPUSH_DECLS
- #  define YYPUSH_DECLS
- struct ]b4_prefix[pstate;
- typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
- enum { YYPUSH_MORE = 4 };
- ]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_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_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]]])[
- #endif
- ]])
- b4_percent_code_get([[provides]])[]dnl
- ])dnl b4_defines_if
+ ]b4_locations_if([[extern YYLTYPE ]b4_prefix[lloc;]])])[
+ ]b4_cpp_guard_close([b4_spec_defines_file])[
+ ]])dnl b4_defines_if
  m4_divert_pop(0)
 +m4_popdef([b4_copyright_years])
diff --combined tests/actions.at
index 8be86f073476755736f605e439eba20de98e8481,cfac299202a9e204042ac419df3ab6cf303602b3..84529bef7672dd630fc1b68e65c393df64e4d8c8
@@@ -28,14 -28,13 +28,13 @@@ AT_SETUP([Mid-rule actions]
  # instead of being attached to the empty rule dedicated to this
  # action.
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([[input.y]],
 -[[%error-verbose
 +[[%define parse.error verbose
  %debug
  %{
- # include <stdio.h>
- # include <stdlib.h>
-   static void yyerror (const char *msg);
-   static int yylex (void);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
  %}
  %%
  exp:     { putchar ('0'); }
           { putchar ('\n'); }
     ;
  %%
- static int
- yylex (void)
- {
-   static char const input[] = "123456789";
-   static size_t toknum;
-   if (! (toknum < sizeof input))
-     abort ();
-   return input[toknum++];
- }
- static void
- yyerror (const char *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
+ ]AT_YYLEX_DEFINE(123456789)[
  int
  main (void)
  {
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([-d -v -o input.c input.y])
  AT_COMPILE([input])
@@@ -92,14 -78,13 +78,13 @@@ AT_CLEANU
  
  AT_SETUP([Exotic Dollars])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([[input.y]],
 -[[%error-verbose
 +[[%define parse.error verbose
  %debug
  %{
- # include <stdio.h>
- # include <stdlib.h>
-   static void yyerror (const char *msg);
-   static int yylex (void);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
  # define USE(Var)
  %}
  
@@@ -130,21 -115,8 +115,8 @@@ sum_of_the_five_previous_values
  ;
  
  %%
- static int
- yylex (void)
- {
-   static int called;
-   if (called++)
-     abort ();
-   return EOF;
- }
- static void
- yyerror (const char *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
+ ]AT_YYLEX_DEFINE([])[
  int
  main (void)
  {
@@@ -164,9 -136,9 +136,9 @@@ AT_PARSER_CHECK([./input], 0
  AT_DATA_GRAMMAR([[input.y]],
  [[
  %{
 -#include <stdio.h>
 +# include <stdio.h>
-   static int yylex (void);
-   static void yyerror (char const *msg);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
    typedef struct { int val; } stype;
  # define YYSTYPE stype
  %}
@@@ -185,12 -157,7 +157,7 @@@ yylex (void
    return 0;
  }
  
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  int
  main (void)
  {
@@@ -204,6 -171,7 +171,7 @@@ AT_PARSER_CHECK([[./input]], [[0]]
  [[6
  ]])
  
+ AT_BISON_OPTION_POPDEFS
  AT_CLEANUP
  
  
@@@ -245,7 -213,7 +213,7 @@@ AT_LALR1_CC_IF([%define global_tokens_a
  m4_ifval([$6], [[%code provides {]], [[%code {]])
  AT_LALR1_CC_IF([typedef yy::location YYLTYPE;])
  [static int yylex (]AT_LEX_FORMALS[);
- ]AT_LALR1_CC_IF([], [static void yyerror (const char *msg);])
+ ]AT_LALR1_CC_IF([], [AT_YYERROR_DECLARE])
  [}
  
  ]m4_ifval([$6], [%type <ival> '(' 'x' 'y' ')' ';' thing line input END])[
@@@ -298,11 -266,11 +266,11 @@@ input
        printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
      }
  | line input /* Right recursive to load the stack so that popping at
 -              END can be exercised.  */
 +                END can be exercised.  */
      {
        $$ = 2;
        printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
 -            $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
 +              $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
      }
  ;
  
@@@ -593,7 -561,8 +561,8 @@@ Parsing FAILED (status 2)
  ]])
  ])
  
- ])
+ AT_BISON_OPTION_POPDEFS
+ ])# _AT_CHECK_PRINTER_AND_DESTRUCTOR
  
  
  # AT_CHECK_PRINTER_AND_DESTRUCTOR([BISON-OPTIONS], [UNION-FLAG], [SKIP_FLAG])
@@@ -603,7 -572,7 +572,7 @@@ m4_define([AT_CHECK_PRINTER_AND_DESTRUC
  
  $3
  _AT_CHECK_PRINTER_AND_DESTRUCTOR($[1], $[2], $[3], $[4],
 -[%error-verbose
 +[%define parse.error verbose
  %debug
  %verbose
  %locations
@@@ -632,9 -601,9 +601,9 @@@ AT_CHECK_PRINTER_AND_DESTRUCTOR([%glr-p
  # called for $end, and that $$ and @$ work correctly.
  
  AT_SETUP([Default tagless %printer and %destructor])
+ AT_BISON_OPTION_PUSHDEFS([%locations])
  AT_DATA_GRAMMAR([[input.y]],
 -[[%error-verbose
 +[[%define parse.error verbose
  %debug
  %locations
  %initial-action {
  %{
  # include <stdio.h>
  # include <stdlib.h>
-   static void yyerror (const char *msg);
-   static int yylex (void);
+ ]AT_YYLEX_DECLARE[
+ ]AT_YYERROR_DECLARE[
  # define USE(SYM)
  %}
  
  start: 'a' 'b' 'c' 'd' 'e' { $$ = 'S'; USE(($1, $2, $3, $4, $5)); } ;
  
  %%
- static int
- yylex (void)
- {
-   static char const input[] = "abcd";
-   static size_t toknum;
-   if (! (toknum < sizeof input))
-     abort ();
-   yylval = input[toknum++];
-   yylloc.first_line = yylloc.last_line = 1;
-   yylloc.first_column = yylloc.last_column = toknum;
-   return yylval;
- }
- static void
- yyerror (const char *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
+ ]AT_YYLEX_DEFINE([abcd], [[yylval = res]])[
  
  int
  main (void)
@@@ -741,6 -693,7 +693,7 @@@ Cleanup: discarding lookahead token $en
  Stack now 0
  ]])
  
+ AT_BISON_OPTION_POPDEFS
  AT_CLEANUP
  
  
  ## ------------------------------------------------------ ##
  
  AT_SETUP([Default tagged and per-type %printer and %destructor])
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([[input.y]],
 -[[%error-verbose
 +[[%define parse.error verbose
  %debug
  
  %{
  # include <stdio.h>
  # include <stdlib.h>
-   static void yyerror (const char *msg);
-   static int yylex (void);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
  # define USE(SYM)
  %}
  
@@@ -805,22 -758,8 +758,8 @@@ start
    ;
  
  %%
- static int
- yylex (void)
- {
-   static char const input[] = "abcdef";
-   static size_t toknum;
-   if (! (toknum < sizeof input))
-     abort ();
-   return input[toknum++];
- }
- static void
- yyerror (const char *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
+ ]AT_YYLEX_DEFINE([abcdef])[
  
  int
  main (void)
@@@ -878,6 -817,7 +817,7 @@@ Cleanup: discarding lookahead token $en
  Stack now 0
  ]])
  
+ AT_BISON_OPTION_POPDEFS
  AT_CLEANUP
  
  
@@@ -895,8 -835,9 +835,9 @@@ m4_define([_AT_CHECK_DEFAULT_PRINTER_AN
    [m4_pushdef([kind], []) m4_pushdef([not_kind], [*])],
    [m4_pushdef([kind], [*]) m4_pushdef([not_kind], [])])
  
+ AT_BISON_OPTION_PUSHDEFS([%locations])
  AT_DATA_GRAMMAR([[input]]$1[[.y]],
 -[[%error-verbose
 +[[%define parse.error verbose
  %debug
  %locations
  %initial-action {
  %{
  # include <stdio.h>
  # include <stdlib.h>
-   static void yyerror (const char *msg);
-   static int yylex (void);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
  # define USE(SYM)
  %}
  
@@@ -950,12 -891,7 +891,7 @@@ yylex (void
    yylloc.first_column = yylloc.last_column = 1;
    return 0;
  }
- static void
- yyerror (const char *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  
  int
  main (void)
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([-o input$1.c input$1.y])
  AT_COMPILE([input$1])
@@@ -1010,15 -947,15 +947,15 @@@ AT_SETUP([Default %printer and %destruc
  #       semantic value, which would be initialized from the lookahead, which
  #       would be destroyed separately.
  #   - For $undefined, who knows what the semantic value would be.
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([[input.y]],
  [[%debug
  
  %{
  # include <stdio.h>
  # include <stdlib.h>
-   static void yyerror (const char *msg);
-   static int yylex (void);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
  # define USE(SYM)
  %}
  
@@@ -1039,24 -976,8 +976,8 @@@ start
    ;
  
  %%
- static int
- yylex (void)
- {
-   static char const input[] = "abd";
-   static size_t toknum;
-   if (! (toknum < sizeof input))
-     abort ();
-   yylval = input[toknum++];
-   return yylval;
- }
- static void
- yyerror (const char *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
+ ]AT_YYLEX_DEFINE([abd], [yylval = res])[
  int
  main (void)
  {
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([-o input.c input.y])
  AT_COMPILE([input])
@@@ -1125,14 -1047,15 +1047,15 @@@ AT_SETUP([Default %printer and %destruc
  #     true for $undefined and the error token, so there are three warnings for
  #     %printer and three for %destructor.)
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([[input.y]],
  [[%debug /* So that %printer is actually compiled.  */
  
  %{
  # include <stdio.h>
  # include <stdlib.h>
-   static void yyerror (const char *msg);
-   static int yylex (void);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
  # define USE(SYM)
  %}
  
  start: { USE($$); } ;
  
  %%
- static int
- yylex (void)
- {
-   static int called;
-   if (called++)
-     abort ();
-   return 0;
- }
- static void
- yyerror (const char *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
+ ]AT_YYLEX_DEFINE([])[
  int
  main (void)
  {
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([-o input.c input.y])
  AT_COMPILE([input])
@@@ -1189,14 -1099,15 +1099,15 @@@ AT_CLEANU
  
  AT_SETUP([Default %printer and %destructor for mid-rule values])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([[input.y]],
  [[%debug /* So that %printer is actually compiled.  */
  
  %{
  # include <stdio.h>
  # include <stdlib.h>
-   static void yyerror (const char *msg);
-   static int yylex (void);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
  # define USE(SYM)
  # define YYLTYPE int
  # define YYLLOC_DEFAULT(Current, Rhs, N) (void)(Rhs)
@@@ -1220,22 -1131,8 +1131,8 @@@ start
    ;
  
  %%
- static int
- yylex (void)
- {
-   static int called;
-   if (called++)
-     abort ();
-   return 0;
- }
- static void
- yyerror (const char *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
+ ]AT_YYLEX_DEFINE([])[
  int
  main (void)
  {
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([-o input.c input.y], 0,,
  [[input.y:33.3-23: warning: unset value: $$
@@@ -1296,15 -1194,15 +1194,15 @@@ AT_CLEANU
  # Bison once forgot to check for @$ in actions other than semantic actions.
  
  # AT_CHECK_ACTION_LOCATIONS(ACTION-DIRECTIVE)
- # -------------------------------------------------------
+ # -------------------------------------------
  m4_define([AT_CHECK_ACTION_LOCATIONS],
  [AT_SETUP([[@$ in ]$1[ implies %locations]])
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([[input.y]],
  [[%code {
    #include <stdio.h>
-   static int yylex (void);
-   static void yyerror (char const *msg);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
  }
  
  %debug
@@@ -1325,12 -1223,7 +1223,7 @@@ yylex (void
    return 0;
  }
  
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  int
  main (void)
  {
  
  AT_BISON_CHECK([[-o input.c input.y]])
  AT_COMPILE([[input]])
+ AT_BISON_OPTION_POPDEFS
  AT_CLEANUP])
  
  AT_CHECK_ACTION_LOCATIONS([[%initial-action]])
@@@ -1357,43 -1250,43 +1250,43 @@@ AT_SETUP([[Fix user actions without a t
  # This feature is undocumented, but we accidentally broke it in 2.3a,
  # and there was a complaint at:
  # <http://lists.gnu.org/archive/html/bug-bison/2008-11/msg00001.html>.
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA([input.y],
  [[%%
  start: test2 test1 test0 testc;
  
  test2
 -: 'a' { semi;                 /* TEST:N:2 */ }
 -| 'b' { if (0) {no_semi}      /* TEST:N:2 */ }
 -| 'c' { if (0) {semi;}                /* TEST:N:2 */ }
 -| 'd' { semi;   no_semi               /* TEST:Y:2 */ }
 -| 'e' { semi(); no_semi()     /* TEST:Y:2 */ }
 -| 'f' { semi[]; no_semi[]     /* TEST:Y:2 */ }
 -| 'g' { semi++; no_semi++     /* TEST:Y:2 */ }
 -| 'h' { {no_semi} no_semi     /* TEST:Y:2 */ }
 -| 'i' { {semi;}   no_semi     /* TEST:Y:2 */ }
 +: 'a' { semi;                   /* TEST:N:2 */ }
 +| 'b' { if (0) {no_semi}        /* TEST:N:2 */ }
 +| 'c' { if (0) {semi;}          /* TEST:N:2 */ }
 +| 'd' { semi;   no_semi         /* TEST:Y:2 */ }
 +| 'e' { semi(); no_semi()       /* TEST:Y:2 */ }
 +| 'f' { semi[]; no_semi[]       /* TEST:Y:2 */ }
 +| 'g' { semi++; no_semi++       /* TEST:Y:2 */ }
 +| 'h' { {no_semi} no_semi       /* TEST:Y:2 */ }
 +| 'i' { {semi;}   no_semi       /* TEST:Y:2 */ }
  ;
  test1
 -  : 'a' { semi;                       // TEST:N:1 ;
 -} | 'b' { if (0) {no_semi}    // TEST:N:1 ;
 -} | 'c' { if (0) {semi;}      // TEST:N:1 ;
 -} | 'd' { semi;   no_semi     // TEST:Y:1 ;
 -} | 'e' { semi(); no_semi()   // TEST:Y:1 ;
 -} | 'f' { semi[]; no_semi[]   // TEST:Y:1 ;
 -} | 'g' { semi++; no_semi++   // TEST:Y:1 ;
 -} | 'h' { {no_semi} no_semi   // TEST:Y:1 ;
 -} | 'i' { {semi;}   no_semi   // TEST:Y:1 ;
 +  : 'a' { semi;                 // TEST:N:1 ;
 +} | 'b' { if (0) {no_semi}      // TEST:N:1 ;
 +} | 'c' { if (0) {semi;}        // TEST:N:1 ;
 +} | 'd' { semi;   no_semi       // TEST:Y:1 ;
 +} | 'e' { semi(); no_semi()     // TEST:Y:1 ;
 +} | 'f' { semi[]; no_semi[]     // TEST:Y:1 ;
 +} | 'g' { semi++; no_semi++     // TEST:Y:1 ;
 +} | 'h' { {no_semi} no_semi     // TEST:Y:1 ;
 +} | 'i' { {semi;}   no_semi     // TEST:Y:1 ;
  } ;
  test0
 -  : 'a' { semi;                       // TEST:N:1 {}
 -} | 'b' { if (0) {no_semi}    // TEST:N:1 {}
 -} | 'c' { if (0) {semi;}      // TEST:N:1 {}
 -} | 'd' { semi;   no_semi     // TEST:Y:1 {}
 -} | 'e' { semi(); no_semi()   // TEST:Y:1 {}
 -} | 'f' { semi[]; no_semi[]   // TEST:Y:1 {}
 -} | 'g' { semi++; no_semi++   // TEST:Y:1 {}
 -} | 'h' { {no_semi} no_semi   // TEST:Y:1 {}
 -} | 'i' { {semi;}   no_semi   // TEST:Y:1 {}
 +  : 'a' { semi;                 // TEST:N:1 {}
 +} | 'b' { if (0) {no_semi}      // TEST:N:1 {}
 +} | 'c' { if (0) {semi;}        // TEST:N:1 {}
 +} | 'd' { semi;   no_semi       // TEST:Y:1 {}
 +} | 'e' { semi(); no_semi()     // TEST:Y:1 {}
 +} | 'f' { semi[]; no_semi[]     // TEST:Y:1 {}
 +} | 'g' { semi++; no_semi++     // TEST:Y:1 {}
 +} | 'h' { {no_semi} no_semi     // TEST:Y:1 {}
 +} | 'i' { {semi;}   no_semi     // TEST:Y:1 {}
  } ;
  
  testc
@@@ -1407,6 -1300,7 +1300,7 @@@ no_sem
  []"broken\" $ @ $$ @$ [];\
  string;"}
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o input.c input.y]], [0], [],
  [[input.y:8.48: warning: a ';' might be needed at the end of action code
@@@ -1462,13 -1356,14 +1356,14 @@@ AT_CLEANU
  
  AT_SETUP([[Destroying lookahead assigned by semantic action]])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([input.y],
  [[
  %code {
    #include <assert.h>
    #include <stdio.h>
-   static void yyerror (char const *);
-   static int yylex (void);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
    #define USE(Var)
  }
  
@@@ -1496,27 -1391,15 +1391,15 @@@ accept: /*empty*/ 
  } ;
  
  %%
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
- static int
- yylex (void)
- {
-   static char const *input = "a";
-   return *input++;
- }
+ ]AT_YYERROR_DEFINE[
+ ]AT_YYLEX_DEFINE([a])[
  int
  main (void)
  {
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  AT_BISON_CHECK([[-o input.c input.y]])
  AT_COMPILE([[input]])
  AT_PARSER_CHECK([[./input]], [[0]], [],
@@@ -1532,6 -1415,8 +1415,8 @@@ AT_CLEANU
  
  AT_SETUP([[YYBACKUP]])
  
+ AT_BISON_OPTION_PUSHDEFS([%pure-parser])
  AT_DATA_GRAMMAR([input.y],
  [[
  %error-verbose
  # include <stdlib.h>
  # include <assert.h>
  
-   static void yyerror (const char *msg);
+   ]AT_YYERROR_DECLARE[
    static int yylex (YYSTYPE *yylval);
  }
  %%
@@@ -1557,6 -1442,7 +1442,7 @@@ exp
  ;
  
  %%
+ ]AT_YYERROR_DEFINE[
  static int
  yylex (YYSTYPE *yylval)
  {
    return input[toknum++];
  }
  
- static void
- yyerror (const char *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
  int
  main (void)
  {
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o input.c input.y]])
  AT_COMPILE([[input]])
diff --combined tests/calc.at
index 477c92d3759f5fe90bb5784c645498db6c796156,77f70cd3b4ebe2b33636a7e14ae54d794be69a5f..5c6c4cc11f539d17f370eaba459b0556643f1d92
  # Don't call this macro directly, because it contains some occurrences
  # of `$1' etc. which will be interpreted by m4.  So you should call it
  # with $1, $2, and $3 as arguments, which is what AT_DATA_CALC_Y does.
+ #
+ # When %defines is not passed, generate a single self-contained file.
+ # Otherwise, generate three: calc.y with the parser, calc-lex.c with
+ # the scanner, and calc-main.c with "main()".  This is in order to
+ # stress the use of the generated parser header.  To avoid code
+ # duplication, AT_CALC_LEX and AT_CALC_MAIN contain the body of these
+ # two later files.
  m4_define([_AT_DATA_CALC_Y],
  [m4_if([$1$2$3], $[1]$[2]$[3], [],
         [m4_fatal([$0: Invalid arguments: $@])])dnl
+ m4_pushdef([AT_CALC_MAIN],
+ [#include <stdlib.h> /* abort */
+ #if HAVE_UNISTD_H
+ # include <unistd.h>
+ #else
+ # undef alarm
+ # define alarm(seconds) /* empty */
+ #endif
+ AT_SKEL_CC_IF([[
+ /* A C++ ]AT_NAME_PREFIX[parse that simulates the C signature.  */
+ 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
+   parser.set_debug_level (1);
+ #endif
+   return parser.parse ();
+ }
+ ]])[
+ semantic_value global_result = 0;
+ int global_count = 0;
+ /* A C main function.  */
+ int
+ main (int argc, const char **argv)
+ {
+   semantic_value result = 0;
+   int count = 0;
+   int status;
+   /* This used to be alarm (10), but that isn't enough time for
+      a July 1995 vintage DEC Alphastation 200 4/100 system,
+      according to Nelson H. F. Beebe.  100 seconds is enough.  */
+   alarm (100);
+   if (argc == 2)
+     input = fopen (argv[1], "r");
+   else
+     input = stdin;
+   if (!input)
+     {
+       perror (argv[1]);
+       return 3;
+     }
+ ]AT_SKEL_CC_IF([], [m4_bmatch([$4], [%debug],
+ [  ]AT_NAME_PREFIX[debug = 1;])])[
+   status = ]AT_NAME_PREFIX[parse (]AT_PARAM_IF([[&result, &count]])[);
+   if (fclose (input))
+     perror ("fclose");
+   if (global_result != result)
+     abort ();
+   if (global_count != count)
+     abort ();
+   return status;
+ }
+ ]])
  m4_pushdef([AT_CALC_LEX],
  [[#include <ctype.h>
  
@@@ -137,12 -208,12 +208,12 @@@ in
      {
        unget_char (]AT_LEX_PRE_ARGS[ c);
        ]AT_VAL[.ival = read_signed_integer (]AT_LEX_ARGS[);
 -      return NUM;
 +      return ]AT_TOKEN_PREFIX[NUM;
      }
  
    /* Return end-of-file.  */
    if (c == EOF)
 -    return CALC_EOF;
 +    return ]AT_TOKEN_PREFIX[CALC_EOF;
  
    /* Return single chars. */
    return c;
@@@ -198,7 -269,9 +269,9 @@@ AT_SKEL_CC_IF
  {
  #include <stdio.h>
  /* The input.  */
- extern FILE *input;]AT_SKEL_CC_IF([[
+ 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
  %code
  {
  #include <assert.h>
- #include <stdlib.h>
  #include <string.h>
- #if HAVE_UNISTD_H
- # include <unistd.h>
- #else
- # undef alarm
- # define alarm(seconds) /* empty */
- #endif
  #define USE(Var)
  
  FILE *input;
- static semantic_value global_result = 0;
- static int global_count = 0;
  static int power (int base, int exponent);
  
  ]AT_SKEL_CC_IF(,
@@@ -234,27 -298,27 +298,27 @@@ static void yyerror (AT_YYERROR_ARG_LOC
  int yylex (]AT_LEX_FORMALS[);
  }
  
 -]AT_SKEL_CC_IF([AT_LOCATION_TYPE_IF([], [
 +]AT_SKEL_CC_IF([AT_LOCATION_IF([AT_LOCATION_TYPE_IF([], [
  /* The lalr1.cc skeleton, for backward compatibility, defines
     a constructor for position that initializes the filename.  The
     glr.cc skeleton does not (and in fact cannot: location/position
     are stored in a union, from which objects with constructors are
 -   excluded in C++. */
 +   excluded in C++). */
  %initial-action {
    @$.initialize ();
  }
 -])])[
 +])])])[
  
  /* Bison Declarations */
  %token CALC_EOF 0 "end of input"
  %token <ival> NUM "number"
  %type  <ival> exp
  
 -%nonassoc '=' /* comparison            */
 +%nonassoc '='   /* comparison          */
  %left '-' '+'
  %left '*' '/'
 -%left NEG     /* negation--unary minus */
 -%right '^'    /* exponentiation        */
 +%precedence NEG /* negation--unary minus */
 +%right '^'      /* exponentiation        */
  
  /* Grammar follows */
  %%
@@@ -289,6 -353,16 +353,16 @@@ exp
  ;
  %%
  
+ static int
+ power (int base, int exponent)
+ {
+   int res = 1;
+   assert (0 <= exponent);
+   for (/* Niente */; exponent; --exponent)
+     res *= base;
+   return res;
+ }
  ]AT_SKEL_CC_IF(
  [AT_LOCATION_TYPE_IF([[
    std::ostream&
  
  /* A C++ error reporting function.  */
  void
 -AT_NAME_PREFIX::parser::error (const location_type& l, const std::string& m)
 +AT_NAME_PREFIX::parser::error (AT_LOCATION_IF([const location_type& l, ])const std::string& m)
  {
 -  (void) l;
    std::cerr << AT_LOCATION_IF([l << ": " << ])m << std::endl;
  }
- /* A C++ yyparse that simulates the C signature.  */
- int
- yyparse (AT_PARAM_IF([semantic_value *result, int *count]))
- {
-   AT_NAME_PREFIX::parser parser[]AT_PARAM_IF([ (result, count)]);
- #if YYDEBUG
-   parser.set_debug_level (1);
- #endif
-   return parser.parse ();
- }
  ],
  [/* A C error reporting function.  */
  static void
@@@ -341,59 -405,21 +404,21 @@@ AT_YYERROR_SEES_LOC_IF(
    fprintf (stderr, "%s\n", s);
  }])[
  
- ]AT_DEFINES_IF(, [AT_CALC_LEX])[
- static int
- power (int base, int exponent)
- {
-   int res = 1;
-   assert (0 <= exponent);
-   for (/* Niente */; exponent; --exponent)
-     res *= base;
-   return res;
- }
- /* A C main function.  */
- int
- main (int argc, const char **argv)
- {
-   semantic_value result = 0;
-   int count = 0;
-   int status;
-   /* This used to be alarm (10), but that isn't enough time for
-      a July 1995 vintage DEC Alphastation 200 4/100 system,
-      according to Nelson H. F. Beebe.  100 seconds is enough.  */
-   alarm (100);
-   if (argc == 2)
-     input = fopen (argv[1], "r");
-   else
-     input = stdin;
-   if (!input)
-     {
-       perror (argv[1]);
-       return 3;
-     }
- ]AT_SKEL_CC_IF([], [m4_bmatch([$4], [%debug],
- [  yydebug = 1;])])[
-   status = yyparse (]AT_PARAM_IF([[&result, &count]])[);
-   if (fclose (input))
-     perror ("fclose");
-   if (global_result != result)
-     abort ();
-   if (global_count != count)
-     abort ();
-   return status;
- }
+ ]AT_DEFINES_IF([],
+ [AT_CALC_LEX
+ AT_CALC_MAIN])[
  ]])
  AT_DEFINES_IF([AT_DATA_SOURCE([[calc-lex.c]AT_SKEL_CC_IF([[c]])],
  [[#include "calc.h]AT_SKEL_CC_IF([[h]])["
  
- ]AT_CALC_LEX])])
+ ]AT_CALC_LEX])
+ AT_DATA_SOURCE([[calc-main.c]AT_SKEL_CC_IF([[c]])],
+ [[#include "calc.h]AT_SKEL_CC_IF([[h]])["
+ ]AT_CALC_MAIN])
+ ])
+ m4_popdef([AT_CALC_MAIN])
  m4_popdef([AT_CALC_LEX])
  ])# _AT_DATA_CALC_Y
  
@@@ -442,7 -468,7 +467,7 @@@ AT_PARSER_CHECK([./calc input], 0, [], 
  # If BISON-OPTIONS contains `%location', then make sure the ERROR-LOCATION
  # is correctly output on stderr.
  #
 -# If BISON-OPTIONS contains `%error-verbose', then make sure the
 +# If BISON-OPTIONS contains `%define parse.error verbose', then make sure the
  # IF-YYERROR-VERBOSE message is properly output after `syntax error, '
  # on STDERR.
  #
@@@ -484,7 -510,7 +509,7 @@@ AT_YYERROR_SEES_LOC_IF([]
  [[sed 's/^[-0-9.]*: //' expout >at-expout
  mv at-expout expout]])
  # 4. If error-verbose is not used, strip the`, unexpected....' part.
 -m4_bmatch([$1], [%error-verbose], [],
 +m4_bmatch([$1], [%define parse.error verbose], [],
  [[sed 's/syntax error, .*$/syntax error/' expout >at-expout
  mv at-expout expout]])
  # 5. Check
@@@ -506,7 -532,7 +531,7 @@@ m4_ifval([$2], [AT_CHECK([exit 77])]
  AT_BISON_OPTION_PUSHDEFS([$1])
  
  AT_DATA_CALC_Y([$1])
- AT_FULL_COMPILE([calc], [AT_DEFINES_IF([[lex]])])
+ AT_FULL_COMPILE([calc], AT_DEFINES_IF([[lex], [main]]))
  
  # Test the priorities.
  _AT_CHECK_CALC([$1],
@@@ -614,22 -640,21 +639,22 @@@ AT_CHECK_CALC_LALR([%locations]
  AT_CHECK_CALC_LALR([%name-prefix="calc"]) dnl test deprecated `='
  AT_CHECK_CALC_LALR([%verbose])
  AT_CHECK_CALC_LALR([%yacc])
 -AT_CHECK_CALC_LALR([%error-verbose])
 +AT_CHECK_CALC_LALR([%define parse.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([%error-verbose %locations])
 +AT_CHECK_CALC_LALR([%define parse.error verbose %locations])
  
 -AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc])
 +AT_CHECK_CALC_LALR([%define parse.error verbose %locations %defines %name-prefix "calc" %verbose %yacc])
 +AT_CHECK_CALC_LALR([%define parse.error verbose %locations %defines %name-prefix "calc" %define api.tokens.prefix "TOK_" %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([%define parse.error verbose %debug %locations %defines %name-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.pure %define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
 +AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %define parse.error verbose %debug %locations %defines %name-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 %define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
  
  
  # ----------------------- #
@@@ -653,20 -678,19 +678,20 @@@ AT_CHECK_CALC_GLR([%locations]
  AT_CHECK_CALC_GLR([%name-prefix "calc"])
  AT_CHECK_CALC_GLR([%verbose])
  AT_CHECK_CALC_GLR([%yacc])
 -AT_CHECK_CALC_GLR([%error-verbose])
 +AT_CHECK_CALC_GLR([%define parse.error verbose])
  
  AT_CHECK_CALC_GLR([%define api.pure %locations])
 -AT_CHECK_CALC_GLR([%error-verbose %locations])
 +AT_CHECK_CALC_GLR([%define parse.error verbose %locations])
  
 -AT_CHECK_CALC_GLR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc])
 +AT_CHECK_CALC_GLR([%define parse.error verbose %locations %defines %name-prefix "calc" %verbose %yacc])
  
  AT_CHECK_CALC_GLR([%debug])
 -AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
 +AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
 +AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %defines %name-prefix "calc" %define api.tokens.prefix "TOK_" %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 %define parse.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 %define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
  
  
  # ----------------------------- #
@@@ -683,19 -707,16 +708,19 @@@ AT_CHECK_CALC([%skeleton "lalr1.cc" %de
  # Start a testing chunk which compiles `calc' grammar with
  # the C++ skeleton, and performs several tests over the parser.
  m4_define([AT_CHECK_CALC_LALR1_CC],
 -[AT_CHECK_CALC([%language "C++" %defines %locations] $@)])
 +[AT_CHECK_CALC([%language "C++" %defines] $@)])
  
  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 %debug %name-prefix "calc" %verbose %yacc])
 +AT_CHECK_CALC_LALR1_CC([%locations])
 +AT_CHECK_CALC_LALR1_CC([%locations %define location_type Span])
 +AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %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([%locations %define parse.error verbose %debug %name-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([%locations %pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc])
 +AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose %debug %name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
 +
 +AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
  
  
  
@@@ -717,12 -738,11 +742,12 @@@ 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([%define parse.error verbose %name-prefix "calc" %verbose %yacc])
  
  AT_CHECK_CALC_GLR_CC([%debug])
 -AT_CHECK_CALC_GLR_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc])
 +AT_CHECK_CALC_GLR_CC([%define parse.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 %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc])
 +AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error verbose %debug %name-prefix "calc" %define api.tokens.prefix "TOK_" %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 %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
diff --combined tests/conflicts.at
index 599d708b54486e24b232b6026f21e2fafcd59788,54df05112fe6344f3e5964319fb0dd1cd80d2b56..6c71a3681d7e59bc63ca95c96e7f6a922a50038f
@@@ -1,6 -1,7 +1,6 @@@
  # Exercising Bison on conflicts.                         -*- Autotest -*-
  
 -# Copyright (C) 2002-2005, 2007, 2009-2012 Free Software Foundation,
 -# Inc.
 +# Copyright (C) 2002-2005, 2007-2012 Free Software Foundation, Inc.
  
  # This program is free software: you can redistribute it and/or modify
  # it under the terms of the GNU General Public License as published by
@@@ -49,6 -50,7 +49,7 @@@ AT_CLEANU
  
  AT_SETUP([%nonassoc and eof])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([input.y],
  [[
  %{
  #include <string.h>
  
  #define YYERROR_VERBOSE 1
- static void
- yyerror (const char *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  /* The current argument. */
  static const char *input;
  
@@@ -92,6 -89,7 +88,7 @@@ main (int argc, const char *argv[]
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  m4_pushdef([AT_NONASSOC_AND_EOF_CHECK],
  [AT_BISON_CHECK([$1[ -o input.c input.y]])
@@@ -144,11 -142,11 +141,11 @@@ AT_CLEANU
  
  
  
 -## -------------------------------------- ##
 -## %error-verbose and consistent errors.  ##
 -## -------------------------------------- ##
 +## ------------------------------------------- ##
 +## parse.error=verbose and consistent errors.  ##
 +## ------------------------------------------- ##
  
 -AT_SETUP([[%error-verbose and consistent errors]])
 +AT_SETUP([[parse.error=verbose and consistent errors]])
  
  m4_pushdef([AT_CONSISTENT_ERRORS_CHECK], [
  
@@@ -166,10 -164,11 +163,10 @@@ AT_SKEL_JAVA_IF([AT_DATA], [AT_DATA_GRA
  }]], [[
  
  %code {]AT_SKEL_CC_IF([[
 -  #include <cassert>
    #include <string>]], [[
    #include <assert.h>
    #include <stdio.h>
-   void yyerror (char const *msg);]])[
+   ]AT_YYERROR_DECLARE])[
    ]AT_YYLEX_PROTOTYPE[;
    #define USE(Var)
  }
  
  ]$1[
  
 -%error-verbose
 +%define parse.error verbose
  
  %%
  
@@@ -210,31 -209,11 +207,11 @@@ public Object getLVal (
    *lvalp = 1;
    return *input++;
  }]])[
- /*----------.
- | yyerror.  |
- `----------*/]AT_SKEL_JAVA_IF([[
- public void yyerror (String msg)
- {
-   System.err.println (msg);
- }
+ ]AT_YYERROR_DEFINE[
+ ]AT_SKEL_JAVA_IF([[
  };
  
- %%]], [AT_SKEL_CC_IF([[
- void
- yy::parser::error (std::string const &msg)
- {
-   std::cerr << msg << std::endl;
- }]], [[
- void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }]])])[
+ %%]])[
  
  /*-------.
  | main.  |
@@@ -393,7 -372,7 +370,7 @@@ error-reduce
  ;
  
  consistent-reduction: /*empty*/ {
 -  assert (yychar == ]AT_SKEL_CC_IF([[yyempty_]], [[YYEMPTY]])[);
 +  assert (yychar == YYEMPTY);
    yylval = 0;
    yychar = 'b';
  } ;
@@@ -417,7 -396,11 +394,7 @@@ AT_CONSISTENT_ERRORS_CHECK([[%glr-parse
                             [AT_USER_ACTION_GRAMMAR],
                             [AT_USER_ACTION_INPUT],
                             [['b']], [[none]])
 -AT_CONSISTENT_ERRORS_CHECK([[%language "c++"]],
 -                           [AT_USER_ACTION_GRAMMAR],
 -                           [AT_USER_ACTION_INPUT],
 -                           [['b']], [[none]])
 -# No Java test because yychar cannot be manipulated by users.
 +# No C++ or Java test because yychar cannot be manipulated by users.
  
  AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reductions consistent]],
                             [AT_USER_ACTION_GRAMMAR],
@@@ -465,12 -448,12 +442,12 @@@ AT_CLEANU
  # with minimal LR parser tables.
  
  AT_SETUP([[LAC: %nonassoc requires splitting canonical LR states]])
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([[input.y]],
  [[%code {
    #include <stdio.h>
-   void yyerror (char const *);
-   int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
  }
  
  %error-verbose
@@@ -507,19 -490,8 +484,8 @@@ look
  reduce-nonassoc: %prec 'a';
  
  %%
- void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
- int
- yylex (void)
- {
-   char const *input = "aaa";
-   return *input++;
- }
+ ]AT_YYERROR_DEFINE[
+ ]AT_YYLEX_DEFINE([aaa])[
  
  int
  main (void)
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  # Show canonical LR's failure.
  AT_BISON_CHECK([[-Dlr.type=canonical-lr -o input.c input.y]],
@@@ -768,62 -741,6 +735,62 @@@ state 
  AT_CLEANUP
  
  
 +## ---------------------- ##
 +## %precedence suffices.  ##
 +## ---------------------- ##
 +
 +AT_SETUP([%precedence suffices])
 +
 +AT_DATA([input.y],
 +[[%precedence "then"
 +%precedence "else"
 +%%
 +stmt:
 +  "if" cond "then" stmt
 +| "if" cond "then" stmt "else" stmt
 +| "stmt"
 +;
 +
 +cond:
 +  "exp"
 +;
 +]])
 +
 +AT_BISON_CHECK([-o input.c input.y])
 +
 +AT_CLEANUP
 +
 +
 +## ------------------------------ ##
 +## %precedence does not suffice.  ##
 +## ------------------------------ ##
 +
 +AT_SETUP([%precedence does not suffice])
 +
 +AT_DATA([input.y],
 +[[%precedence "then"
 +%precedence "else"
 +%%
 +stmt:
 +  "if" cond "then" stmt
 +| "if" cond "then" stmt "else" stmt
 +| "stmt"
 +;
 +
 +cond:
 +  "exp"
 +| cond "then" cond
 +;
 +]])
 +
 +AT_BISON_CHECK([-o input.c input.y], 0, [],
 +[[input.y: conflicts: 1 shift/reduce
 +input.y:12.3-18: warning: rule useless in parser due to conflicts: cond: cond "then" cond
 +]])
 +
 +AT_CLEANUP
 +
 +
  ## -------------------------------- ##
  ## Defaulted Conflicted Reduction.  ##
  ## -------------------------------- ##
diff --combined tests/glr-regression.at
index 4ac48611104f1924f838a6c24f5c9ebaefe1144a,9c534631eded6e00f3c35b522527d254cf536c2b..67c6070730eff8449cfa7cbeff98c8c841f5407b
@@@ -24,6 -24,7 +24,7 @@@ AT_BANNER([[GLR Regression Tests]]
  
  AT_SETUP([Badly Collapsed GLR States])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr1.y],
  [[/* Regression Test: Improper state compression */
  /* Reported by Scott McPeak */
@@@ -34,8 -35,8 +35,8 @@@
  
  #define YYSTYPE int
  static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1);
- int yylex (void);
- void yyerror (char const *msg);
+ ]AT_YYLEX_DECLARE[
+ ]AT_YYERROR_DECLARE[
  %}
  
  
@@@ -71,12 -72,7 +72,7 @@@ main (void
    return yyparse ();
  }
  
- void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  
  int
  yylex (void)
      {
        int ch;
        if (feof (stdin))
 -      abort ();
 +        abort ();
        ch = getchar ();
        if (ch == EOF)
 -      return 0;
 +        return 0;
        else if (ch == 'B' || ch == 'P')
 -      return ch;
 +        return ch;
      }
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr1.c glr-regr1.y]], 0, [],
  [glr-regr1.y: conflicts: 1 shift/reduce
@@@ -119,6 -116,7 +116,7 @@@ AT_CLEANU
  
  AT_SETUP([Improper handling of embedded actions and dollar(-N) in GLR parsers])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr2a.y],
  [[/* Regression Test: Improper handling of embedded actions and $-N  */
  /* Reported by S. Eken */
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
-   int yylex (void);
-   void yyerror (char const *);
+   ]AT_YYLEX_DECLARE[
+   ]AT_YYERROR_DECLARE[
  %}
  
  %glr-parser
@@@ -171,7 -169,7 +169,7 @@@ var_printer: 'v
     { printf ("Variable: '%s'\n", $-1); }
  
  %%
+ ]AT_YYERROR_DEFINE[
  FILE *input;
  
  int
@@@ -181,7 -179,8 +179,8 @@@ yylex (void
    char *s;
    if (feof (stdin))
      abort ();
-   switch (fscanf (input, " %1[a-z,]", buf)) {
+   switch (fscanf (input, " %1[a-z,]", buf))
+   {
    case 1:
      return buf[0];
    case EOF:
    return 'V';
  }
  
- void
- yyerror (char const *s)
- { printf ("%s\n", s);
- }
  int
  main (int argc, char **argv)
  {
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr2a.c glr-regr2a.y]], 0, [],
  [glr-regr2a.y: conflicts: 2 shift/reduce
@@@ -238,6 -233,7 +233,7 @@@ AT_CLEANU
  
  AT_SETUP([Improper merging of GLR delayed action sets])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr3.y],
  [[/* Regression Test: Improper merging of GLR delayed action sets.  */
  /* Reported by M. Rosien */
  #include <stdarg.h>
  
  static int MergeRule (int x0, int x1);
- static void yyerror (char const * s);
- int yylex (void);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
  
  #define RULE(x) (1 << (x))
  
@@@ -290,13 -286,12 +286,12 @@@ NT6 : P1 NT1 O1 T3 P2  { $$ = RULE(11) 
  
  %%
  
- static int MergeRule (int x0, int x1) {
+ static int
+ MergeRule (int x0, int x1)
+ {
    return x0 | x1;
  }
- static void yyerror(char const * s) {
-   fprintf(stderr,"error: %s\n",s);
- }
+ ]AT_YYERROR_DEFINE[
  
  FILE *input = YY_NULL;
  
@@@ -320,12 -315,15 +315,15 @@@ int yylex (void
    return BAD_CHAR;
  }
  
- int main(int argc, char* argv[]) {
+ int
+ main(int argc, char* argv[])
+ {
    input = stdin;
    if (argc == 2 && !(input = fopen (argv[1], "r"))) return 3;
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr3.c glr-regr3.y]], 0, [],
  [glr-regr3.y: conflicts: 1 shift/reduce, 1 reduce/reduce
@@@ -341,12 -339,13 +339,13 @@@ AT_CLEANU
  
  
  ## ------------------------------------------------------------------------- ##
 -## Duplicate representation of merged trees.  See                          ##
 +## Duplicate representation of merged trees.  See                            ##
  ## <http://lists.gnu.org/archive/html/help-bison/2005-07/msg00013.html>.     ##
  ## ------------------------------------------------------------------------- ##
  
  AT_SETUP([Duplicate representation of merged trees])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr4.y],
  [[
  %union { char *ptr; }
    #include <string.h>
    static char *merge (YYSTYPE, YYSTYPE);
    static char *make_value (char const *, char const *);
-   static void yyerror (char const *);
-   static int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
    static char *ptrs[100];
    static char **ptrs_next = ptrs;
  %}
@@@ -384,16 -383,8 +383,8 @@@ A2: 'a' { $$ = make_value ("A2", "'a'")
  B:  'a' { $$ = make_value ("B", "'a'");  } ;
  
  %%
- static int
- yylex (void)
- {
-   static char const input[] = "a";
-   static size_t toknum;
-   if (! (toknum < sizeof input))
-     abort ();
-   return input[toknum++];
- }
+ ]AT_YYERROR_DEFINE[
+ ]AT_YYLEX_DEFINE([a])[
  
  int
  main (void)
@@@ -423,13 -414,8 +414,8 @@@ merge (YYSTYPE s1, YYSTYPE s2
    sprintf (value, format, s1.ptr, s2.ptr);
    return value;
  }
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr4.c glr-regr4.y]], 0, [],
  [glr-regr4.y: conflicts: 1 reduce/reduce
@@@ -444,19 -430,20 +430,20 @@@ AT_CLEANU
  
  
  ## -------------------------------------------------------------------------- ##
 -## User destructor for unresolved GLR semantic value.  See                  ##
 +## User destructor for unresolved GLR semantic value.  See                    ##
  ## <http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00016.html>.   ##
  ## -------------------------------------------------------------------------- ##
  
  AT_SETUP([User destructor for unresolved GLR semantic value])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr5.y],
  [[
  %{
    #include <stdio.h>
    #include <stdlib.h>
-   static void yyerror (char const *);
-   static int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
    enum { MAGIC_VALUE = -1057808125 }; /* originally chosen at random */
  %}
  
@@@ -480,29 -467,15 +467,15 @@@ start
     ;
  
  %%
- static int
- yylex (void)
- {
-   static char const input[] = "a";
-   static size_t toknum;
-   if (! (toknum < sizeof input))
-     abort ();
-   return input[toknum++];
- }
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYLEX_DEFINE(a)[
+ ]AT_YYERROR_DEFINE[
  int
  main (void)
  {
    return yyparse () != 1;
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr5.c glr-regr5.y]], 0, [],
  [glr-regr5.y: conflicts: 1 reduce/reduce
@@@ -517,19 -490,20 +490,20 @@@ AT_CLEANU
  
  
  ## -------------------------------------------------------------------------- ##
 -## User destructor after an error during a split parse.  See                ##
 +## User destructor after an error during a split parse.  See                  ##
  ## <http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00029.html>.   ##
  ## -------------------------------------------------------------------------- ##
  
  AT_SETUP([User destructor after an error during a split parse])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr6.y],
  [[
  %{
    #include <stdio.h>
    #include <stdlib.h>
-   static void yyerror (char const *);
-   static int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
  %}
  
  %glr-parser
@@@ -556,18 -530,14 +530,14 @@@ yylex (void
    return input[toknum++];
  }
  
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  int
  main (void)
  {
    return yyparse () != 1;
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr6.c glr-regr6.y]], 0, [],
  [glr-regr6.y: conflicts: 1 reduce/reduce
@@@ -584,19 -554,20 +554,20 @@@ AT_CLEANU
  
  
  ## ------------------------------------------------------------------------- ##
 -## Duplicated user destructor for lookahead.  See                          ##
 +## Duplicated user destructor for lookahead.  See                            ##
  ## <http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00035.html>.  ##
  ## ------------------------------------------------------------------------- ##
  
  AT_SETUP([Duplicated user destructor for lookahead])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr7.y],
  [[
  %{
    #include <stdio.h>
    #include <stdlib.h>
-   static void yyerror (char const *);
-   static int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
    #define YYSTACKEXPANDABLE 0
    typedef struct count_node {
      int count;
@@@ -641,12 -612,7 +612,7 @@@ yylex (void
    return 'a';
  }
  
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  int
  main (void)
  {
    return status;
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr7.c glr-regr7.y]], 0, [],
  [glr-regr7.y: conflicts: 2 reduce/reduce
@@@ -675,21 -642,22 +642,22 @@@ AT_CLEANU
  
  ## ------------------------------------------------------------------------- ##
  ## Incorrect default location for empty right-hand sides.  Adapted from bug  ##
 -## report by Claudia Hermann.                                              ##
 +## report by Claudia Hermann.                                                ##
  ## See http://lists.gnu.org/archive/html/bug-bison/2005-10/msg00069.html and ##
  ## http://lists.gnu.org/archive/html/bug-bison/2005-10/msg00072.html         ##
  ## ------------------------------------------------------------------------- ##
  
  AT_SETUP([Incorrectly initialized location for empty right-hand side in GLR])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr8.y],
  [[
  %{
    #include <stdio.h>
    #include <stdlib.h>
-   static void yyerror (char const *);
-   static int yylex (void);
-   static void yyerror (char const *msg);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
+   ]AT_YYERROR_DECLARE[
  %}
  
  %token T_CONSTANT
  %%
  
  
 -PortClause    : T_PORT InterfaceDeclaration T_PORT
 -              { printf("%d/%d - %d/%d - %d/%d\n",
 -                       @1.first_column, @1.last_column,
 -                       @2.first_column, @2.last_column,
 -                       @3.first_column, @3.last_column); }
 -      ;
 +PortClause      : T_PORT InterfaceDeclaration T_PORT
 +                { printf("%d/%d - %d/%d - %d/%d\n",
 +                         @1.first_column, @1.last_column,
 +                         @2.first_column, @2.last_column,
 +                         @3.first_column, @3.last_column); }
 +        ;
  
 -InterfaceDeclaration  : OptConstantWord       %dprec 1
 -      | OptSignalWord %dprec 2
 -      ;
 +InterfaceDeclaration    : OptConstantWord       %dprec 1
 +        | OptSignalWord %dprec 2
 +        ;
  
 -OptConstantWord       : /* empty */
 -      | T_CONSTANT
 -      ;
 +OptConstantWord : /* empty */
 +        | T_CONSTANT
 +        ;
  
 -OptSignalWord : /* empty */
 -              { printf("empty: %d/%d\n", @$.first_column, @$.last_column); }
 -      | T_SIGNAL
 -      ;
 +OptSignalWord   : /* empty */
 +                { printf("empty: %d/%d\n", @$.first_column, @$.last_column); }
 +        | T_SIGNAL
 +        ;
  
  %%
  
- void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  static int lexIndex;
  
  int yylex (void)
@@@ -758,6 -721,7 +721,7 @@@ main (void
    return 0;
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr8.c glr-regr8.y]], 0, [],
  [glr-regr8.y: conflicts: 1 reduce/reduce
@@@ -774,19 -738,20 +738,20 @@@ AT_CLEANU
  
  
  ## ------------------------------------------------------------------------- ##
 -## No users destructors if stack 0 deleted.  See                           ##
 +## No users destructors if stack 0 deleted.  See                             ##
  ## <http://lists.gnu.org/archive/html/bison-patches/2005-09/msg00109.html>.  ##
  ## ------------------------------------------------------------------------- ##
  
  AT_SETUP([No users destructors if stack 0 deleted])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr9.y],
  [[
  %{
  # include <stdio.h>
  # include <stdlib.h>
-   static void yyerror (char const *);
-   static int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
  # define YYSTACKEXPANDABLE 0
    static int tokens = 0;
    static int destructors = 0;
@@@ -822,12 -787,7 +787,7 @@@ yylex (void
    return 'a';
  }
  
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  int
  main (void)
  {
    return !exit_status;
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr9.c glr-regr9.y]], 0, [],
  [glr-regr9.y: conflicts: 1 reduce/reduce
@@@ -855,18 -816,19 +816,19 @@@ AT_CLEANU
  
  
  ## ------------------------------------------------------------------------- ##
 -## Corrupted semantic options if user action cuts parse.                   ##
 +## Corrupted semantic options if user action cuts parse.                     ##
  ## ------------------------------------------------------------------------- ##
  
  AT_SETUP([Corrupted semantic options if user action cuts parse])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr10.y],
  [[
  %{
  # include <stdlib.h>
  # include <stdio.h>
-   static void yyerror (char const *);
-   static int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
    #define GARBAGE_SIZE 50
    static char garbage[GARBAGE_SIZE];
  %}
@@@ -884,12 -846,7 +846,7 @@@ start
  
  %%
  
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  static int
  yylex (void)
  {
@@@ -908,6 -865,7 +865,7 @@@ main (void
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr10.c glr-regr10.y]], 0, [],
  [glr-regr10.y: conflicts: 1 reduce/reduce
@@@ -920,17 -878,18 +878,18 @@@ AT_CLEANU
  
  
  ## ------------------------------------------------------------------------- ##
 -## Undesirable destructors if user action cuts parse.                      ##
 +## Undesirable destructors if user action cuts parse.                        ##
  ## ------------------------------------------------------------------------- ##
  
  AT_SETUP([Undesirable destructors if user action cuts parse])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr11.y],
  [[
  %{
  # include <stdlib.h>
-   static void yyerror (char const *);
-   static int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
    static int destructors = 0;
  # define USE(val)
  %}
@@@ -949,21 -908,8 +908,8 @@@ start
  
  %%
  
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
- static int
- yylex (void)
- {
-   static char const input[] = "a";
-   static size_t toknum;
-   if (! (toknum < sizeof input))
-     abort ();
-   return input[toknum++];
- }
+ ]AT_YYERROR_DEFINE[
+ ]AT_YYLEX_DEFINE([a])[
  
  int
  main (void)
    return exit_status;
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr11.c glr-regr11.y]], 0, [],
  [glr-regr11.y: conflicts: 1 reduce/reduce
@@@ -989,11 -936,12 +936,12 @@@ AT_CLEANU
  
  
  ## ------------------------------------------------------------------------- ##
 -## Leaked semantic values if user action cuts parse.                       ##
 +## Leaked semantic values if user action cuts parse.                         ##
  ## ------------------------------------------------------------------------- ##
  
  AT_SETUP([Leaked semantic values if user action cuts parse])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr12.y],
  [[
  %glr-parser
  %{
  # include <stdlib.h>
    static int merge (YYSTYPE, YYSTYPE);
-   static void yyerror (char const *);
-   static int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
    static int parent_rhs_before_value = 0;
    static int merged_value = 0;
    static int parent_rhs_after_value = 0;
@@@ -1068,12 -1016,7 +1016,7 @@@ merge (YYSTYPE s1, YYSTYPE s2
    return dummy;
  }
  
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  static int
  yylex (void)
  {
@@@ -1108,6 -1051,7 +1051,7 @@@ main (void
    return exit_status;
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr12.c glr-regr12.y]], 0, [],
  [glr-regr12.y: conflicts: 1 shift/reduce, 1 reduce/reduce
@@@ -1120,13 -1064,14 +1064,14 @@@ AT_CLEANU
  
  
  ## ------------------------------------------------------------------------- ##
 -## Incorrect lookahead during deterministic GLR.  See                      ##
 +## Incorrect lookahead during deterministic GLR.  See                        ##
  ## <http://lists.gnu.org/archive/html/help-bison/2005-07/msg00017.html> and  ##
  ## <http://lists.gnu.org/archive/html/bison-patches/2006-01/msg00060.html>.  ##
  ## ------------------------------------------------------------------------- ##
  
  AT_SETUP([Incorrect lookahead during deterministic GLR])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr13.y],
  [[
  /* Tests:
  
  %{
    #include <stdio.h>
-   static void yyerror (char const *);
-   static int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
    static void print_lookahead (char const *);
    #define USE(value)
  %}
@@@ -1190,12 -1135,7 +1135,7 @@@ change_lookahead
  
  %%
  
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  static int
  yylex (void)
  {
@@@ -1221,10 -1161,10 +1161,10 @@@ print_lookahead (char const *reduction
      {
        printf ("'%c', yylval='", yychar);
        if (yylval.value > ' ')
 -      printf ("%c", yylval.value);
 +        printf ("%c", yylval.value);
        printf ("', yylloc=(%d,%d),(%d,%d)",
 -            yylloc.first_line, yylloc.first_column,
 -            yylloc.last_line, yylloc.last_column);
 +              yylloc.first_line, yylloc.first_column,
 +              yylloc.last_line, yylloc.last_column);
      }
    printf ("\n");
  }
@@@ -1237,6 -1177,7 +1177,7 @@@ main (void
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr13.c glr-regr13.y]], 0, [], [])
  AT_COMPILE([glr-regr13])
@@@ -1258,11 -1199,12 +1199,12 @@@ AT_CLEANU
  
  
  ## ------------------------------------------------------------------------- ##
 -## Incorrect lookahead during nondeterministic GLR.                        ##
 +## Incorrect lookahead during nondeterministic GLR.                          ##
  ## ------------------------------------------------------------------------- ##
  
  AT_SETUP([Incorrect lookahead during nondeterministic GLR])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr14.y],
  [[
  /* Tests:
  %{
    #include <stdlib.h>
    #include <stdio.h>
-   static void yyerror (char const *);
-   static int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
    static void print_lookahead (char const *);
    static char merge (union YYSTYPE, union YYSTYPE);
    #define USE(value)
@@@ -1318,7 -1260,7 +1260,7 @@@ merge
    | conflict defstate_look 'a' nonconflict2 'b' defstate_shift %dprec 2 {
      USE ($3); USE ($5);
      print_lookahead ("merge <- conflict defstate_look 'a' nonconflict2 'b'"
 -                    " defstate_shift");
 +                      " defstate_shift");
    }
    ;
  
@@@ -1365,7 -1307,7 +1307,7 @@@ alt1
      USE ($1);
      if (yychar != 'd' && yychar != YYEOF)
        {
 -      fprintf (stderr, "Incorrect lookahead during stack explosion.\n");
 +        fprintf (stderr, "Incorrect lookahead during stack explosion.\n");
        }
    }
    ;
@@@ -1374,7 -1316,7 +1316,7 @@@ alt2
      USE ($1);
      if (yychar != 'd' && yychar != YYEOF)
        {
 -      fprintf (stderr, "Incorrect lookahead during stack explosion.\n");
 +        fprintf (stderr, "Incorrect lookahead during stack explosion.\n");
        }
    }
    ;
@@@ -1383,7 -1325,7 +1325,7 @@@ alt3
      USE ($1);
      if (yychar != 'd' && yychar != YYEOF)
        {
 -      fprintf (stderr, "Incorrect lookahead during stack explosion.\n");
 +        fprintf (stderr, "Incorrect lookahead during stack explosion.\n");
        }
    }
    ;
@@@ -1391,20 -1333,15 +1333,15 @@@ no_look
    {
      if (yychar != YYEMPTY)
        {
 -      fprintf (stderr,
 -               "Found lookahead where shouldn't during stack explosion.\n");
 +        fprintf (stderr,
 +                 "Found lookahead where shouldn't during stack explosion.\n");
        }
    }
    ;
  
  %%
  
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  static int
  yylex (void)
  {
@@@ -1430,10 -1367,10 +1367,10 @@@ print_lookahead (char const *reduction
      {
        printf ("'%c', yylval='", yychar);
        if (yylval.value > ' ')
 -      printf ("%c", yylval.value);
 +        printf ("%c", yylval.value);
        printf ("', yylloc=(%d,%d),(%d,%d)",
 -            yylloc.first_line, yylloc.first_column,
 -            yylloc.last_line, yylloc.last_column);
 +              yylloc.first_line, yylloc.first_column,
 +              yylloc.last_line, yylloc.last_column);
      }
    printf ("\n");
  }
@@@ -1453,6 -1390,7 +1390,7 @@@ main (void
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr14.c glr-regr14.y]], 0, [],
  [glr-regr14.y: conflicts: 3 reduce/reduce
@@@ -1478,11 -1416,12 +1416,12 @@@ AT_CLEANU
  
  
  ## ------------------------------------------------------------------------- ##
 -## Leaked semantic values when reporting ambiguity.                        ##
 +## Leaked semantic values when reporting ambiguity.                          ##
  ## ------------------------------------------------------------------------- ##
  
  AT_SETUP([Leaked semantic values when reporting ambiguity])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr15.y],
  [[
  %glr-parser
  
  %{
  # include <stdlib.h>
-   static void yyerror (char const *);
-   static int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
    static int parent_rhs_before_value = 0;
  # define USE(val)
  %}
@@@ -1530,12 -1469,7 +1469,7 @@@ ambiguity2: 
  
  %%
  
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  static int
  yylex (void)
  {
@@@ -1557,6 -1491,7 +1491,7 @@@ main (void
    return exit_status;
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr15.c glr-regr15.y]], 0, [],
  [glr-regr15.y: conflicts: 2 reduce/reduce
@@@ -1571,10 -1506,12 +1506,12 @@@ AT_CLEANU
  
  
  ## ------------------------------------------------------------------------- ##
 -## Leaked lookahead after nondeterministic parse syntax error.                     ##
 +## Leaked lookahead after nondeterministic parse syntax error.               ##
  ## ------------------------------------------------------------------------- ##
  
  AT_SETUP([Leaked lookahead after nondeterministic parse syntax error])
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr16.y],
  [[
  %glr-parser
  
  %{
  # include <stdlib.h>
-   static void yyerror (char const *);
-   static int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
    static int lookahead_value = 0;
  # define USE(val)
  %}
@@@ -1596,12 -1533,7 +1533,7 @@@ alt2: 
  
  %%
  
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  static int
  yylex (void)
  {
@@@ -1626,6 -1558,7 +1558,7 @@@ main (void
    return exit_status;
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr16.c glr-regr16.y]], 0, [],
  [glr-regr16.y: conflicts: 1 reduce/reduce
@@@ -1640,10 -1573,12 +1573,12 @@@ AT_CLEANU
  
  
  ## ------------------------------------------------------------------------- ##
 -## Uninitialized location when reporting ambiguity.                        ##
 +## Uninitialized location when reporting ambiguity.                          ##
  ## ------------------------------------------------------------------------- ##
  
  AT_SETUP([Uninitialized location when reporting ambiguity])
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr17.y],
  [[
  %glr-parser
@@@ -1713,6 -1648,7 +1648,7 @@@ main (void
    return yyparse () != 1;
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr17.c glr-regr17.y]], 0, [],
  [glr-regr17.y: conflicts: 3 reduce/reduce
@@@ -1731,12 -1667,14 +1667,14 @@@ AT_CLEANU
  ## -------------------------------------------------------------##
  
  AT_SETUP([Missed %merge type warnings when LHS type is declared later])
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([glr-regr18.y],
  [[%glr-parser
  
  %{
    #include <stdlib.h>
-   static void yyerror (char const *);
+   ]AT_YYERROR_DECLARE[
    static int yylex ();
  %}
  
@@@ -1758,27 -1696,15 +1696,15 @@@ sym3: %merge<merge> { $$ = 0; } 
  
  %%
  
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
- static int
- yylex ()
- {
-   static int called;
-   if (called++)
-     abort ();
-   return 0;
- }
+ ]AT_YYERROR_DEFINE[
+ ]AT_YYLEX_DEFINE()[
  int
  main (void)
  {
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o glr-regr18.c glr-regr18.y]], 1, [],
  [glr-regr18.y:26.18-24: result type clash on merge function 'merge': <type2> != <type1>
@@@ -1796,13 -1722,14 +1722,14 @@@ AT_CLEANU
  
  AT_SETUP([Ambiguity reports])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([input.y],
  [[
  %{
    #include <stdio.h>
    #include <stdlib.h>
-   static void yyerror (char const *);
-   static int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
  %}
  
  %debug
@@@ -1816,23 -1743,8 +1743,8 @@@ start
  b: 'b';
  d: /* nada.  */;
  %%
- static int
- yylex (void)
- {
-   static char const input[] = "abc";
-   static size_t toknum;
-   if (! (toknum < sizeof input))
-     abort ();
-   return input[toknum++];
- }
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYLEX_DEFINE([abc])[
+ ]AT_YYERROR_DEFINE[
  int
  main (void)
  {
    return !!yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o input.c input.y]], 0, [],
  [input.y: conflicts: 1 reduce/reduce
diff --combined tests/input.at
index d0bc51a75aa06937570cf187ae1e24adb266ba0a,2f667d0ad5c6a6a3adf3b6a9751bb86bf48bcaf7..d94b652ec6cb36cf45b1596e3d087bbee66f4adf
@@@ -69,9 -69,10 +69,9 @@@ AT_CLEANU
  
  
  # _AT_UNUSED_VALUES_DECLARATIONS()
 -# --------------------------------------------
 +# --------------------------------
  # Generate the token, type, and destructor
  # declarations for the unused values tests.
 -
  m4_define([_AT_UNUSED_VALUES_DECLARATIONS],
  [[[%token <integer> INT;
  %type <integer> a b c d e f g h i j k l;
  
  
  # AT_CHECK_UNUSED_VALUES(DECLARATIONS_AFTER, CHECK_MIDRULE_VALUES)
 -# ------------------------------------------------------------------
 -# Generate a grammar to test unused values,
 -# compile it, run it.  If DECLARATIONS_AFTER
 -# is set, then the token, type, and destructor
 -# declarations are generated after the rules
 -# rather than before.  If CHECK_MIDRULE_VALUES
 -# is set, then --warnings=midrule-values is
 -# set.
 -
 +# ----------------------------------------------------------------
 +# Generate a grammar to test unused values, compile it, run it.  If
 +# DECLARATIONS_AFTER is set, then the token, type, and destructor
 +# declarations are generated after the rules rather than before.  If
 +# CHECK_MIDRULE_VALUES is set, then --warnings=midrule-values is set.
  m4_define([AT_CHECK_UNUSED_VALUES],
  [AT_DATA([input.y],
  m4_ifval($1, [
@@@ -386,7 -391,7 +386,7 @@@ AT_CLEANU
  
  AT_SETUP([Torturing the Scanner])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA([input.y], [])
  AT_BISON_CHECK([input.y], [1], [],
  [[input.y:1.1: syntax error, unexpected end of file
@@@ -463,8 -468,8 +463,8 @@@ char quote[] = "@:>@@:>@,"
  %}
  
  %{
- static void yyerror (const char *s);
- static int yylex (void);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
  %}
  
  %type <ival> '@<:@'
@@@ -496,7 -501,7 +496,7 @@@ value_as_yystype (value val
    res.ival = val;
    return res;
  }
+ ]AT_YYERROR_DEFINE[
  static int
  yylex (void)
  {
    yylval = value_as_yystype (input[toknum]);
    return input[toknum++];
  }
- static void
- yyerror (const char *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
  ]])
  
 -# Pacify Emacs' font-lock-mode: "
 +# Pacify Emacs'font-lock-mode: "
  
  AT_DATA([main.c],
  [[typedef int value;
@@@ -531,6 -530,7 +525,7 @@@ main (void
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([-d -v -o input.c input.y])
  AT_COMPILE([input.o], [-c input.c])
@@@ -595,8 -595,8 +590,8 @@@ AT_CHECK_REQUIRE(100.0, 63
  
  AT_SETUP([String aliases for character tokens])
  
 -# Bison once thought a character token and its alias were different symbols
 -# with the same user token number.
 +# Bison once thought a character token and its alias were different
 +# symbols with the same user token number.
  
  AT_DATA_GRAMMAR([input.y],
  [[%token 'a' "a"
@@@ -616,14 -616,15 +611,15 @@@ AT_CLEANU
  
  AT_SETUP([Symbols])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([input.y],
  [[%token WITH-DASH
  %token WITHOUT_DASH "WITHOUT-DASH"
  %token WITH.PERIOD
  %token WITHOUT_PERIOD "WITHOUT.PERIOD"
  %code {
-   void yyerror (char const *);
-   int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
  }
  %%
  start: with-dash without_dash with.period without_period;
@@@ -632,7 -633,10 +628,10 @@@ without_dash: "WITHOUT-DASH"
  with.period: WITH.PERIOD;
  without_period: "WITHOUT.PERIOD";
  %%
+ ]AT_YYERROR_DEFINE[
+ ]AT_YYLEX_DEFINE[
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  # POSIX Yacc accept periods, but not dashes.
  AT_BISON_CHECK([--yacc input.y], [1], [],
@@@ -716,10 -720,10 +715,10 @@@ AT_CLEANU
  
  AT_SETUP([Unclosed constructs])
  
 -# Bison's scan-gram.l once forgot to STRING_FINISH some unclosed constructs, so
 -# they were prepended to whatever it STRING_GROW'ed next.  It also threw them
 -# away rather than returning them to the parser.  The effect was confusing
 -# subsequent error messages.
 +# Bison's scan-gram.l once forgot to STRING_FINISH some unclosed
 +# constructs, so they were prepended to whatever it STRING_GROW'ed
 +# next.  It also threw them away rather than returning them to the
 +# parser.  The effect was confusing subsequent error messages.
  
  AT_DATA([input.y],
  [[%token A "a
@@@ -761,8 -765,8 +760,8 @@@ AT_CLEANU
  
  AT_SETUP([%start after first rule])
  
 -# Bison once complained that a %start after the first rule was a redeclaration
 -# of the start symbol.
 +# Bison once complained that a %start after the first rule was a
 +# redeclaration of the start symbol.
  
  AT_DATA([input.y],
  [[%%
@@@ -1079,17 -1083,6 +1078,17 @@@ AT_BISON_CHECK([[input.y]], [1], []
  [[input.y:1.9-34: invalid value for %define Boolean variable 'lr.keep-unreachable-states'
  ]])
  
 +AT_DATA([[input.y]],
 +[[%define namespace "foo"
 +%define api.namespace "foo"
 +%%
 +start: ;
 +]])
 +AT_BISON_CHECK([[input.y]], [1], [],
 +[[input.y:2.9-21: %define variable 'api.namespace' redefined
 +input.y:1.9-17: previous definition
 +]])
 +
  AT_DATA([[input.y]],
  [[%define foo_bar "baz"
  %%
@@@ -1148,14 -1141,14 +1147,14 @@@ m4_define([AT_CHECK_NAMESPACE_ERROR]
  AT_DATA([[input.y]],
  [[%language "C++"
  %defines
 -%define namespace "]$1["
 +%define api.namespace "]$1["
  %%
  start: ;
  ]])
  
  AT_BISON_CHECK([[input.y]], [1], [],
  [m4_foreach([b4_arg], m4_dquote(m4_shift($@)),
 -[[input.y:3.9-17: ]b4_arg[
 +[[input.y:3.9-21: ]b4_arg[
  ]])])
  ])
  
diff --combined tests/local.at
index a53f1d17adc4201c967024b6412426b72522e1e1,6d3ff18f9568b6091af13f4dc529d7d410a88b2b..0d24a44a3d0bf7242e9d230996eea3b69e5b96f2
@@@ -98,7 -98,7 +98,7 @@@ m4_define([AT_BISON_OPTION_PUSHDEFS]
  # --------------------------------------------------
  # This macro works around the impossibility to define macros
  # inside macros, because issuing `[$1]' is not possible in M4 :(.
 -# This sucks hard, GNU M4 should really provide M5 like $$1.
 +# This sucks hard, GNU M4 should really provide M5-like $$1.
  m4_define([_AT_BISON_OPTION_PUSHDEFS],
  [m4_if([$1$2], $[1]$[2], [],
         [m4_fatal([$0: Invalid arguments: $@])])dnl
@@@ -109,7 -109,7 +109,7 @@@ m4_pushdef([AT_SKEL_CC_IF]
  m4_pushdef([AT_SKEL_JAVA_IF],
  [m4_bmatch([$3], [%language "[Jj][Aa][Vv][Aa]"\|%skeleton "[a-z0-9]+\.java"], [$1], [$2])])
  m4_pushdef([AT_GLR_IF],
- [m4_bmatch([$3], [%glr-parser\|%skeleton "glr\.], [$1], [$2])])
+ [m4_bmatch([$3], [%glr-parser\|%skeleton "glr\..*"], [$1], [$2])])
  m4_pushdef([AT_LALR1_CC_IF],
  [AT_SKEL_CC_IF([AT_GLR_IF([$2], [$1])], [$2])])
  m4_pushdef([AT_GLR_CC_IF],
@@@ -135,42 -135,43 +135,46 @@@ m4_pushdef([AT_GLR_OR_PARAM_IF]
  [m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])])
  m4_pushdef([AT_NAME_PREFIX],
  [m4_bmatch([$3], [%name-prefix ".*"],
-            [m4_bregexp([$3], [name-prefix "\([^"]*\)"], [\1])],
+            [m4_bregexp([$3], [name-prefix "\([^""]*\)"], [\1])],
+            [yy])])
+ m4_pushdef([AT_API_PREFIX],
+ [m4_bmatch([$3], [%define api\.prefix ".*"],
+            [m4_bregexp([$3], [%define api\.prefix "\([^""]*\)"], [\1])],
             [yy])])
 +m4_pushdef([AT_TOKEN_PREFIX],
 +[m4_bmatch([$3], [%define api.tokens.prefix ".*"],
 +           [m4_bregexp([$3], [%define api.tokens.prefix "\(.*\)"], [\1])])])
  # yyerror receives the location if %location & %pure & (%glr or %parse-param).
  m4_pushdef([AT_YYERROR_ARG_LOC_IF],
  [AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
 -                  [$2])])
 +                    [$2])])
  # yyerror always sees the locations (when activated), except if
  # (yacc & pure & !param).  FIXME: This is wrong.  See the manual.
  m4_pushdef([AT_YYERROR_SEES_LOC_IF],
  [AT_LOCATION_IF([AT_YACC_IF([AT_PURE_IF([AT_PARAM_IF([$1], [$2])],
 -                                      [$1])],
 -                          [$1])],
 -              [$2])])
 +                                        [$1])],
 +                            [$1])],
 +                [$2])])
  
  # The interface is pure: either because %define api.pure, or because we
  # are using the C++ parsers.
  m4_pushdef([AT_PURE_LEX_IF],
  [AT_PURE_IF([$1],
 -          [AT_SKEL_CC_IF([$1], [$2])])])
 +            [AT_SKEL_CC_IF([$1], [$2])])])
  
  AT_PURE_LEX_IF(
  [m4_pushdef([AT_LOC], [(*llocp)])
   m4_pushdef([AT_VAL], [(*lvalp)])
   m4_pushdef([AT_LEX_FORMALS],
 -          [YYSTYPE *lvalp[]AT_LOCATION_IF([, YYLTYPE *llocp])])
 +            [YYSTYPE *lvalp[]AT_LOCATION_IF([, YYLTYPE *llocp])])
   m4_pushdef([AT_LEX_ARGS],
 -          [lvalp[]AT_LOCATION_IF([, llocp])])
 +            [lvalp[]AT_LOCATION_IF([, llocp])])
   m4_pushdef([AT_USE_LEX_ARGS],
 -          [(void) lvalp;AT_LOCATION_IF([(void) llocp])])
 +            [(void) lvalp;AT_LOCATION_IF([(void) llocp])])
   m4_pushdef([AT_LEX_PRE_FORMALS],
 -          [AT_LEX_FORMALS, ])
 +            [AT_LEX_FORMALS, ])
   m4_pushdef([AT_LEX_PRE_ARGS],
 -          [AT_LEX_ARGS, ])
 +            [AT_LEX_ARGS, ])
  ],
  [m4_pushdef([AT_LOC], [[(]AT_NAME_PREFIX[lloc)]])
   m4_pushdef([AT_VAL], [[(]AT_NAME_PREFIX[lval)]])
@@@ -189,8 -190,6 +193,8 @@@ AT_SKEL_CC_IF
      [AT_LOC_PUSHDEF([begin.line], [begin.column], [end.line], [end.column])])],
    [AT_LOC_PUSHDEF([first_line], [first_column], [last_line], [last_column])])
  
 +
 +AT_GLR_IF([AT_KEYWORDS([glr])])
  ])# _AT_BISON_OPTION_PUSHDEFS
  
  
@@@ -207,6 -206,7 +211,7 @@@ m4_popdef([AT_LOC]
  m4_popdef([AT_PURE_LEX_IF])
  m4_popdef([AT_YYERROR_SEES_LOC_IF])
  m4_popdef([AT_YYERROR_ARG_LOC_IF])
+ m4_popdef([AT_API_PREFIX])
  m4_popdef([AT_NAME_PREFIX])
  m4_popdef([AT_GLR_OR_PARAM_IF])
  m4_popdef([AT_PURE_AND_LOC_IF])
@@@ -272,6 -272,70 +277,70 @@@ m4_define([AT_DATA_GRAMMAR]
  $2])
  ])
  
+ # AT_YYLEX_DECLARE_EXTERN
+ # AT_YYLEX_DECLARE
+ # AT_YYLEX_DEFINE(INPUT-STRING, [ACTION])
+ # ---------------------------------------
+ m4_define([AT_YYLEX_DECLARE_EXTERN],
+ [int AT_API_PREFIX[]lex (void);dnl
+ ])
+ m4_define([AT_YYLEX_DECLARE],
+ [static AT_YYLEX_DECLARE_EXTERN[]dnl
+ ])
+ m4_define([AT_YYLEX_DEFINE],
+ [[#include <stdlib.h> /* abort */
+ static int
+ ]AT_API_PREFIX[lex (void)
+ {
+   static char const input[] = "$1";
+   static size_t toknum = 0;
+   int res;
+   if (! (toknum < sizeof input))
+     abort ();
+   res = input[toknum++];
+   ]$2;[]AT_LOCATION_IF([[
+   ]AT_API_PREFIX[lloc.first_line = ]AT_API_PREFIX[lloc.last_line = 1;
+   ]AT_API_PREFIX[lloc.first_column = ]AT_API_PREFIX[lloc.last_column = toknum;]])[
+   return res;
+ }]dnl
+ ])
+ # AT_YYERROR_DECLARE_EXTERN
+ # AT_YYERROR_DECLARE
+ # AT_YYERROR_DEFINE
+ # -------------------------
+ # Beware that must be called inside a AT_BISON_OPTION_PUSHDEFS/POPDEFS
+ # pair.
+ m4_define([AT_YYERROR_DECLARE_EXTERN],
+ [void AT_API_PREFIX[]error (const char *msg);dnl
+ ])
+ m4_define([AT_YYERROR_DECLARE],
+ [static AT_YYERROR_DECLARE_EXTERN[]dnl
+ ])
+ m4_define([AT_YYERROR_DEFINE],
+ [AT_SKEL_JAVA_IF([[public void yyerror (String msg)
+ {
+   System.err.println (msg);
+ }]], [AT_SKEL_CC_IF([[void
+ yy::parser::error (const yy::location &, std::string const &msg)
+ {
+   std::cerr << msg << std::endl;
+ }]], [[#include <stdio.h>
+ static void
+ ]AT_API_PREFIX[error (char const *msg)
+ {
+   fprintf (stderr, "%s\n", msg);
+ }]])])dnl
+ ])
+ ## --------------- ##
+ ## Running Bison.  ##
+ ## --------------- ##
  # AT_BISON_CHECK(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
  # -------------------------------------------------
  # Check Bison by invoking `bison BISON_ARGS'.  BISON_ARGS should not contain
@@@ -431,7 -495,7 +500,7 @@@ m4_define([AT_QUELL_VALGRIND]
  # assume that we are linking too; this is a hack.
  m4_define([AT_COMPILE],
  [AT_CHECK([$CC $CFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1 m4_default([$2], [$1.c])[]m4_bmatch([$1], [[.]], [], [ $LIBS])],
 -         0, [ignore], [ignore])])
 +           0, [ignore], [ignore])])
  
  # AT_COMPILE_CXX(OUTPUT, [SOURCES = OUTPUT.cc])
  # --------------------------------------------
@@@ -442,7 -506,7 +511,7 @@@ m4_define([AT_COMPILE_CXX]
  [AT_KEYWORDS(c++)
  AT_CHECK([$BISON_CXX_WORKS], 0, ignore, ignore)
  AT_CHECK([$CXX $CXXFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1 m4_default([$2], [$1.cc])[]m4_bmatch([$1], [[.]], [], [ $LIBS])],
 -       0, [ignore], [ignore])])
 +         0, [ignore], [ignore])])
  
  # AT_JAVA_COMPILE(SOURCES)
  # ------------------------
@@@ -455,8 -519,8 +524,8 @@@ AT_CHECK([[test -n "$CONF_JAVA" || exi
  AT_CHECK([[$SHELL ../../../javacomp.sh ]$1],
           [[0]], [ignore], [ignore])])
  
- # AT_FULL_COMPILE(OUTPUT, [OTHER])
- # --------------------------------
+ # AT_FULL_COMPILE(OUTPUT, [OTHER1], [OTHER2])
+ # -------------------------------------------
  # Compile OUTPUT.y to OUTPUT.c, OUTPUT.cc, or OUTPUT.java, and then
  # compile it to OUTPUT or OUTPUT.class.  If OTHER is specified, compile
  # OUTPUT-OTHER.c, OUTPUT-OTHER.cc, or OUTPUT-OTHER.java to OUTPUT or
  # AT_SKEL_JAVA_IF.
  m4_define([AT_FULL_COMPILE], [
    AT_SKEL_JAVA_IF([
-     AT_BISON_CHECK([[-o ]$1[.java ]$1[.y]])
-     AT_JAVA_COMPILE([$1[.java]]m4_ifval($2,
-                                         [[$1[.java ]$1[-]$2[.java]]]))
+     AT_BISON_CHECK([-o $1.java $1.y])
+     AT_JAVA_COMPILE([$1.java],
+                     m4_join([ ],
+                             [$1.java],
+                             m4_ifval($2, [[$1-$2.java]]),
+                             m4_ifval($3, [[$1-$3.java]])))
    ], [
      AT_SKEL_CC_IF([
-       AT_BISON_CHECK([[-o ]$1[.cc ]$1[.y]])
-       AT_COMPILE_CXX([$1]m4_ifval($2, [, [$1[.cc ]$1[-]$2[.cc]]]))
+       AT_BISON_CHECK([-o $1.cc $1.y])
+       AT_COMPILE_CXX([$1],
+                      m4_join([ ],
+                              [$1.cc],
+                              m4_ifval($2, [[$1-$2.cc]]),
+                              m4_ifval($3, [[$1-$3.cc]])))
      ], [
-       AT_BISON_CHECK([[-o ]$1[.c ]$1[.y]])
-       AT_COMPILE([$1]m4_ifval($2, [, [$1[.c ]$1[-]$2[.c]]]))
+       AT_BISON_CHECK([-o $1.c $1.y])
+       AT_COMPILE([$1],
+                   m4_join([ ],
 -                        [$1.c],
++                          [$1.c],
+                           m4_ifval($2, [[$1-$2.c]]),
+                           m4_ifval($3, [[$1-$3.c]])))
      ])
    ])
  ])
@@@ -582,12 -657,12 +662,12 @@@ m4_define([AT_TEST_TABLES_AND_PARSE]
  [m4_pushdef([AT_COND_CASE], [m4_case([$2], $][@)])
  
  AT_SETUP([$1])
+ AT_BISON_OPTION_PUSHDEFS([$4])
  AT_DATA_GRAMMAR([[input.y]],
  [[%code {
    #include <stdio.h>
-   static void yyerror (char const *msg);
-   static int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
  }
  
  ]$4[
  ]$5[
  
  %%
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  static int
  yylex (void)
  {
@@@ -659,6 -728,7 +733,7 @@@ AT_PARSER_CHECK([[./input]]
                  m4_ifval([$11], [m4_dquote($11)]),
                  m4_ifval([$12], [m4_dquote($12)]))
  
+ AT_BISON_OPTION_POPDEFS
  AT_CLEANUP
  
  m4_popdef([AT_COND_CASE])])
diff --combined tests/named-refs.at
index 0b2f4c94ef1641ebf9e6e5b86b284eed402b96ec,c9b91a0e1dbf2d4517b39f0dd6a31108b4fe0da1..0e6f60c8eeabafd79c32795494c60661f9db8d26
@@@ -19,7 -19,7 +19,7 @@@
  AT_BANNER([[Named references tests.]])
  
  AT_SETUP([Tutorial calculator])
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([test.y],
  [[
  %{
@@@ -33,8 -33,8 +33,8 @@@ FILE *input
  static semantic_value global_result = 0;
  static int global_count = 0;
  static int power (int base, int exponent);
- static void yyerror (const char *s);
- int yylex (void);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
  %}
  
  %union
  %token <ival> NUM "number"
  %type  <ival> exp
  
 -%nonassoc '='   /* comparison        */
 +%nonassoc '='   /* comparison          */
  %left '-' '+'
  %left '*' '/'
 -%left NEG /* negation--unary minus */
 +%precedence NEG /* negation--unary minus */
  %right '^'      /* exponentiation        */
  
  %%
@@@ -83,12 -83,7 +83,7 @@@ exp
  | '-' error          { $$ = 0; YYERROR;     }
  ;
  %%
- static void yyerror (const char *s)
- {
-   fprintf (stderr, "%s\n", s);
- }
+ ]AT_YYERROR_DEFINE[
  static int get_char (void)
  {
    int res = getc (input);
@@@ -119,7 -114,8 +114,8 @@@ static int read_signed_integer (void
    return sign * n;
  }
  
- int yylex (void)
+ static int
+ yylex (void)
  {
    int c;
    /* Skip white space.  */
@@@ -190,6 -186,7 +186,7 @@@ AT_DATA([input.txt]
  AT_BISON_CHECK([-o test.c test.y])
  AT_COMPILE([[test]])
  AT_PARSER_CHECK([./test input.txt], 0, [], [stderr])
+ AT_BISON_OPTION_POPDEFS
  AT_CLEANUP
  
  
  
  
  AT_SETUP([Undefined and ambiguous references])
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([test.y],
  [[
  %{
  static int power (int base, int exponent);
- static void yyerror (const char *s);
- int yylex (void);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
  %}
  
  %union
  %token <ival> NUM "number"
  %type  <ival> exp
  
 -%nonassoc '='   /* comparison        */
 +%nonassoc '='   /* comparison          */
  %left '-' '+'
  %left '*' '/'
 -%left NEG /* negation--unary minus */
 +%precedence NEG /* negation--unary minus */
  %right '^'      /* exponentiation        */
  
  %%
@@@ -268,6 -265,7 +265,7 @@@ test.y:55.3-53:      symbol not found i
  test.y:56.29-33: invalid reference: '$expo'
  test.y:56.3-46:      symbol not found in production: expo
  ]])
+ AT_BISON_OPTION_POPDEFS
  AT_CLEANUP
  
  #######################################################################
diff --combined tests/regression.at
index ff798a87a85cd0190b154210f8733cc0f49d6ae9,fa93833cd0d08b3bf4378e8b54c4a5bfe79243cc..fd08800a28e5ae7ce0e76b03c310da171926c059
@@@ -24,10 -24,11 +24,11 @@@ AT_BANNER([[Regression tests.]]
  
  AT_SETUP([Trivial grammars])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([input.y],
  [[%{
- void yyerror (char const *);
- int yylex (void);
+ ]AT_YYERROR_DECLARE_EXTERN[
+ ]AT_YYLEX_DECLARE_EXTERN[
  #define YYSTYPE int *
  %}
  
@@@ -37,6 -38,7 +38,7 @@@
  
  program: 'x';
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([-o input.c input.y])
  AT_COMPILE([input.o], [-c input.c])
@@@ -52,10 -54,11 +54,11 @@@ AT_CLEANU
  
  AT_SETUP([YYSTYPE typedef])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([input.y],
  [[%{
- void yyerror (char const *);
- int yylex (void);
+ ]AT_YYERROR_DECLARE_EXTERN[
+ ]AT_YYLEX_DECLARE_EXTERN[
  typedef union { char const *val; } YYSTYPE;
  %}
  
@@@ -65,6 -68,7 +68,7 @@@
  
  program: { $$ = ""; };
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([-o input.c input.y])
  AT_COMPILE([input.o], [-c input.c])
@@@ -83,10 -87,11 +87,11 @@@ AT_SETUP([Early token definitions with 
  # Found in GCJ: they expect the tokens to be defined before the user
  # prologue, so that they can use the token definitions in it.
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([input.y],
  [[%{
- void yyerror (const char *s);
- int yylex (void);
+ ]AT_YYERROR_DECLARE_EXTERN[
+ ]AT_YYLEX_DECLARE_EXTERN[
  %}
  
  %union
  exp: MY_TOKEN;
  %%
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([-y -o input.c input.y])
  AT_COMPILE([input.o], [-c input.c])
@@@ -121,11 -127,12 +127,12 @@@ AT_SETUP([Early token definitions witho
  # Found in GCJ: they expect the tokens to be defined before the user
  # prologue, so that they can use the token definitions in it.
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([input.y],
  [[%{
  #include <stdio.h>
- void yyerror (const char *s);
- int yylex (void);
+ ]AT_YYERROR_DECLARE_EXTERN[
+ ]AT_YYLEX_DECLARE_EXTERN[
  void print_my_token (void);
  %}
  
@@@ -146,6 -153,7 +153,7 @@@ print_my_token (void
  exp: MY_TOKEN;
  %%
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([-o input.c input.y])
  AT_COMPILE([input.o], [-c input.c])
@@@ -161,6 -169,7 +169,7 @@@ AT_CLEANU
  
  AT_SETUP([Braces parsing])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA([input.y],
  [[/* Bison used to swallow the character after '}'. */
  
  exp: { tests = {{{{{{{{{{}}}}}}}}}}; };
  %%
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([-v -o input.c input.y])
  
@@@ -183,6 -193,7 +193,7 @@@ AT_CLEANU
  
  AT_SETUP([Duplicate string])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA([input.y],
  [[/* 'Bison -v' used to dump core when two tokens are defined with the same
     string, as LE and GE below. */
  exp: '(' exp ')' | NUM ;
  %%
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([-v -o input.c input.y], 0, [],
  [[input.y:6.8-14: warning: symbol "<=" used more than once as a literal string
@@@ -211,6 -223,7 +223,7 @@@ AT_SETUP([Rule Line Numbers]
  
  AT_KEYWORDS([report])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA([input.y],
  [[%%
  expr:
  
  };
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([-o input.c -v input.y])
  
@@@ -428,13 -442,14 +442,14 @@@ AT_CLEANU
  
  AT_SETUP([Token definitions])
  
+ AT_BISON_OPTION_PUSHDEFS
  # Bison managed, when fed with '%token 'f' "f"' to #define 'f'!
  AT_DATA_GRAMMAR([input.y],
  [%{
  #include <stdlib.h>
  #include <stdio.h>
- void yyerror (const char *s);
- int yylex (void);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
  %}
  [%error-verbose
  %token MYEOF 0 "end of file"
@@@ -468,6 -483,7 +483,7 @@@ main (void
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  # Checking the warning message guarantees that the trigraph "??!" isn't
  # unnecessarily escaped here even though it would need to be if encoded in a
@@@ -498,19 -514,21 +514,21 @@@ AT_CLEANU
  
  AT_SETUP([Characters Escapes])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([input.y],
  [%{
- void yyerror (const char *s);
- int yylex (void);
+ ]AT_YYERROR_DECLARE_EXTERN[
+ ]AT_YYLEX_DECLARE_EXTERN[
  %}
  [%%
  exp:
    '\'' "\'"
  | '\"' "\""
- | '"'  "'"
+ | '"'  "'" /* Pacify font-lock-mode: ". */
  ;
  ]])
- # Pacify font-lock-mode: "
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([-o input.c input.y])
  AT_COMPILE([input.o], [-c input.c])
@@@ -532,7 -550,7 +550,7 @@@ AT_SETUP([Web2c Report]
  AT_KEYWORDS([report])
  
  AT_DATA([input.y],
 -[[%token      undef_id_tok const_id_tok
 +[[%token        undef_id_tok const_id_tok
  
  %start CONST_DEC_PART
  \f
@@@ -542,12 -560,12 +560,12 @@@ CONST_DEC_PART
          ;
  
  CONST_DEC_LIST:
 -        CONST_DEC
 +          CONST_DEC
          | CONST_DEC_LIST CONST_DEC
          ;
  
  CONST_DEC:
 -        { } undef_id_tok '=' const_id_tok ';'
 +          { } undef_id_tok '=' const_id_tok ';'
          ;
  %%
  ]])
@@@ -753,6 -771,15 +771,6 @@@ AT_CHECK([[cat tables.c]], 0
         2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
         5,     6
  };
 -static const yytype_uint8 yyprhs[] =
 -{
 -       0,     0,     3,     5,     6,     9,    14
 -};
 -static const yytype_int8 yyrhs[] =
 -{
 -       8,     0,    -1,     9,    -1,    -1,    10,    11,    -1,     3,
 -       4,     5,     8,    -1,     6,     8,    -1
 -};
  static const yytype_uint8 yyrline[] =
  {
         0,     2,     2,     3,     3,     4,     5
@@@ -766,24 -793,32 +784,24 @@@ static const yytype_uint16 yytoknum[] 
  {
         0,   256,   257,   258,   259,   260,   261
  };
 -static const yytype_uint8 yyr1[] =
 -{
 -       0,     7,     8,     9,     9,    10,    11
 -};
 -static const yytype_uint8 yyr2[] =
 +static const yytype_int8 yypact[] =
  {
 -       0,     2,     1,     0,     2,     4,     2
 +      -2,    -1,     4,    -8,     0,     2,    -8,    -2,    -8,    -2,
 +      -8,    -8
  };
  static const yytype_uint8 yydefact[] =
  {
         3,     0,     0,     2,     0,     0,     1,     3,     4,     3,
         6,     5
  };
 -static const yytype_int8 yydefgoto[] =
 -{
 -      -1,     2,     3,     4,     8
 -};
 -static const yytype_int8 yypact[] =
 -{
 -      -2,    -1,     4,    -8,     0,     2,    -8,    -2,    -8,    -2,
 -      -8,    -8
 -};
  static const yytype_int8 yypgoto[] =
  {
        -8,    -7,    -8,    -8,    -8
  };
 +static const yytype_int8 yydefgoto[] =
 +{
 +      -1,     2,     3,     4,     8
 +};
  static const yytype_uint8 yytable[] =
  {
        10,     1,    11,     5,     6,     0,     7,     9
@@@ -797,14 -832,6 +815,14 @@@ static const yytype_uint8 yystos[] 
         0,     3,     8,     9,    10,     4,     0,     6,    11,     5,
         8,     8
  };
 +static const yytype_uint8 yyr1[] =
 +{
 +       0,     7,     8,     9,     9,    10,    11
 +};
 +static const yytype_uint8 yyr2[] =
 +{
 +       0,     2,     1,     0,     2,     4,     2
 +};
  ]])
  
  AT_CLEANUP
@@@ -825,10 -852,10 +843,10 @@@ m4_define([_AT_DATA_DANCER_Y]
  [AT_DATA_GRAMMAR([dancer.y],
  [%{
  static int yylex (AT_LALR1_CC_IF([int *], [void]));
 -AT_LALR1_CC_IF([],
 +AT_LALR1_CC_IF([#include <cstdlib>],
  [#include <stdlib.h>
  #include <stdio.h>
static void yyerror (const char *);])
]AT_YYERROR_DECLARE[])
  %}
  $1
  %token ARROW INVALID NUMBER STRING DATA
@@@ -877,7 -904,7 +895,7 @@@ member: STRIN
  AT_LALR1_CC_IF(
  [/* A C++ error reporting function. */
  void
 -yy::parser::error (const location&, const std::string& m)
 +yy::parser::error (const std::string& m)
  {
    std::cerr << m << std::endl;
  }
@@@ -951,12 -978,12 +969,12 @@@ AT_CHECK_DANCER([%skeleton "lalr1.cc"]
  # --------------------------------
  m4_define([_AT_DATA_EXPECT2_Y],
  [AT_DATA_GRAMMAR([expect2.y],
 -[[%{
 -static int yylex (]AT_LALR1_CC_IF([int *], [void]));
 -AT_LALR1_CC_IF([],
 -[[#include <stdio.h>
 -#include <stdlib.h>
 +[%{
 +static int yylex (AT_LALR1_CC_IF([int *], [void]));
- AT_LALR1_CC_IF([#include <cstdlib>],
- [#include <stdio.h>
- #include <stdlib.h>
- static void yyerror (const char *);])
++AT_LALR1_CC_IF([[#include <cstdlib>]],
++[[#include <stdlib.h>
++#include <stdio.h>
+ ]AT_YYERROR_DECLARE])[
  %}
  $1
  %defines
@@@ -973,30 -1000,19 +991,19 @@@ e: e '+' t | t
  t: A | B;
  
  %%
- AT_LALR1_CC_IF(
- [/* A C++ error reporting function. */
- void
- yy::parser::error (const std::string& m)
- {
-   std::cerr << m << std::endl;
- }
- int
+ ]AT_YYERROR_DEFINE[
+ ]AT_LALR1_CC_IF(
+ [int
  yyparse ()
  {
    yy::parser parser;
    return parser.parse ();
  }
- ],
- [static void
- yyerror (const char *s)
- {
-   fprintf (stderr, "%s\n", s);
- }])
+ ])[
  
  static int
- yylex (AT_LALR1_CC_IF([int *lval], [void]))
[{
+ yylex (]AT_LALR1_CC_IF([int *lval], [void])[)
+ {
    static int const tokens[] =
      {
        1000, '+', '+', -1
    if (! (toknum < sizeof tokens / sizeof *tokens))
      abort ();
    return tokens[toknum++];
- }]
+ }
  
  int
  main (void)
  {
    return yyparse ();
  }
- ])
+ ]])
  ])# _AT_DATA_EXPECT2_Y
  
  
  # AT_CHECK_EXPECT2(BISON-OPTIONS)
- # ------------------------------
+ # -------------------------------
  # Generate the grammar, compile it, run it.
  m4_define([AT_CHECK_EXPECT2],
  [AT_SETUP([Expecting two tokens $1])
@@@ -1047,12 -1063,12 +1054,12 @@@ AT_SETUP([Braced code in declaration i
  
  # Bison once mistook braced code in a declaration in the rules section to be a
  # rule action.
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([input.y],
  [[%{
  #include <stdio.h>
- static void yyerror (char const *msg);
- static int yylex (void);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
  %}
  
  %error-verbose
  start:
    {
      printf ("Bison would once convert this action to a midrule because of the"
 -          " subsequent braced code.\n");
 +            " subsequent braced code.\n");
    }
    ;
  
  
  %%
  
- static void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  static int
  yylex (void)
  {
@@@ -1090,6 -1101,7 +1092,7 @@@ main (void
    return !yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([-t -o input.c input.y])
  AT_COMPILE([input])
@@@ -1187,12 -1199,12 +1190,12 @@@ AT_SETUP([[Token number in precedence d
  
  # POSIX says token numbers can be declared in %left, %right, and %nonassoc, but
  # we lost this in Bison 1.50.
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([input.y],
  [[%{
    #include <stdio.h>
-   void yyerror (char const *);
-   int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
  %}
  
  %error-verbose
@@@ -1212,12 -1224,7 +1215,7 @@@ sr_conflict
  
  %%
  
- void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  int
  yylex (void)
  {
@@@ -1232,6 -1239,7 +1230,7 @@@ main (void
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o input.c input.y]], [[0]],,
  [[input.y:23.5-19: warning: rule useless in parser due to conflicts: start: start
@@@ -1253,9 -1261,8 +1252,9 @@@ AT_CLEANU
  
  AT_SETUP([[parse-gram.y: LALR = IELR]])
  
 -# Avoid differences in synclines by telling bison that the output files
 -# have the same name.
 +# Avoid tests/bison's dark magic by processing a local copy of the
 +# grammar.  Avoid differences in synclines by telling bison that the
 +# output files have the same name.
  [cp $abs_top_srcdir/src/parse-gram.y input.y]
  AT_BISON_CHECK([[-o input.c -Dlr.type=lalr input.y]])
  [mv input.c lalr.c]
@@@ -1269,21 -1276,22 +1268,22 @@@ AT_CLEANU
  
  
  
 -## --------------------------------------- ##
 -## %error-verbose and YYSTACK_USE_ALLOCA.  ##
 -## --------------------------------------- ##
 +## -------------------------------------------- ##
 +## parse.error=verbose and YYSTACK_USE_ALLOCA.  ##
 +## -------------------------------------------- ##
  
 -AT_SETUP([[%error-verbose and YYSTACK_USE_ALLOCA]])
 +AT_SETUP([[parse.error=verbose and YYSTACK_USE_ALLOCA]])
  
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([input.y],
  [[%code {
    #include <stdio.h>
-   void yyerror (char const *);
-   int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
    #define YYSTACK_USE_ALLOCA 1
  }
  
 -%error-verbose
 +%define parse.error verbose
  
  %%
  
@@@ -1315,28 -1323,18 +1315,18 @@@ syntax_error
  
  %%
  
- void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
- int
- yylex (void)
- {
+ ]AT_YYERROR_DEFINE[
 -/* Induce two syntax error messages (which requires full error
 -   recovery by shifting 3 tokens) in order to detect any loss of the
 -   reallocated buffer.  */
 +  /* Induce two syntax error messages (which requires full error
 +     recovery by shifting 3 tokens) in order to detect any loss of the
 +     reallocated buffer.  */
-   static char const *input = "abc";
-   return *input++;
- }
+ ]AT_YYLEX_DEFINE([abc])[
  int
  main (void)
  {
    return yyparse ();
  }
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_BISON_CHECK([[-o input.c input.y]])
  AT_COMPILE([[input]])
@@@ -1349,9 -1347,9 +1339,9 @@@ AT_CLEANU
  
  
  
 -## ------------------------- ##
 -## %error-verbose overflow.  ##
 -## ------------------------- ##
 +## ------------------------------ ##
 +## parse.error=verbose overflow.  ##
 +## ------------------------------ ##
  
  # Imagine the case where YYSTACK_ALLOC_MAXIMUM = YYSIZE_MAXIMUM and an
  # invocation of yysyntax_error has caused yymsg_alloc to grow to exactly
  # size calculation would return YYSIZE_MAXIMUM to yyparse.  Then,
  # yyparse would invoke yyerror using the old contents of yymsg.
  
 -AT_SETUP([[%error-verbose overflow]])
 +AT_SETUP([[parse.error=verbose overflow]])
 +
+ AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([input.y],
  [[%code {
    #include <stdio.h>
-   void yyerror (char const *);
-   int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
  
    /* This prevents this test case from having to induce error messages
       large enough to overflow size_t.  */
    #define YYMAXDEPTH 100
  }
  
 -%error-verbose
 +%define parse.error verbose
  
  %%
  
@@@ -1433,21 -1431,10 +1424,10 @@@ syntax_error2
  
  %%
  
- void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
- int
- yylex (void)
- {
+ ]AT_YYERROR_DEFINE[
 -/* Induce two syntax error messages (which requires full error
 -   recovery by shifting 3 tokens).  */
 +  /* Induce two syntax error messages (which requires full error
 +     recovery by shifting 3 tokens).  */
-   static char const *input = "abc";
-   return *input++;
- }
+ ]AT_YYLEX_DEFINE([abc])[
  int
  main (void)
  {
@@@ -1473,7 -1460,7 +1453,7 @@@ AT_PARSER_CHECK([[./input]], [[2]], []
  syntax error
  memory exhausted
  ]])
+ AT_BISON_OPTION_POPDEFS
  AT_CLEANUP
  
  
@@@ -1491,12 -1478,12 +1471,12 @@@ AT_BISON_OPTION_PUSHDEFS([$1]
  AT_DATA_GRAMMAR([input.y],
  [[%code {
    #include <stdio.h>
-   void yyerror (char const *);
+   ]AT_YYERROR_DECLARE[
    int yylex (]AT_PURE_IF([[YYSTYPE *]], [[void]])[);
  }
  
  ]$1[
 -%error-verbose
 +%define parse.error verbose
  %token 'c'
  
  %%
@@@ -1512,13 -1499,7 +1492,7 @@@ B: 'b' 
  C: /*empty*/ { printf ("consistent default reduction\n"); } ;
  
  %%
- void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  int
  yylex (]AT_PURE_IF([[YYSTYPE *v]], [[void]])[)
  {
@@@ -1584,13 -1565,13 +1558,13 @@@ AT_CLEANU
  
  AT_SETUP([[LAC: Memory exhaustion]])
  
- m4_pushdef([AT_LAC_CHECK], [
+ m4_pushdef([AT_LAC_CHECK],
+ [AT_BISON_OPTION_PUSHDEFS
  AT_DATA_GRAMMAR([input.y],
  [[%code {
    #include <stdio.h>
-   void yyerror (char const *);
-   int yylex (void);
+   ]AT_YYERROR_DECLARE[
+   ]AT_YYLEX_DECLARE[
    #define YYMAXDEPTH 8
  }
  
@@@ -1602,20 -1583,8 +1576,8 @@@ S: A A A A A A A A A 
  A: /*empty*/ | 'a' ;
  
  %%
- void
- yyerror (char const *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
- int
- yylex (void)
- {
-   static char const *input = "]$1[";
-   return *input++;
- }
+ ]AT_YYERROR_DEFINE[
+ ]AT_YYLEX_DEFINE([$1])[
  int
  main (void)
  {
@@@ -1629,12 -1598,12 +1591,12 @@@ AT_BISON_CHECK([[-Dparse.lac=full -Dpar
  [[input.y: conflicts: 8 shift/reduce
  ]])
  AT_COMPILE([[input]])
+ AT_BISON_OPTION_POPDEFS
  ])
  
  # Check for memory exhaustion during parsing.
- AT_LAC_CHECK([[]])
- AT_PARSER_CHECK([[./input]], [[2]], [[]],
+ AT_LAC_CHECK([])
+ AT_PARSER_CHECK([[./input]], [[2]], [],
  [[Starting parse
  Entering state 0
  Reading a token: Now at end of input.
@@@ -1647,8 -1616,8 +1609,8 @@@ Stack now 
  
  # Induce an immediate syntax error with an undefined token, and check
  # for memory exhaustion while building syntax error message.
- AT_LAC_CHECK([[z]], [[0]])
- AT_PARSER_CHECK([[./input]], [[2]], [[]],
+ AT_LAC_CHECK([z], [[0]])
+ AT_PARSER_CHECK([[./input]], [[2]], [],
  [[Starting parse
  Entering state 0
  Reading a token: Next token is token $undefined ()
diff --combined tests/torture.at
index 253041e6d50ea5bb0593e0efa763c7e5d39aa447,313df345ed494f3c81e0c43ea1ff75a9d13201e8..061467d05b962a8b44b8913708e9480eb35925c4
@@@ -42,7 -42,8 +42,8 @@@ esac]
  # Create FILE-NAME, containing a self checking parser for a huge
  # triangular grammar.
  m4_define([AT_DATA_TRIANGULAR_GRAMMAR],
- [AT_DATA([[gengram.pl]],
+ [AT_BISON_OPTION_PUSHDEFS
+ AT_DATA([[gengram.pl]],
  [[#! /usr/bin/perl -w
  
  use strict;
@@@ -56,8 -57,8 +57,8 @@@ print <<EOF
  #include <stdio.h>
  #include <stdlib.h>
  
- static int yylex (void);
- static void yyerror (const char *msg);
+ ]AT_YYLEX_DECLARE[
+ ]AT_YYERROR_DECLARE[
  %}
  %union
  {
@@@ -89,9 -90,9 +90,9 @@@ for my $size (1 .. $max
    {
      use Text::Wrap;
      print wrap ("| ", "   ",
 -              (map { "\"$_\"" } (1 .. $size)),
 -              " END \n"),
 -                "    { \$\$ = $size; }\n";
 +                (map { "\"$_\"" } (1 .. $size)),
 +                " END \n"),
 +                  "    { \$\$ = $size; }\n";
    };
  print ";\n";
  
@@@ -127,6 -128,7 +128,7 @@@ main (void
  }
  EOF
  ]])
+ AT_BISON_OPTION_POPDEFS
  
  AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
  mv stdout $1
@@@ -157,7 -159,8 +159,8 @@@ AT_CLEANU
  # Create FILE-NAME, containing a self checking parser for a huge
  # horizontal grammar.
  m4_define([AT_DATA_HORIZONTAL_GRAMMAR],
- [AT_DATA([[gengram.pl]],
+ [AT_BISON_OPTION_PUSHDEFS
+ AT_DATA([[gengram.pl]],
  [[#! /usr/bin/perl -w
  
  use strict;
@@@ -171,8 -174,8 +174,8 @@@ print <<EOF
  #include <stdio.h>
  #include <stdlib.h>
  
- static int yylex (void);
- static void yyerror (const char *msg);
+ ]AT_YYLEX_DECLARE[
+ ]AT_YYERROR_DECLARE[
  %}
  
  %token
@@@ -190,7 -193,7 +193,7 @@@ EO
  use Text::Wrap;
  print
    wrap ("exp: ", "  ",
 -      (map { "\"$_\"" } (1 .. $max)), ";"),
 +        (map { "\"$_\"" } (1 .. $max)), ";"),
    "\n";
  
  print <<EOF;
@@@ -223,6 -226,7 +226,7 @@@ EO
  
  AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
  mv stdout $1
+ AT_BISON_OPTION_POPDEFS
  ])
  
  
@@@ -263,7 -267,8 +267,8 @@@ AT_CLEANU
  # Create FILE-NAME, containing a self checking parser for a grammar
  # requiring SIZE lookahead tokens.
  m4_define([AT_DATA_LOOKAHEAD_TOKENS_GRAMMAR],
- [AT_DATA([[gengram.pl]],
+ [AT_BISON_OPTION_PUSHDEFS
+ AT_DATA([[gengram.pl]],
  [[#! /usr/bin/perl -w
  
  use strict;
@@@ -278,8 -283,8 +283,8 @@@ print <<EOF
  # include <stdlib.h>
  # include <assert.h>
  
- static int yylex (void);
- static void yyerror (const char *msg);
+ ]AT_YYLEX_DECLARE[
+ ]AT_YYERROR_DECLARE[
  %}
  %union
  {
@@@ -292,8 -297,8 +297,8 @@@ EO
  
  print
    wrap ("%type <val> ",
 -      "            ",
 -      map { "n$_" } (1 .. $max)),
 +        "            ",
 +        map { "n$_" } (1 .. $max)),
    "\n";
  
  print "%token\n";
@@@ -334,7 -339,7 +339,7 @@@ yylex (void
    if (counter > $max)
      {
        if (counter++ != $max + 1)
 -      abort ();
 +        abort ();
        return 0;
      }
    if (return_token)
@@@ -363,6 -368,7 +368,7 @@@ EO
  
  AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
  mv stdout $1
+ AT_BISON_OPTION_POPDEFS
  ])
  
  
@@@ -390,7 -396,8 +396,8 @@@ AT_CLEANU
  # ------------------------------------------------
  # A parser specialized in torturing the stack size.
  m4_define([AT_DATA_STACK_TORTURE],
- [# A grammar of parens growing the stack thanks to right recursion.
+ [AT_BISON_OPTION_PUSHDEFS([$2])
+ # A grammar of parens growing the stack thanks to right recursion.
  # exp:
  AT_DATA([input.y],
  [[%{
  #include <stdio.h>
  #include <stdlib.h>
  ]$1[
-   static int yylex (void);
-   static void yyerror (const char *msg);
+   ]AT_YYLEX_DECLARE[
+   ]AT_YYERROR_DECLARE[
  %}
  ]$2[
  %error-verbose
  %%
  exp: WAIT_FOR_EOF exp | ;
  %%
- static void
- yyerror (const char *msg)
- {
-   fprintf (stderr, "%s\n", msg);
- }
+ ]AT_YYERROR_DEFINE[
  static int
  yylex (void)
  {
@@@ -435,8 -437,8 +437,8 @@@ main (int argc, const char **argv
      abort ();
    yylval_init = strtol (argv[1], &endp, 10);
    if (! (argv[1] != endp
 -       && 0 <= yylval_init && yylval_init <= INT_MAX
 -       && errno != ERANGE))
 +         && 0 <= yylval_init && yylval_init <= INT_MAX
 +         && errno != ERANGE))
      abort ();
    yydebug = 1;
    {
    }
  }
  ]])
+ AT_BISON_OPTION_POPDEFS([$2])
  AT_BISON_CHECK([-o input.c input.y])
  AT_COMPILE([input])
  ])