]> git.saurik.com Git - bison.git/commitdiff
Merge tag 'v2.5.1_rc2'
authorAkim Demaille <akim@lrde.epita.fr>
Thu, 24 May 2012 11:37:28 +0000 (13:37 +0200)
committerAkim Demaille <akim@lrde.epita.fr>
Thu, 24 May 2012 11:54:55 +0000 (13:54 +0200)
Bison 2.5.1_rc2.

* tag 'v2.5.1_rc2': (34 commits)
  Bison 2.5.1_rc2.
  doc: fixes.
  build: fix ChangeLog generation.
  c++: compute the header guards.
  skeletons: remove support for unused directive.
  lalr1.cc: improve Doxygen documentation.
  lalr1.cc: extract stack.hh.
  news: convert to double quotes.
  space changes.
  build: do not prototype flex-generated functions.
  build: fix ChangeLog generation.
  Bison 2.5.1_rc1.
  tests: save/restore Autotest special files when checking XML support.
  tests: AT_SAVE_SPECIAL_FILES / AT_RESTORE_SPECIAL_FILES.
  tests: honor TESTSUITEFLAGS in all the check targets.
  build: do not enable c++ warnings on 0 when nullptr is not supported.
  maint: update gnulib.
  build: config.in.h.
  build: move silent rules.
  glr.c: reduce variable scopes.
  maint: maintainer-release-check.
  maint: shush a syntax-check.
  maint: prefer "commit message" to "log entry".
  command line: fix minor leaks.
  maint: we no longer maintain the ChangeLog.
  maint: fix the generation of the synclines for bison's parser.
  maint: regen.
  maint: import the xmemdup0 gnulib module.
  maint: remove left-over gnulib modules.
  maint: ignore files imported by autopoint.
  build: AC_PROG_LEX: use more readable variable names.
  maint: regen src/parse-gram.[ch]
  maint: simplify parse-gram.y
  maint: s/strncpy/memcpy/, when equivalent

Conflicts:
Makefile.am
NEWS
data/glr.c
data/lalr1.cc
data/stack.hh
examples/rpcalc/local.mk
src/flex-scanner.h
src/getargs.c
src/output.c
src/parse-gram.c
src/parse-gram.h
src/parse-gram.y
tests/Makefile.am
tests/bison.in

23 files changed:
1  2 
Makefile.am
NEWS
README-hacking
THANKS
bootstrap.conf
build-aux/.gitignore
cfg.mk
configure.ac
data/c.m4
data/glr.c
data/lalr1.cc
data/location.cc
data/stack.hh
doc/bison.texinfo
m4/.gitignore
po/.gitignore
runtime-po/.gitignore
src/flex-scanner.h
src/getargs.c
src/parse-gram.y
src/scan-skel.l
tests/local.at
tests/regression.at

diff --combined Makefile.am
index feb55681ee2bc7ab17239f803ada6a28467c082d,eef413fca9c82e610c5041cc4092144e8221fb21..5fae4ce5848de9bf82f02b9518707a15eeda4c91
@@@ -1,7 -1,7 +1,7 @@@
 -## Process this file with automake to produce Makefile.in -*-Makefile-*-
 -
 -## Copyright (C) 2001-2012 Free Software Foundation, Inc.
 +## Process this file with automake to produce Makefile.in.
  
 +# Copyright (C) 2001-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
  # the Free Software Foundation, either version 3 of the License, or
  # You should have received a copy of the GNU General Public License
  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
 +AUTOMAKE_OPTIONS = subdir-objects
  ACLOCAL_AMFLAGS = -I m4
  
 -SUBDIRS = build-aux po runtime-po lib data src doc examples tests etc
 +SUBDIRS = po runtime-po .
  
  # Files installed for use by Automake.
  aclocaldir = @aclocaldir@
  aclocal_DATA = m4/bison-i18n.m4
  
  EXTRA_DIST = .prev-version .version \
 -  cfg.mk ChangeLog-1998 ChangeLog-2012 PACKAGING \
 -  djgpp/Makefile.maint djgpp/README.in djgpp/config.bat \
 -  djgpp/config.sed djgpp/config.site djgpp/config_h.sed \
 -  djgpp/subpipe.c djgpp/subpipe.h djgpp/djunpack.bat \
 -  djgpp/fnchange.lst djgpp/testsuite.sed
 +  cfg.mk ChangeLog-1998 ChangeLog-2012 PACKAGING
 +
 +## Running the bison from this tarball.  To generate our own parser,
 +## but also to run the tests.  Of course, you ought to keep a sane
 +## version of Bison nearby...
 +BISON = $(top_builddir)/tests/bison
 +BISON_IN = $(top_srcdir)/tests/bison.in
 +YACC = $(BISON) -y
 +AM_YFLAGS = -d -v --warnings=all,error --report=all
 +
 +# Initialization before completion by local.mk's.
 +AM_CFLAGS = $(WARN_CFLAGS)
 +# Find builddir/src/scan-code.c etc.
 +AM_CPPFLAGS = -I. -Ilib -I$(top_srcdir) -I$(top_srcdir)/lib
 +BUILT_SOURCES =
 +CLEANFILES =
 +DISTCLEANFILES =
 +EXTRA_DIST += $(dist_TESTS)
 +MOSTLYCLEANDIRS =
 +MOSTLYCLEANFILES =
 +SUFFIXES =
 +TESTS = $(dist_TESTS)
 +check_PROGRAMS =
 +dist_TESTS =
 +noinst_LIBRARIES =
  
 -MAINTAINER_CHECKS =                           \
 -  maintainer-check                            \
 -  maintainer-push-check                               \
 -  maintainer-xml-check                                \
 -  maintainer-release-check
 -.PHONY: $(MAINTAINER_CHECKS)
 -$(MAINTAINER_CHECKS):
 -      $(AM_V_GEN)cd tests && $(MAKE) $(AM_MAKEFLAGS) $@
 +include build-aux/local.mk
 +include data/local.mk
 +include djgpp/local.mk
 +include doc/local.mk
 +include etc/local.mk
 +include examples/local.mk
 +include lib/local.mk
 +include src/local.mk
 +include tests/local.mk
  
  # See comments in build-aux/git-version-gen.  However, we make .version depend
  # on configure so that .version and VERSION/PACKAGE_VERSION stay in sync in the
  # a developer might naively reference .version in a test case while the bison
  # executable still compiles with VERSION, and so the test case might fail or
  # pass incorrectly.
 -BUILT_SOURCES = $(top_srcdir)/.version
 +BUILT_SOURCES += $(top_srcdir)/.version
  $(top_srcdir)/.version: configure
 -      $(AM_V_GEN)echo $(VERSION) > $@-t && mv $@-t $@
 +      echo $(VERSION) > $@-t && mv $@-t $@
  dist-hook: gen-ChangeLog
 -      $(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version
 +      echo $(VERSION) > $(distdir)/.tarball-version
  
  .PHONY: update-b4-copyright update-package-copyright-year
  update-b4-copyright:
 -      $(AM_V_GEN) find data -type f           \
 -        | grep -v -E '^data/bison.m4$$'       \
 +      find data -type f                    \
 +        | grep -v -E '^data/bison.m4$$'    \
          | xargs $(build_aux)/$@
        @echo 'warning: src/parse-gram.[hc] may need to be regenerated.'
  update-package-copyright-year:
 -      $(AM_V_GEN)$(build_aux)/$@ configure.ac
 +      $(build_aux)/$@ configure.ac
  
  gen_start_date = 2012-01-16
  .PHONY: gen-ChangeLog
  gen-ChangeLog:
-       $(AM_V_GEN)if test -d .git; then                                \
-         $(top_srcdir)/build-aux/gitlog-to-changelog                   \
-           --no-cluster                                                \
-           --amend=$(srcdir)/build-aux/git-log-fix                     \
-           --since=$(gen_start_date) > $(distdir)/cl-t;                \
-         rm -f $(distdir)/ChangeLog;                                   \
-         mv $(distdir)/cl-t $(distdir)/ChangeLog;                      \
+       $(AM_V_GEN)if test -d $(srcdir)/.git; then              \
+         $(top_srcdir)/build-aux/gitlog-to-changelog           \
+           --strip-tab                                         \
+           --strip-cherry-picked                               \
+           --no-cluster                                        \
+           --amend=$(srcdir)/build-aux/git-log-fix             \
+           --since=$(gen_start_date) > $(distdir)/cl-t;        \
+         rm -f $(distdir)/ChangeLog;                           \
+         mv $(distdir)/cl-t $(distdir)/ChangeLog;              \
        fi
diff --combined NEWS
index 8f77271b6b2924225ecb5fe0f01942ddf0c7c13e,14f51b3e3263093ef079e83b71812f6f2132e831..a3b2fa7c342563fcd9bd94247e5da2286631a05c
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -1,79 -1,11 +1,79 @@@
  Bison News
  ----------
  
 -* Changes in version 2.5.1_rc2 (2012-05-23):
 +* Changes in version ?.? (????-??-??):
 +
 +** 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
 +
 +      %lex-param   {arg1_type *arg1}
 +      %lex-param   {arg2_type *arg2}
 +      %parse-param {arg1_type *arg1}
 +      %parse-param {arg2_type *arg2}
 +
 +  one may now declare
 +
 +      %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.
 +
 +* Changes in version 2.5.1 (????-??-??):
  
  ** Future changes:
  
-   The next major release will drop support for K&R C.
+   The next major release will drop support for generating parsers in K&R C.
  
  ** yacc.c: YYBACKUP works as expected.
  
  
  *** Location support is eliminated when not requested:
  
-   GLR parsers used to include location-related code even when
-   locations were not requested, and therefore not even usable.
+   GLR parsers used to include location-related code even when locations were
+   not requested, and therefore not even usable.
  
  *** __attribute__ is preserved:
  
-   __attribute__ is no longer disabled when __STRICT_ANSI__ is defined
-   (i.e., when -std is passed to GCC).
+   __attribute__ is no longer disabled when __STRICT_ANSI__ is defined (i.e.,
+   when -std is passed to GCC).
  
  ** lalr1.java: several fixes:
  
-   The Java parser no longer throws ArrayIndexOutOfBoundsException if
-   the first token leads to a syntax error.  Some minor clean ups.
+   The Java parser no longer throws ArrayIndexOutOfBoundsException if the
+   first token leads to a syntax error.  Some minor clean ups.
  
- ** C++11 compatibility:
+ ** Changes for C++:
  
-   C and C++ parsers use nullptr instead of 0 when __cplusplus is
-   201103L or higher.
+ *** C++11 compatibility:
  
- ** C++ locations:
+   C and C++ parsers use "nullptr" instead of "0" when __cplusplus is 201103L
+   or higher.
  
-   The position and location constructors (and their initialize
-   methods) accept new arguments for line and column.  Several issues
-   in the documentation were fixed.
+ *** Header guards
+   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
+   The inclusion guard is now computed from "PREFIX/FILE-NAME", where lower
+   case characters are converted to upper case, and series of
+   non-alphanumerical characters are converted to an underscore.
+   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
+ *** C++ locations:
+   The position and location constructors (and their initialize methods)
+   accept new arguments for line and column.  Several issues in the
+   documentation were fixed.
  
  ** liby is no longer asking for "rpl_fprintf" on some platforms.
  
  
  *** %printer is documented
  
-   The %printer directive, supported since at least Bison 1.50, is
-   finally documented.  The %mfcalc example is extended to demonstrate
-   its use of printer.
+   The "%printer" directive, supported since at least Bison 1.50, is finally
+   documented.  The "mfcalc" example is extended to demonstrate it.
  
-   The C++ parsers now also support yyoutput (as an alias to
-   debug_stream ()) for consistency with the C skeletons.
+   For consistency with the C skeletons, the C++ parsers now also support
+   "yyoutput" (as an alias to "debug_stream ()").
  
  *** Several improvements have been made:
  
-   The layout for grammar excerpts was changed to a more compact
-   scheme.  Named references are motivated.  The description of the
-   automaton description file (*.output) is updated to the current
-   format.  Incorrect index entries were fixed.  Some other errors were
-   fixed.
+   The layout for grammar excerpts was changed to a more compact scheme.
+   Named references are motivated.  The description of the automaton
+   description file (*.output) is updated to the current format.  Incorrect
+   index entries were fixed.  Some other errors were fixed.
+ ** Building bison:
+ *** Conflicting prototypes with recent/modified Flex.
  
- ** Changes to the build system:
+   Fixed build problems with the current, unreleased, version of Flex, and
+   some modified versions of 2.5.35, which have modified function prototypes.
  
  *** Warnings during the build procedure have been eliminated.
  
  *** Several portability problems in the test suite have been fixed:
  
-   This includes warnings with some compilers, unexpected behavior of
-   tools such as diff, warning messages from the test suite itself,
-   etc.
+   This includes warnings with some compilers, unexpected behavior of tools
+   such as diff, warning messages from the test suite itself, etc.
  
  *** The install-pdf target work properly:
  
-   Running "make install-pdf" (or -dvi, -html, -info, and -ps) no
-   longer halts in the middle of its course.
+   Running "make install-pdf" (or -dvi, -html, -info, and -ps) no longer
+   halts in the middle of its course.
  
  * Changes in version 2.5 (2011-05-14):
  
      %define lr.type canonical-lr
  
    The default-reduction optimization in the parser tables can also be
-   adjusted using `%define lr.default-reductions'.  For details on both
-   of these features, see the new section `Tuning LR' in the Bison
+   adjusted using "%define lr.default-reductions".  For details on both
+   of these features, see the new section "Tuning LR" in the Bison
    manual.
  
    These features are experimental.  More user feedback will help to
    cause error recovery to begin in a different syntactic context than
    the one in which the invalid token was encountered.  Second, when
    verbose error messages are enabled (with %error-verbose or the
-   obsolete `#define YYERROR_VERBOSE'), the expected token list in the
+   obsolete "#define YYERROR_VERBOSE"), the expected token list in the
    syntax error message can both contain invalid tokens and omit valid
    tokens.
  
  
      %define parse.lac full
  
-   See the new section `LAC' in the Bison manual for additional
+   See the new section "LAC" in the Bison manual for additional
    details including a few caveats.
  
    LAC is an experimental feature.  More user feedback will help to
    except that the manner in which Bison processes multiple definitions
    for the same NAME differs.  Most importantly, -F and --force-define
    quietly override %define, but -D and --define do not.  For further
-   details, see the section `Bison Options' in the Bison manual.
+   details, see the section "Bison Options" in the Bison manual.
  
  *** Variables renamed:
  
  
    Similarly to the C parsers, the C++ parsers now define the YYRHSLOC
    macro and use it in the default YYLLOC_DEFAULT.  You are encouraged
-   to use it.  If, for instance, your location structure has `first'
-   and `last' members, instead of
+   to use it.  If, for instance, your location structure has "first"
+   and "last" members, instead of
  
        # define YYLLOC_DEFAULT(Current, Rhs, N)                             \
          do                                                                 \
  
  ** Verbose syntax error message fixes:
  
-   When %error-verbose or the obsolete `#define YYERROR_VERBOSE' is
+   When %error-verbose or the obsolete "#define YYERROR_VERBOSE" is
    specified, syntax error messages produced by the generated parser
    include the unexpected token as well as a list of expected tokens.
    The effect of %nonassoc on these verbose messages has been corrected
      in order to detect a syntax error.  Because no unexpected token or
      expected tokens can then be reported, the verbose syntax error
      message described above is suppressed, and the parser instead
-     reports the simpler message, `syntax error'.  Previously, this
+     reports the simpler message, "syntax error".  Previously, this
      suppression was sometimes erroneously triggered by %nonassoc when a
      lookahead was actually required.  Now verbose messages are
      suppressed only when all previous lookaheads have already been
  
  ** -W/--warnings fixes:
  
- *** Bison now properly recognizes the `no-' versions of categories:
+ *** Bison now properly recognizes the "no-" versions of categories:
  
    For example, given the following command line, Bison now enables all
    warnings except warnings for incompatibilities with POSIX Yacc:
  
    Previously, conflict reports were independent of Bison's normal
    warning system.  Now, Bison recognizes the warning categories
-   `conflicts-sr' and `conflicts-rr'.  This change has important
+   "conflicts-sr" and "conflicts-rr".  This change has important
    consequences for the -W and --warnings command-line options.  For
    example:
  
    expected number of conflicts is not reported, so -W and --warning
    then have no effect on the conflict report.
  
- *** The `none' category no longer disables a preceding `error':
+ *** The "none" category no longer disables a preceding "error":
  
    For example, for the following command line, Bison now reports
    errors instead of warnings for incompatibilities with POSIX Yacc:
  
      bison -Werror,none,yacc gram.y
  
- *** The `none' category now disables all Bison warnings:
+ *** The "none" category now disables all Bison warnings:
  
-   Previously, the `none' category disabled only Bison warnings for
+   Previously, the "none" category disabled only Bison warnings for
    which there existed a specific -W/--warning category.  However,
    given the following command line, Bison is now guaranteed to
    suppress all warnings:
     errors should no longer cause M4 to report a broken pipe on the
     affected platforms.
  
- ** `%prec IDENTIFIER' requires IDENTIFIER to be defined separately.
+ ** "%prec IDENTIFIER" requires IDENTIFIER to be defined separately.
  
    POSIX specifies that an error be reported for any identifier that does
    not appear on the LHS of a grammar rule and that is not defined by
    that YYFAIL will automatically invoke yyerror to report the syntax
    error so that you don't have to.  However, there are several other
    subtle differences between YYERROR and YYFAIL, and YYFAIL suffers from
-   inherent flaws when %error-verbose or `#define YYERROR_VERBOSE' is
+   inherent flaws when %error-verbose or "#define YYERROR_VERBOSE" is
    used.  For a more detailed discussion, see:
  
      http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html
    Bison features compatible with it.  Thus, during parser generation,
    Bison 2.5 will produce a warning whenever it discovers YYFAIL in a
    rule action.  In a later release, YYFAIL will be disabled for
-   %error-verbose and `#define YYERROR_VERBOSE'.  Eventually, YYFAIL will
+   %error-verbose and "#define YYERROR_VERBOSE".  Eventually, YYFAIL will
    be removed altogether.
  
    There exists at least one case where Bison 2.5's YYFAIL warning will
    Bison-defined macros for the sole purpose of suppressing C
    preprocessor warnings (from GCC cpp's -Wunused-macros, for example).
    To avoid Bison's future warning, such YYFAIL uses can be moved to the
-   epilogue (that is, after the second `%%') in the Bison input file.  In
+   epilogue (that is, after the second "%%") in the Bison input file.  In
    this release (2.4.2), Bison already generates its own code to suppress
    C preprocessor warnings for YYFAIL, so projects can remove their own
    phony uses of YYFAIL if compatibility with Bison releases prior to
  
      exp: exp "+" exp { $$ = $1 + $3; };
  
-   Some grammars still depend on this `feature'.  Bison 2.4.1 restores
+   Some grammars still depend on this "feature".  Bison 2.4.1 restores
    the previous behavior in the case of C output (specifically, when
    neither %language or %skeleton or equivalent command-line options
    are used) to leave more time for grammars depending on the old
  
      %define NAME "VALUE"
  
- ** The directive `%pure-parser' is now deprecated in favor of:
+ ** The directive "%pure-parser" is now deprecated in favor of:
  
      %define api.pure
  
  ** Push Parsing
  
    Bison can now generate an LALR(1) parser in C with a push interface.  That
-   is, instead of invoking `yyparse', which pulls tokens from `yylex', you can
-   push one token at a time to the parser using `yypush_parse', which will
+   is, instead of invoking "yyparse", which pulls tokens from "yylex", you can
+   push one token at a time to the parser using "yypush_parse", which will
    return to the caller after processing each token.  By default, the push
    interface is disabled.  Either of the following directives will enable it:
  
      %define api.push_pull "push" // Just push; does not require yylex.
      %define api.push_pull "both" // Push and pull; requires yylex.
  
-   See the new section `A Push Parser' in the Bison manual for details.
+   See the new section "A Push Parser" in the Bison manual for details.
  
    The current push parsing interface is experimental and may evolve.  More user
    feedback will help to stabilize it.
  ** Java
  
    Bison can now generate an LALR(1) parser in Java.  The skeleton is
-   `data/lalr1.java'.  Consider using the new %language directive instead of
+   "data/lalr1.java".  Consider using the new %language directive instead of
    %skeleton to select it.
  
-   See the new section `Java Parsers' in the Bison manual for details.
+   See the new section "Java Parsers" in the Bison manual for details.
  
    The current Java interface is experimental and may evolve.  More user
    feedback will help to stabilize it.
  ** XML Automaton Report
  
    Bison can now generate an XML report of the LALR(1) automaton using the new
-   `--xml' option.  The current XML schema is experimental and may evolve.  More
+   "--xml" option.  The current XML schema is experimental and may evolve.  More
    user feedback will help to stabilize it.
  
  ** The grammar file may now specify the name of the parser header file using
  
      %define lr.keep_unreachable_states
  
-   See the %define entry in the `Bison Declaration Summary' in the Bison manual
+   See the %define entry in the "Bison Declaration Summary" in the Bison manual
    for further discussion.
  
- ** Lookahead Set Correction in the `.output' Report
+ ** Lookahead Set Correction in the ".output" Report
  
-   When instructed to generate a `.output' file including lookahead sets
-   (using `--report=lookahead', for example), Bison now prints each reduction's
+   When instructed to generate a ".output" file including lookahead sets
+   (using "--report=lookahead", for example), Bison now prints each reduction's
    lookahead set only next to the associated state's one item that (1) is
    associated with the same rule as the reduction and (2) has its dot at the end
    of its RHS.  Previously, Bison also erroneously printed the lookahead set
    next to all of the state's other items associated with the same rule.  This
-   bug affected only the `.output' file and not the generated parser source
+   bug affected only the ".output" file and not the generated parser source
    code.
  
- ** --report-file=FILE is a new option to override the default `.output' file
+ ** --report-file=FILE is a new option to override the default ".output" file
    name.
  
- ** The `=' that used to be required in the following directives is now
+ ** The "=" that used to be required in the following directives is now
    deprecated:
  
      %file-prefix "parser"
      %name-prefix "c_"
      %output "parser.c"
  
- ** An Alternative to `%{...%}' -- `%code QUALIFIER {CODE}'
+ ** An Alternative to "%{...%}" -- "%code QUALIFIER {CODE}"
  
    Bison 2.3a provided a new set of directives as a more flexible alternative to
    the traditional Yacc prologue blocks.  Those have now been consolidated into
    the purpose of the code and thus the location(s) where Bison should generate
    it:
  
-     1. `%code          {CODE}' replaces `%after-header  {CODE}'
-     2. `%code requires {CODE}' replaces `%start-header  {CODE}'
-     3. `%code provides {CODE}' replaces `%end-header    {CODE}'
-     4. `%code top      {CODE}' replaces `%before-header {CODE}'
+     1. "%code          {CODE}" replaces "%after-header  {CODE}"
+     2. "%code requires {CODE}" replaces "%start-header  {CODE}"
+     3. "%code provides {CODE}" replaces "%end-header    {CODE}"
+     4. "%code top      {CODE}" replaces "%before-header {CODE}"
  
-   See the %code entries in section `Bison Declaration Summary' in the Bison
-   manual for a summary of the new functionality.  See the new section `Prologue
-   Alternatives' for a detailed discussion including the advantages of %code
+   See the %code entries in section "Bison Declaration Summary" in the Bison
+   manual for a summary of the new functionality.  See the new section "Prologue
+   Alternatives" for a detailed discussion including the advantages of %code
    over the traditional Yacc prologues.
  
    The prologue alternatives are experimental.  More user feedback will help to
    sometimes prove to be false alarms in existing grammars employing the Yacc
    constructs $0 or $-N (where N is some positive integer).
  
-   To enable these warnings, specify the option `--warnings=midrule-values' or
-   `-W', which is a synonym for `--warnings=all'.
+   To enable these warnings, specify the option "--warnings=midrule-values" or
+   "-W", which is a synonym for "--warnings=all".
  
- ** Default %destructor or %printer with `<*>' or `<>'
+ ** Default %destructor or %printer with "<*>" or "<>"
  
    Bison now recognizes two separate kinds of default %destructor's and
    %printer's:
  
-     1. Place `<*>' in a %destructor/%printer symbol list to define a default
+     1. Place "<*>" in a %destructor/%printer symbol list to define a default
         %destructor/%printer for all grammar symbols for which you have formally
         declared semantic type tags.
  
-     2. Place `<>' in a %destructor/%printer symbol list to define a default
+     2. Place "<>" in a %destructor/%printer symbol list to define a default
         %destructor/%printer for all grammar symbols without declared semantic
         type tags.
  
-   Bison no longer supports the `%symbol-default' notation from Bison 2.3a.
-   `<*>' and `<>' combined achieve the same effect with one exception: Bison no
+   Bison no longer supports the "%symbol-default" notation from Bison 2.3a.
+   "<*>" and "<>" combined achieve the same effect with one exception: Bison no
    longer applies any %destructor to a mid-rule value if that mid-rule value is
    not actually ever referenced using either $$ or $n in a semantic action.
  
    feedback will help to determine whether they should become permanent
    features.
  
-   See the section `Freeing Discarded Symbols' in the Bison manual for further
+   See the section "Freeing Discarded Symbols" in the Bison manual for further
    details.
  
  ** %left, %right, and %nonassoc can now declare token numbers.  This is required
-   by POSIX.  However, see the end of section `Operator Precedence' in the Bison
+   by POSIX.  However, see the end of section "Operator Precedence" in the Bison
    manual for a caveat concerning the treatment of literal strings.
  
  ** The nonfunctional --no-parser, -n, and %no-parser options have been
      %destructor { } <character>
  
    guarantees that, when the parser discards any user-defined symbol that has a
-   semantic type tag other than `<character>', it passes its semantic value to
-   `free'.  However, when the parser discards a `STRING1' or a `string1', it
-   also prints its line number to `stdout'.  It performs only the second
-   `%destructor' in this case, so it invokes `free' only once.
+   semantic type tag other than "<character>", it passes its semantic value to
+   "free".  However, when the parser discards a "STRING1" or a "string1", it
+   also prints its line number to "stdout".  It performs only the second
+   "%destructor" in this case, so it invokes "free" only once.
  
    [Although we failed to mention this here in the 2.3a release, the default
    %destructor's and %printer's were experimental, and they were rewritten in
    future versions.]
  
- ** Except for LALR(1) parsers in C with POSIX Yacc emulation enabled (with `-y',
-   `--yacc', or `%yacc'), Bison no longer generates #define statements for
+ ** Except for LALR(1) parsers in C with POSIX Yacc emulation enabled (with "-y",
+   "--yacc", or "%yacc"), Bison no longer generates #define statements for
    associating token numbers with token names.  Removing the #define statements
    helps to sanitize the global namespace during preprocessing, but POSIX Yacc
    requires them.  Bison still generates an enum for token names in all cases.
    potentially incompatible with previous releases of Bison.
  
    As before, you declare prologue blocks in your grammar file with the
-   `%{ ... %}' syntax.  To generate the pre-prologue, Bison concatenates all
+   "%{ ... %}" syntax.  To generate the pre-prologue, Bison concatenates all
    prologue blocks that you've declared before the first %union.  To generate
    the post-prologue, Bison concatenates all prologue blocks that you've
    declared after the first %union.
         * the code file before the contents of the header file.  It does *not*
         * insert it into the header file.  This is a good place to put
         * #include's that you want at the top of your code file.  A common
-        * example is `#include "system.h"'.  */
+        * example is '#include "system.h"'.  */
      }
      %start-header {
        /* Bison inserts this block into both the header file and the code file.
    [Although we failed to mention this here in the 2.3a release, the prologue
    alternatives were experimental, and they were rewritten in future versions.]
  
- ** The option `--report=look-ahead' has been changed to `--report=lookahead'.
+ ** The option "--report=look-ahead" has been changed to "--report=lookahead".
    The old spelling still works, but is not documented and may be removed
    in a future release.
  
  * Changes in version 2.3, 2006-06-05:
  
- ** GLR grammars should now use `YYRECOVERING ()' instead of `YYRECOVERING',
+ ** GLR grammars should now use "YYRECOVERING ()" instead of "YYRECOVERING",
    for compatibility with LALR(1) grammars.
  
  ** It is now documented that any definition of YYSTYPE or YYLTYPE should
    if the symbols have destructors.  For instance:
  
       exp: exp "?" exp ":" exp { $1 ? $1 : $3; }
 -      | exp "+" exp
 -      ;
 +        | exp "+" exp
 +        ;
  
    will trigger a warning about $$ and $5 in the first rule, and $3 in
    the second ($1 is copied to $$ by the default rule).  This example
    most likely contains three errors, and could be rewritten as:
  
       exp: exp "?" exp ":" exp
 -          { $$ = $1 ? $3 : $5; free ($1 ? $5 : $3); free ($1); }
 -      | exp "+" exp
 -          { $$ = $1 ? $1 : $3; if ($1) free ($3); }
 -      ;
 +            { $$ = $1 ? $3 : $5; free ($1 ? $5 : $3); free ($1); }
 +        | exp "+" exp
 +            { $$ = $1 ? $1 : $3; if ($1) free ($3); }
 +        ;
  
    However, if the original actions were really intended, memory leaks
    and all, the warnings can be suppressed by letting Bison believe the
    values are used, e.g.:
  
       exp: exp "?" exp ":" exp { $1 ? $1 : $3; (void) ($$, $5); }
 -      | exp "+" exp         { $$ = $1; (void) $3; }
 -      ;
 +        | exp "+" exp         { $$ = $1; (void) $3; }
 +        ;
  
    If there are mid-rule actions, the warning is issued if no action
    uses it.  The following triggers no warning: $1 and $3 are used.
    The %parse-params are available in the destructors (and the
    experimental printers) as per the documentation.
  
- ** Bison now warns if it finds a stray `$' or `@' in an action.
+ ** Bison now warns if it finds a stray "$" or "@" in an action.
  
  ** %require "VERSION"
    This specifies that the grammar file depends on features implemented
  ** lalr1.cc: The token and value types are now class members.
    The tokens were defined as free form enums and cpp macros.  YYSTYPE
    was defined as a free form union.  They are now class members:
-   tokens are enumerations of the `yy::parser::token' struct, and the
-   semantic values have the `yy::parser::semantic_type' type.
+   tokens are enumerations of the "yy::parser::token" struct, and the
+   semantic values have the "yy::parser::semantic_type" type.
  
    If you do not want or can update to this scheme, the directive
-   `%define "global_tokens_and_yystype" "1"' triggers the global
+   '%define "global_tokens_and_yystype" "1"' triggers the global
    definition of tokens and YYSTYPE.  This change is suitable both
    for previous releases of Bison, and this one.
  
    If you wish to update, then make sure older version of Bison will
-   fail using `%require "2.2"'.
+   fail using '%require "2.2"'.
  
  ** DJGPP support added.
  \f
    - A new directive "%expect-rr N" specifies the expected number of
      reduce/reduce conflicts in GLR parsers.
  
-   - %token numbers can now be hexadecimal integers, e.g., `%token FOO 0x12d'.
+   - %token numbers can now be hexadecimal integers, e.g., "%token FOO 0x12d".
      This is a GNU extension.
  
-   - The option `--report=lookahead' was changed to `--report=look-ahead'.
+   - The option "--report=lookahead" was changed to "--report=look-ahead".
      [However, this was changed back after 2.3.]
  
    - Experimental %destructor support has been added to lalr1.cc.
      This reverts to the behavior of Bison 1.33 and earlier, and improves
      compatibility with Yacc.
  
-   - `parse error' -> `syntax error'
-     Bison now uniformly uses the term `syntax error'; formerly, the code
-     and manual sometimes used the term `parse error' instead.  POSIX
-     requires `syntax error' in diagnostics, and it was thought better to
+   - "parse error" -> "syntax error"
+     Bison now uniformly uses the term "syntax error"; formerly, the code
+     and manual sometimes used the term "parse error" instead.  POSIX
+     requires "syntax error" in diagnostics, and it was thought better to
      be consistent.
  
    - The documentation now emphasizes that yylex and yyerror must be
      output as "foo\\bar.y".
  
    - Yacc command and library now available
-     The Bison distribution now installs a `yacc' command, as POSIX requires.
+     The Bison distribution now installs a "yacc" command, as POSIX requires.
      Also, Bison now installs a small library liby.a containing
      implementations of Yacc-compatible yyerror and main functions.
      This library is normally not useful, but POSIX requires it.
  
  ** Other compatibility issues
  
-   - %union directives can now have a tag before the `{', e.g., the
-     directive `%union foo {...}' now generates the C code
-     `typedef union foo { ... } YYSTYPE;'; this is for Yacc compatibility.
-     The default union tag is `YYSTYPE', for compatibility with Solaris 9 Yacc.
-     For consistency, YYLTYPE's struct tag is now `YYLTYPE' not `yyltype'.
+   - %union directives can now have a tag before the "{", e.g., the
+     directive "%union foo {...}" now generates the C code
+     "typedef union foo { ... } YYSTYPE;"; this is for Yacc compatibility.
+     The default union tag is "YYSTYPE", for compatibility with Solaris 9 Yacc.
+     For consistency, YYLTYPE's struct tag is now "YYLTYPE" not "yyltype".
      This is for compatibility with both Yacc and Bison 1.35.
  
-   - `;' is output before the terminating `}' of an action, for
+   - ";" is output before the terminating "}" of an action, for
      compatibility with Bison 1.35.
  
    - Bison now uses a Yacc-style format for conflict reports, e.g.,
-     `conflicts: 2 shift/reduce, 1 reduce/reduce'.
+     "conflicts: 2 shift/reduce, 1 reduce/reduce".
  
-   - `yystype' and `yyltype' are now obsolescent macros instead of being
+   - "yystype" and "yyltype" are now obsolescent macros instead of being
      typedefs or tags; they are no longer documented and are planned to be
      withdrawn in a future release.
  
  
    - GLR and inline
      Users of Bison have to decide how they handle the portability of the
-     C keyword `inline'.
+     C keyword "inline".
  
-   - `parsing stack overflow...' -> `parser stack overflow'
-     GLR parsers now report `parser stack overflow' as per the Bison manual.
+   - "parsing stack overflow..." -> "parser stack overflow"
+     GLR parsers now report "parser stack overflow" as per the Bison manual.
  
  ** Bison now warns if it detects conflicting outputs to the same file,
-   e.g., it generates a warning for `bison -d -o foo.h foo.y' since
+   e.g., it generates a warning for "bison -d -o foo.h foo.y" since
    that command outputs both code and header to foo.h.
  
  ** #line in output files
    In agreement with POSIX and with other Yaccs, leaving a default
    action is valid when $$ is untyped, and $1 typed:
  
 -      untyped: ... typed;
 +        untyped: ... typed;
  
    but the converse remains an error:
  
 -      typed: ... untyped;
 +        typed: ... untyped;
  
  ** Values of mid-rule actions
    The following code:
  
 -      foo: { ... } { $$ = $1; } ...
 +        foo: { ... } { $$ = $1; } ...
  
    was incorrectly rejected: $1 is defined in the second mid-rule
    action, and is equal to the $$ of the first mid-rule action.
  
  ** Output Directory
    When not in Yacc compatibility mode, when the output file was not
-   specified, running `bison foo/bar.y' created `foo/bar.c'.  It
-   now creates `bar.c'.
+   specified, running "bison foo/bar.y" created "foo/bar.c".  It
+   now creates "bar.c".
  
  ** Undefined token
    The undefined token was systematically mapped to 2 which prevented
    will be mapped onto another number.
  
  ** Verbose error messages
-   They no longer report `..., expecting error or...' for states where
+   They no longer report "..., expecting error or..." for states where
    error recovery is possible.
  
  ** End token
-   Defaults to `$end' instead of `$'.
+   Defaults to "$end" instead of "$".
  
  ** Error recovery now conforms to documentation and to POSIX
    When a Bison-generated parser encounters a syntax error, it now pops
    Rules that can never be reduced because of conflicts are now
    reported.
  
- ** Incorrect `Token not used'
+ ** Incorrect "Token not used"
    On a grammar such as
  
             %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.
+   bison reported both "useful" and "useless" as useless tokens.
  
  ** Revert the C++ namespace changes introduced in 1.31
    as they caused too many portability hassles.
  ** Token end-of-file
    The token end of file may be specified by the user, in which case,
    the user symbol is used in the reports, the graphs, and the verbose
-   error messages instead of `$end', which remains being the default.
+   error messages instead of "$end", which remains being the default.
    For instance
       %token MYEOF 0
    or
    Croatian, thanks to Denis Lackovic.
  
  ** Incorrect token definitions
-   When given `%token 'a' "A"', Bison used to output `#define 'a' 65'.
+   When given
+     %token 'a' "A"
+   bison used to output
+     #define 'a' 65
  
  ** Token definitions as enums
    Tokens are output both as the traditional #define's, and, provided
    produces additional information:
    - itemset
      complete the core item sets with their closure
-   - lookahead [changed to `look-ahead' in 1.875e through 2.3, but changed back]
+   - lookahead [changed to "look-ahead" in 1.875e through 2.3, but changed back]
      explicitly associate lookahead tokens to items
    - solved
      describe shift/reduce conflicts solving.
  
  ** File name clashes are detected
    $ bison foo.y -d -o foo.x
-   fatal error: header and parser would both be named `foo.x'
+   fatal error: header and parser would both be named "foo.x"
  
- ** A missing `;' at the end of a rule triggers a warning
+ ** A missing ";" at the end of a rule triggers a warning
    In accordance with POSIX, and in agreement with other
    Yacc implementations, Bison will mandate this semicolon in the near
    future.  This eases the implementation of a Bison parser of Bison
    GNU Gettext asserts 10 s/r conflicts, but there are 7.  Now that
    Bison dies on incorrect %expectations, we fear there will be
    too many bug reports for Gettext, so _for the time being_, %expect
-   does not trigger an error when the input file is named `plural.y'.
+   does not trigger an error when the input file is named "plural.y".
  
  ** Use of alloca in parsers
    If YYSTACK_USE_ALLOCA is defined to 0, then the parsers will use
    New.
  
  ** --output
-   New, aliasing `--output-file'.
+   New, aliasing "--output-file".
  \f
  * Changes in version 1.30, 2001-10-26:
  
- ** `--defines' and `--graph' have now an optional argument which is the
-   output file name. `-d' and `-g' do not change; they do not take any
+ ** "--defines" and "--graph" have now an optional argument which is the
+   output file name. "-d" and "-g" do not change; they do not take any
    argument.
  
- ** `%source_extension' and `%header_extension' are removed, failed
+ ** "%source_extension" and "%header_extension" are removed, failed
    experiment.
  
  ** Portability fixes.
  ** The output file does not define const, as this caused problems when used
    with common autoconfiguration schemes.  If you still use ancient compilers
    that lack const, compile with the equivalent of the C compiler option
-   `-Dconst='.  Autoconf's AC_C_CONST macro provides one way to do this.
+   "-Dconst=".  Autoconf's AC_C_CONST macro provides one way to do this.
  
- ** Added `-g' and `--graph'.
+ ** Added "-g" and "--graph".
  
  ** The Bison manual is now distributed under the terms of the GNU FDL.
  
  
  ** Added the old Bison reference card.
  
- ** Added `--locations' and `%locations'.
+ ** Added "--locations" and "%locations".
  
- ** Added `-S' and `--skeleton'.
+ ** Added "-S" and "--skeleton".
  
- ** `%raw', `-r', `--raw' is disabled.
+ ** "%raw", "-r", "--raw" is disabled.
  
  ** Special characters are escaped when output.  This solves the problems
    of the #line lines with path names including backslashes.
  
  ** New directives.
-   `%yacc', `%fixed_output_files', `%defines', `%no_parser', `%verbose',
-   `%debug', `%source_extension' and `%header_extension'.
+   "%yacc", "%fixed_output_files", "%defines", "%no_parser", "%verbose",
+   "%debug", "%source_extension" and "%header_extension".
  
  ** @$
    Automatic location tracking.
@@@ -1686,4 -1646,5 +1714,5 @@@ along with this program.  If not, see <
  
  Local Variables:
  mode: outline
+ fill-column: 76
  End:
diff --combined README-hacking
index f79a31a8f57b25f101c37d69b55a353667b93be0,97c73a80c5b3e506841b6d9849eb717bfe70b504..c4578fcc9de6a48ec41745c80ec0a1ff9778318e
@@@ -15,25 -15,16 +15,16 @@@ First, if it is a large change, you mus
  the appropriate paperwork.  Second, be sure to add their name and
  email address to THANKS.
  
- ** If a change fixes a test, mention the test in the ChangeLog entry.
+ ** If a change fixes a test, mention the test in the commit message.
  
  ** Bug reports
- If somebody reports a new bug, mention his name in the ChangeLog entry
+ If somebody reports a new bug, mention his name in the commit message
  and in the test case you write.  Put him into THANKS.
  
  The correct response to most actual bugs is to write a new test case
  which demonstrates the bug.  Then fix the bug, re-run the test suite,
  and check everything in.
  
- ** You may find it useful to install the git-merge-changelog merge driver:
-   http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/git-merge-changelog.c
- When following the generic installation instructions there, keep in mind that
- your clone of Bison's git repository already contains appropriate
- .gitattributes files, and running Bison's bootstrap script will make the
- necessary changes to .git/config.
  
  * Hacking
  
@@@ -46,13 -37,6 +37,13 @@@ of the .output file etc.  This exclude
  (comparable to assert/abort), and all the --trace output which is
  meant for the maintainers only.
  
 +** Horizontal tabs
 +Do not add horizontal tab characters to any file in Bison's repository
 +except where required.  For example, do not use tabs to format C code.
 +However, make files, ChangeLog, and some regular expressions require
 +tabs.  Also, test cases might need to contain tabs to check that Bison
 +properly processes tabs in its input.
 +
  
  * Working from the repository
  
@@@ -176,7 -160,7 +167,7 @@@ The autoconf files we use are currently
          lib/m4sugar/m4sugar.m4
          lib/m4sugar/foreach.m4
  
- These files don't change very often in autoconf, so it should be
+ These files don't change very often in Autoconf, so it should be
  relatively straight-forward to examine the differences in order to
  decide whether to update.
  
@@@ -196,6 -180,9 +187,9 @@@ release
  - Build with -DGNULIB_POSIXCHECK.  It suggests gnulib modules that can
    fix portability issues.
  
+ - Check with `make syntax-check' if there are issues diagnosed by
+   gnulib.
  - run `make maintainer-check' which:
    - runs `valgrind -q bison' to run Bison under Valgrind.
    - runs the parsers under Valgrind.
    Bison's included XSLT style sheets with the output of --report=all and
    --graph.
  
+ - running `make maintainer-release-check' takes care of running
+   maintainer-check, maintainer-push-check and maintainer-xml-check.
  - Change tests/atlocal/CFLAGS to add your preferred options.  For
    instance, `-traditional' to check that the parsers are K&R.  Note
    that it does not make sense for glr.c, which should be ANSI,
    but currently is actually GNU C, nor for lalr1.cc.
  
 +- Test with a very recent version of GCC for both C and C++.  Testing
 +  with older versions that are still in use is nice too.
 +
  
  * Release Procedure
  
@@@ -260,16 -247,17 +257,17 @@@ occurrences of PACKAGE_COPYRIGHT_YEAR i
  The version number, *and* the date of the release (including for
  betas).
  
- ** Update ChangeLog
- Should have an entry similar to `Version 1.49b.'.
+ ** Mention the release name in a commit message
+ Should have an entry similar to `Version 2.3b.'.
  
  ** Tag the release
- Before Bison will build with the right version number, you must tag the release
- in git.  Do this after all other changes.  The command is similar to:
+ Before Bison will build with the right version number, you must tag
+ the release in git.  Do this after all other changes.  The command is
+ similar to:
  
    git tag -a v2.3b
  
- The log message can be simply:
+ The commit message can be simply:
  
    Bison 2.3b
  
diff --combined THANKS
index f2c5231aa85931f98ad7b92a99b5776c114aedcf,e3bf221b365c6c6d388a19b666cc5c70a432b728..9d0af4bee40b2599901c4ef521a7a259f86ee6b8
--- 1/THANKS
--- 2/THANKS
+++ b/THANKS
@@@ -69,7 -69,6 +69,7 @@@ Matt Kraai                kraai@alumni.
  Matt Rosing               rosing@peakfive.com
  Michael Hayes             m.hayes@elec.canterbury.ac.nz
  Michael Raskin            7c6f434c@mail.ru
 +Michiel De Wilde          mdewilde.agilent@gmail.com
  Mickael Labau             labau_m@epita.fr
  Mike Castle               dalgoda@ix.netcom.com
  Neil Booth                NeilB@earthling.net
@@@ -87,7 -86,6 +87,7 @@@ Per Allansson             per@appgate.c
  Peter Fales               psfales@lucent.com
  Peter Hamorsky            hamo@upjs.sk
  Piotr Gackiewicz          gacek@intertel.com.pl
 +Quentin Hocquet           hocquet@gostai.com
  Quoc Peyrot               chojin@lrde.epita.fr
  R Blake                   blakers@mac.com
  Raja R Harinath           harinath@cs.umn.edu
@@@ -114,6 -112,7 +114,7 @@@ Tys Lefering              gccbison@gmai
  Vin Shelton               acs@alumni.princeton.edu
  W.C.A. Wijngaards         wouter@NLnetLabs.nl
  Wayne Green               wayne@infosavvy.com
+ Wei Song                  wsong83@gmail.com
  Wolfgang S. Kechel        wolfgang.kechel@prs.de
  Wolfram Wagner            ww@mpi-sb.mpg.de
  Wwp                       subscript@free.fr
diff --combined bootstrap.conf
index e6243a8d3a731ba3f9107916f23d8f9117534789,3303ef37068a50090723b2a97902cd2c725c59c2..237ae7558174a9cb13596aa559f1ce2471a4a277
@@@ -22,11 -22,12 +22,12 @@@ gnulib_modules=
    gettext git-version-gen gitlog-to-changelog
    gpl-3.0 hash inttypes isnan javacomp-script
    javaexec-script ldexpl maintainer-makefile malloc-gnu mbschr mbsrchr
-   mbswidth obstack perror pipe-posix progname
+   mbswidth obstack perror progname
    quote quotearg realloc-posix
    spawn-pipe stdbool stpcpy strdup-posix strerror strtoul strverscmp
    unistd unistd-safer unlocked-io update-copyright unsetenv verify
-   warnings xalloc xalloc-die xstrndup
+   warnings
+   xalloc xalloc-die xmemdup0 xstrndup
  
    fprintf-posix printf-posix snprintf-posix sprintf-posix
    vsnprintf-posix vsprintf-posix
@@@ -66,9 -67,6 +67,9 @@@ gnulib_tool_option_extras='--symlink --
  
  bootstrap_post_import_hook()
  {
 +  # Massage lib/gnulib.mk before using it later in the bootstrapping process.
 +  etc/prefix-gnulib-mk --lib-name=$gnulib_name lib/$gnulib_mk
 +
    # Ensure that ChangeLog exists, for automake.
    test -f ChangeLog || touch ChangeLog
  }
diff --combined build-aux/.gitignore
index 3a663bf0ea32a4706c90b5c51042733bb9679550,f09add4fee02c2ce41762de4fa97feabb7a09ab9..008e7452f152e8deff297954ea0b30bdd88bb344
@@@ -1,9 -1,11 +1,10 @@@
 -/Makefile
 -/Makefile.in
  /announce-gen
  /arg-nonnull.h
  /c++defs.h
  /compile
  /config.guess
  /config.rpath
++/config.rpath~
  /config.sub
  /depcomp
  /gendocs.sh
diff --combined cfg.mk
index ce7553932cc977519263e4f293ec96e1118eeacc,a208fe9ca46a022d40c39ec7fb66ca5cf1588165..6ccef9c92ac3da4292f528363b9e77f1d8a0886d
--- 1/cfg.mk
--- 2/cfg.mk
+++ b/cfg.mk
@@@ -33,9 -33,15 +33,9 @@@ url_dir_list = 
    ftp://$(gnu_rel_host)/gnu/bison
  
  # Tests not to run as part of "make distcheck".
 -# Exclude changelog-check here so that there's less churn in ChangeLog
 -# files -- otherwise, you'd need to have the upcoming version number
 -# at the top of the file for each `make distcheck' run.
 -local-checks-to-skip = \
 -  changelog-check \
 +local-checks-to-skip =                        \
    sc_immutable_NEWS                   \
 -  sc_prohibit_always_true_header_tests        \
 -  sc_prohibit_atoi_atof                       \
 -  sc_prohibit_strcmp
 +  sc_prohibit_atoi_atof
  
  # The local directory containing the checked-out copy of gnulib used in
  # this release.  Used solely to get a date for the "announcement" target.
@@@ -56,11 -62,12 +56,12 @@@ $(call exclude,                                                            
    bindtextdomain=^lib/main.c$$                                                \
    program_name=^lib/main.c$$                                          \
    prohibit_always-defined_macros=^data/yacc.c|^djgpp/                 \
+   prohibit_always-defined_macros+=?|^lib/timevar.c$$                  \
    prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$    \
    prohibit_always-defined_macros+=?|^tests/regression.at$$            \
 -  prohibit_empty_lines_at_EOF=^src/parse-gram.[ch]$$                  \
 +  prohibit_empty_lines_at_EOF=^src/parse-gram.h$$                     \
 +  prohibit_strcmp=^doc/bison\.texinfo$$                                       \
    require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$          \
    space_tab=^tests/(input|c\+\+)\.at$$                                        \
 -  trailing_blank=^src/parse-gram.[ch]$$                                       \
    unmarked_diagnostics=^djgpp/                                                \
  )
diff --combined configure.ac
index 763fe2a9770ad0a8370498690ef4d330da4370b4,6a75d7b414e2b70c0f384288231dd9a85e09511e..95a1b0263b356f2f4f9c4e0ab2195b59f52eb952
@@@ -45,13 -45,11 +45,13 @@@ AC_CONFIG_MACRO_DIR([m4]
  # releases, we want to be able run make dist without being required to
  # add a bogus NEWS entry.  In that case, the version string
  # automatically contains a dash, which we also let disable gnits.
 -AM_INIT_AUTOMAKE([1.11.1 dist-xz silent-rules]
 +AM_INIT_AUTOMAKE([1.11.1 dist-xz nostdinc
 +                 color-tests parallel-tests
 +                 silent-rules]
                   m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [[-_]],
                             [gnu], [gnits]))
  AM_SILENT_RULES([yes])
- AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
+ AC_CONFIG_HEADERS([lib/config.h:lib/config.in.h])
  
  # Checks for the compiler.
  AC_PROG_CC_STDC
@@@ -72,7 -70,7 +72,7 @@@ if test "$enable_gcc_warnings" = yes; t
      -Wcast-qual -Wformat -Wpointer-arith -Wwrite-strings'
    warn_c='-Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes
      -Wshadow -Wstrict-prototypes'
-   warn_cxx='-Wnoexcept -Wzero-as-null-pointer-constant'
+   warn_cxx='-Wnoexcept'
    AC_LANG_PUSH([C])
    for i in $warn_common $warn_c;
    do
@@@ -89,6 -87,8 +89,8 @@@
    do
      gl_WARN_ADD([$i], [WARN_CXXFLAGS])
    done
+   gl_WARN_ADD([ -Wzero-as-null-pointer-constant], [WARN_CXXFLAGS],
+               [AC_LANG_PROGRAM([], [nullptr])])
    gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS])
    # Warnings for the test suite only.
    gl_WARN_ADD([-Wundef], [WARN_CXXFLAGS_TEST])
@@@ -105,8 -105,8 +107,8 @@@ AC_ARG_ENABLE([yacc]
    , [enable_yacc=yes])
  case $enable_yacc in
  yes)
 -  YACC_SCRIPT=yacc
 -  YACC_LIBRARY=liby.a;;
 +  YACC_SCRIPT=src/yacc
 +  YACC_LIBRARY=lib/liby.a;;
  *)
    YACC_SCRIPT=
    YACC_LIBRARY=;;
@@@ -116,19 -116,13 +118,17 @@@ AC_SUBST([YACC_LIBRARY]
  
  # Checks for programs.
  AC_PROG_LEX
- if test "$FLEX" != yes; then
-   AC_MSG_ERROR([Flex is required])
- fi
+ $LEX_IS_FLEX || AC_MSG_ERROR([Flex is required])
  AC_PROG_YACC
  AC_PROG_RANLIB
  AC_PROG_GNU_M4
  AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the GNU M4 executable name.])
  AC_DEFINE_UNQUOTED([M4_GNU_OPTION], ["$M4_GNU"], [Define to "-g" if GNU M4
  supports -g, otherwise to "".])
 +AC_PATH_PROG([PERL], [perl])
 +if test -z "$PERL"; then
 +   AC_MSG_ERROR([perl not found])
 +fi
  AM_MISSING_PROG([HELP2MAN], [help2man])
  AC_PATH_PROG([XSLTPROC], [xsltproc])
  AC_SUBST([XSLTPROC])
@@@ -166,30 -160,24 +166,30 @@@ AC_CONFIG_FILES([etc/bench.pl], [chmod 
  
  # Initialize the test suite.
  AC_CONFIG_TESTDIR(tests)
 -AC_CONFIG_FILES([tests/Makefile tests/atlocal])
 +AC_CONFIG_FILES([tests/atlocal])
  AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
  AC_CHECK_PROGS([VALGRIND], [valgrind])
  AM_MISSING_PROG([AUTOM4TE], [autom4te])
  # Needed by tests/atlocal.in.
  AC_SUBST([GCC])
  
 -gt_JAVACOMP([1.3])
 +gt_JAVACOMP([1.3], [1.4])
  gt_JAVAEXEC
  
 +# We use gnulib, but from lib/local.mk instead of lib/Makefile.am.
 +# So prefix paths with lib/.  See also etc/prefix-gnulib-mk.
 +gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, , lib/,g'`
 +# Listing the names of the variables to prefix is error-prone.
 +# Rather, adjust all the AC_SUBST variables whose name ends in '_H',
 +# and whose content ends in '.h'.
 +for ac_var in $ac_subst_vars
 +do
 +  eval "ac_val=\$$ac_var"
 +  case $ac_var=$ac_val in
 +    (*_H=*.h) eval "$ac_var=lib/\$$ac_var";;
 +  esac
 +done
  AC_CONFIG_FILES([Makefile
 -               build-aux/Makefile
 -               po/Makefile.in
 -               data/Makefile
 -               etc/Makefile
 -               examples/Makefile
 -                  examples/calc++/Makefile
 -               lib/Makefile src/Makefile
 -               doc/Makefile
 -                 doc/yacc.1])
 +                 po/Makefile.in
 +                 doc/yacc.1])
  AC_OUTPUT
diff --combined data/c.m4
index e140ade85b340baf834ae9b5f8bcc5b220d461e1,b49d6dc9378252686199ac3717a1f4fe868538ab..0d30a4966a271cff0e9bbf0cf741880590d8d85b
+++ b/data/c.m4
  # You should have received a copy of the GNU General Public License
  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
+ # b4_tocpp(STRING)
+ # ----------------
+ # Convert STRING into a valid C macro name.
+ m4_define([b4_tocpp],
+ [m4_toupper(m4_bpatsubst(m4_quote($1), [[^a-zA-Z0-9]+], [_]))])
+ # b4_cpp_guard(FILE)
+ # ------------------
+ # A valid C macro name to use as a CPP header guard for FILE.
+ m4_define([b4_cpp_guard],
+ [b4_tocpp(m4_defn([b4_prefix])/[$1])])
+ # b4_cpp_guard_open(FILE)
+ # b4_cpp_guard_close(FILE)
+ # ------------------------
+ # Open/close CPP inclusion guards for FILE.
+ m4_define([b4_cpp_guard_open],
+ [#ifndef b4_cpp_guard([$1])
+ # define b4_cpp_guard([$1])])
+ m4_define([b4_cpp_guard_close],
+ [#endif b4_comment([!b4_cpp_guard([$1])])])
  ## ---------------- ##
  ## 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
  # -----------------
@@@ -75,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])[
  ]])
  
  
@@@ -120,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
  ])
  
@@@ -148,7 -150,7 +175,7 @@@ m4_define([b4_int_type]
  
         m4_eval([0 <= $1]),                [1], [unsigned int],
  
 -                                             [int])])
 +                                               [int])])
  
  
  # b4_int_type_for(NAME)
@@@ -197,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
  ])
  
  
@@@ -235,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)
@@@ -251,7 -243,7 +278,7 @@@ m4_define([b4_token_enums]
     enum yytokentype {
  m4_map_sep([     b4_token_enum], [,
  ],
 -         [$@])
 +           [$@])
     };
  #endif
  ])])
@@@ -266,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.  ##
@@@ -330,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])
@@@ -351,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 ();
@@@ -428,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)
@@@ -460,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
  ])
@@@ -489,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]))[
  {
diff --combined data/glr.c
index e6a8e3818a7adbec1ba9668b2ac0272aa3fdeb14,5f7aac84870ae0110d3ad29fc34fb5068342c335..8f77aa61d330b619770295cfd8bfe26a90b4661e
@@@ -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)])
  
  
  
@@@ -236,7 -228,7 +236,7 @@@ b4_defines_if([[#include "@basename(]b4
  
  /* Enabling traces.  */
  #ifndef YYDEBUG
 -# define YYDEBUG ]b4_debug_flag[
 +# define YYDEBUG ]b4_parse_trace_if([1], [0])[
  #endif
  
  /* Enabling verbose error messages.  */
  # 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.  */
@@@ -379,6 -371,19 +379,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[] =
  {
@@@ -395,10 -400,17 +395,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[] =
@@@ -412,11 -424,41 +412,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
@@@ -437,6 -479,19 +437,6 @@@ 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)[
@@@ -518,12 -573,9 +518,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.  */
@@@ -584,7 -636,13 +584,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
@@@ -681,7 -739,7 +681,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;
@@@ -702,7 -760,7 +702,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
@@@ -810,21 -868,13 +810,20 @@@ static void yyfillin (yyGLRStackItem *
  static void
  yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
  {
-   yyGLRState* s;
    int i;
-   s = yyvsp[yylow0].yystate.yypred;
+   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;
      }
@@@ -859,7 -909,7 +858,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
@@@ -962,7 -1012,7 +961,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
@@@ -1045,10 -1096,9 +1044,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)
  {
@@@ -1114,8 -1164,8 +1113,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
@@@ -1147,9 -1197,9 +1146,9 @@@ yyexpandGLRStack (yyGLRStack* yystackp
  {
    yyGLRStackItem* yynewItems;
    yyGLRStackItem* yyp0, *yyp1;
-   size_t yysize, yynewSize;
+   size_t yynewSize;
    size_t yyn;
-   yysize = yystackp->yynextFree - yystackp->yyitems;
+   size_t yysize = yystackp->yynextFree - yystackp->yyitems;
    if (YYMAXDEPTH - YYHEADROOM < yysize)
      yyMemoryExhausted (yystackp);
    yynewSize = 2*yysize;
                YYRELOC (yyp0, yyp1, yys0->yypred, yystate);
            if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != YY_NULL)
              yys1->yysemantics.yyfirstVal =
-               YYRELOC(yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption);
+               YYRELOC (yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption);
          }
        else
          {
@@@ -1207,9 -1257,9 +1206,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)
@@@ -1276,9 -1326,8 +1275,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
@@@ -1424,18 -1476,11 +1423,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)
            {
-             yyGLRState* yyp, *yysplit = yystackp->yysplitPoint;
-             yyp = yystackp->yytops.yystates[yyi];
+             yyGLRState *yysplit = yystackp->yysplitPoint;
+             yyGLRState *yyp = yystackp->yytops.yystates[yyi];
              while (yyp != yys && yyp != yysplit && yyp->yyposn >= yyposn)
                {
                  if (yyp->yylrState == yynewLRState && yyp->yypred == yys)
@@@ -1530,7 -1574,7 +1529,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
@@@ -1552,8 -1596,8 +1551,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)
  {
          }
        else
          {
-           yySemanticOption** yyz0p;
-           yySemanticOption* yyz1;
-           yyz0p = &yys0->yysemantics.yyfirstVal;
-           yyz1 = yys1->yysemantics.yyfirstVal;
+           yySemanticOption** yyz0p = &yys0->yysemantics.yyfirstVal;
+           yySemanticOption* yyz1 = yys1->yysemantics.yyfirstVal;
            while (YYID (yytrue))
              {
                if (yyz1 == *yyz0p || yyz1 == YY_NULL)
@@@ -1634,11 -1676,11 +1631,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,
                   YYSTYPE* yyvalp]b4_locuser_formals[)
  {
    yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
-   int yynrhs;
-   int yychar_current;
-   YYSTYPE yylval_current;]b4_locations_if([
-   YYLTYPE yylloc_current;])[
-   YYRESULTTAG yyflag;
-   yynrhs = yyrhsLength (yyopt->yyrule);
-   yyflag = yyresolveStates (yyopt->yystate, yynrhs, yystackp]b4_user_args[);
+   int yynrhs = yyrhsLength (yyopt->yyrule);
+   YYRESULTTAG yyflag =
+     yyresolveStates (yyopt->yystate, yynrhs, yystackp]b4_user_args[);
    if (yyflag != yyok)
      {
        yyGLRState *yys;
    if (yynrhs == 0)
      /* Set default location.  */
      yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yyopt->yystate->yyloc;]])[
-   yychar_current = yychar;
-   yylval_current = yylval;]b4_locations_if([
-   yylloc_current = yylloc;])[
-   yychar = yyopt->yyrawchar;
-   yylval = yyopt->yyval;]b4_locations_if([
-   yylloc = yyopt->yyloc;])[
-   yyflag = yyuserAction (yyopt->yyrule, yynrhs,
+   {
+     int yychar_current = yychar;
+     YYSTYPE yylval_current = yylval;]b4_locations_if([
+     YYLTYPE yylloc_current = yylloc;])[
+     yychar = yyopt->yyrawchar;
+     yylval = yyopt->yyval;]b4_locations_if([
+     yylloc = yyopt->yyloc;])[
+     yyflag = yyuserAction (yyopt->yyrule, yynrhs,
                             yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
-                          yystackp, yyvalp]b4_locuser_args[);
-   yychar = yychar_current;
-   yylval = yylval_current;]b4_locations_if([
-   yylloc = yylloc_current;])[
+                            yystackp, yyvalp]b4_locuser_args[);
+     yychar = yychar_current;
+     yylval = yylval_current;]b4_locations_if([
+     yylloc = yylloc_current;])[
+   }
    return yyflag;
  }
  
@@@ -1733,11 -1771,11 +1727,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
@@@ -1766,9 -1804,9 +1760,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[)
        yyresolveLocations (yys1->yypred, yyn1 - 1, yystackp]b4_user_args[);
        if (!yys1->yyresolved)
          {
-           yySemanticOption *yyoption;
            yyGLRStackItem yyrhsloc[1 + YYMAXRHS];
            int yynrhs;
-           int yychar_current;
-           YYSTYPE yylval_current;
-           YYLTYPE yylloc_current;
-           yyoption = yys1->yysemantics.yyfirstVal;
+           yySemanticOption *yyoption = yys1->yysemantics.yyfirstVal;
            YYASSERT (yyoption != YY_NULL);
            yynrhs = yyrhsLength (yyoption->yyrule);
            if (yynrhs > 0)
                yyGLRState *yyprevious = yyoption->yystate;
                yyrhsloc[0].yystate.yyloc = yyprevious->yyloc;
              }
-           yychar_current = yychar;
-           yylval_current = yylval;
-           yylloc_current = yylloc;
-           yychar = yyoption->yyrawchar;
-           yylval = yyoption->yyval;
-           yylloc = yyoption->yyloc;
-           YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs);
-           yychar = yychar_current;
-           yylval = yylval_current;
-           yylloc = yylloc_current;
+           {
+             int yychar_current = yychar;
+             YYSTYPE yylval_current = yylval;
+             YYLTYPE yylloc_current = yylloc;
+             yychar = yyoption->yyrawchar;
+             yylval = yyoption->yyval;
+             yylloc = yyoption->yyloc;
+             YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs);
+             yychar = yychar_current;
+             yylval = yylval_current;
+             yylloc = yylloc_current;
+           }
          }
      }
  }]])[
  
 -/** 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[)
@@@ -1967,6 -2002,10 +1959,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;
@@@ -2326,6 -2326,7 +2318,6 @@@ yyrecoverSyntaxError (yyGLRStack* yysta
      }                                                                        \
    } while (YYID (0))
  
 -
  /*----------.
  | yyparse.  |
  `----------*/
@@@ -2647,7 -2648,9 +2639,7 @@@ yypdumpstack (yyGLRStack* yystackp
    YYFPRINTF (stderr, "\n");
  }
  #endif
 -]
 -
 -b4_epilogue
 +]b4_epilogue[]dnl
  dnl
  dnl glr.cc produces its own header.
  dnl
@@@ -2665,5 -2668,5 +2657,5 @@@ b4_pure_if([]
  b4_locations_if([b4_pure_if([],
  [extern YYLTYPE ]b4_prefix[lloc;])
  ])
 -])])
 +])])[]dnl
  m4_divert_pop(0)
diff --combined data/lalr1.cc
index ef5e1cee4a871030d8ef7e933bad51559b247e4b,4f0b268880d01b16ffa14eca65dcb3b839616993..92f93c2c75d6b98a9bdac4d4f10bd5d74a2f19cb
  
  m4_include(b4_pkgdatadir/[c++.m4])
  
 +
 +# b4_integral_parser_table_declare(TABLE-NAME, CONTENT, COMMENT)
 +# --------------------------------------------------------------
 +# Declare "parser::yy<TABLE-NAME>_" which contents is CONTENT.
 +m4_define([b4_integral_parser_table_declare],
 +[m4_ifval([$3], [b4_c_comment([$3], [  ])
 +])dnl
 +  static const b4_int_type_for([$2]) yy$1_[[]];dnl
 +])
 +
 +# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
 +# -------------------------------------------------------------
 +# Define "parser::yy<TABLE-NAME>_" which contents is CONTENT.
 +m4_define([b4_integral_parser_table_define],
 +[  const b4_int_type_for([$2])
 +  b4_parser_class_name::yy$1_[[]] =
 +  {
 +  $2
 +  };dnl
 +])
 +
 +
 +# b4_symbol_value_template(VAL, [TYPE])
 +# -------------------------------------
 +# Same as b4_symbol_value, but used in a template method.  It makes
 +# a difference when using variants.
 +m4_copy([b4_symbol_value], [b4_symbol_value_template])
 +
 +
 +# b4_lhs_value([TYPE])
 +# --------------------
 +# Expansion of $<TYPE>$.
 +m4_define([b4_lhs_value],
 +          [b4_symbol_value([yylhs.value], [$1])])
 +
 +
 +# b4_lhs_location()
 +# -----------------
 +# Expansion of @$.
 +m4_define([b4_lhs_location],
 +          [yylhs.location])
 +
 +
 +# b4_rhs_data(RULE-LENGTH, NUM)
 +# -----------------------------
 +# Return the data corresponding to the symbol #NUM, where the current
 +# rule has RULE-LENGTH symbols on RHS.
 +m4_define([b4_rhs_data],
 +          [yystack_@{b4_subtract($@)@}])
 +
 +
 +# b4_rhs_state(RULE-LENGTH, NUM)
 +# ------------------------------
 +# The state corresponding to the symbol #NUM, where the current
 +# rule has RULE-LENGTH symbols on RHS.
 +m4_define([b4_rhs_state],
 +          [b4_rhs_data([$1], [$2]).state])
 +
 +
 +# 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],
 +          [b4_symbol_value([b4_rhs_data([$1], [$2]).value], [$3])])
 +
 +
 +# b4_rhs_location(RULE-LENGTH, NUM)
 +# ---------------------------------
 +# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
 +# on RHS.
 +m4_define([b4_rhs_location],
 +          [b4_rhs_data([$1], [$2]).location])
 +
 +
 +# b4_symbol_action(SYMBOL-NUM, KIND)
 +# ----------------------------------
 +# Run the action KIND (destructor or printer) for SYMBOL-NUM.
 +# Same as in C, but using references instead of pointers.
 +m4_define([b4_symbol_action],
 +[b4_symbol_if([$1], [has_$2],
 +[m4_pushdef([b4_dollar_dollar],
 +    [b4_symbol_value_template([yysym.value],
 +                              b4_symbol_if([$1], [has_type],
 +                                           [b4_symbol([$1], [type])]))])dnl
 +m4_pushdef([b4_at_dollar], [yysym.location])dnl
 +      b4_symbol_case_([$1])
 +b4_syncline([b4_symbol([$1], [$2_line])], ["b4_symbol([$1], [$2_file])"])
 +        b4_symbol([$1], [$2])
 +b4_syncline([@oline@], [@ofile@])
 +        break;
 +
 +m4_popdef([b4_at_dollar])dnl
 +m4_popdef([b4_dollar_dollar])dnl
 +])])
 +
 +
 +m4_pushdef([b4_copyright_years],
 +           [2002-2012])
 +
  m4_define([b4_parser_class_name],
            [b4_percent_define_get([[parser_class_name]])])
  
  b4_defines_if([],
                [b4_fatal([b4_skeleton[: using %%defines is mandatory]])])
  
 -b4_percent_define_ifdef([[location_type]], [],
 +b4_locations_if([b4_percent_define_ifdef([[location_type]], [],
    [# Backward compatibility.
--  m4_define([b4_location_constructors])
-   m4_include(b4_pkgdatadir/[location.cc])])])
 -  m4_include(b4_pkgdatadir/[location.cc])])
++   m4_define([b4_location_constructors])
++   m4_include(b4_pkgdatadir/[location.cc])])])
  m4_include(b4_pkgdatadir/[stack.hh])
 +b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])])
  
  # We do want M4 expansion after # for CPP macros.
  m4_changecom()
  m4_divert_push(0)dnl
 -b4_defines_if(
 -[@output(b4_spec_defines_file@)@
 -b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++],
 -             [2002-2012])
 +@output(b4_spec_defines_file@)@
 +b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])
- dnl FIXME: This is wrong, we want computed header guards.
  [
+ /**
+  ** \file ]b4_spec_defines_file[
+  ** Define the ]b4_namespace_ref[::parser class.
+  */
  /* C++ LALR(1) 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]])[
  
 +]b4_parse_assert_if([#include <cassert>])[
 +#include <stdexcept>
  #include <string>
  #include <iostream>
  #include "stack.hh"
 -]b4_percent_define_ifdef([[location_type]], [],
 -                         [[#include "location.hh"]])[
 +]b4_locations_if([b4_percent_define_ifdef([[location_type]], [],
 +                                          [[#include "location.hh"]])])[
 +
 +]b4_variant_if([b4_namespace_open
 +b4_variant_define
 +b4_namespace_close])[
  
  ]b4_null_define[
  
  /* Enabling traces.  */
  #ifndef YYDEBUG
 -# define YYDEBUG ]b4_debug_flag[
 +# define YYDEBUG ]b4_parse_trace_if([1], [0])[
  #endif
  
  /* Enabling verbose error messages.  */
  # 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.  */
    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[);
      virtual ~]b4_parser_class_name[ ();
      void set_debug_level (debug_level_type l);
  #endif
  
 -  private:
 -    /// Report a syntax error.
 -    /// \param loc    where the syntax error is found.
 +    /// Report a syntax error.]b4_locations_if([
 +    /// \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);
 -
 -    /// Generate an error message.
 -    /// \param state   the state where the error occurred.
 -    /// \param tok     the lookahead token.
 -    virtual std::string yysyntax_error_ (int yystate, int tok);
 -
 -#if YYDEBUG
 -    /// \brief Report a symbol value on the debug stream.
 -    /// \param yytype       The token type.
 -    /// \param yyvaluep     Its semantic value.
 -    /// \param yylocationp  Its location.
 -    virtual void yy_symbol_value_print_ (int yytype,
 -                                       const semantic_type* yyvaluep,
 -                                       const location_type* yylocationp);
 -    /// \brief Report a symbol on the debug stream.
 -    /// \param yytype       The token type.
 -    /// \param yyvaluep     Its semantic value.
 -    /// \param yylocationp  Its location.
 -    virtual void yy_symbol_print_ (int yytype,
 -                                 const semantic_type* yyvaluep,
 -                                 const location_type* yylocationp);
 -#endif
 +    virtual void error (]b4_locations_if([const location_type& loc, ])[const std::string& msg);
  
 +    /// Report a syntax error.
 +    void error (const syntax_error& err);
  
 +  private:
      /// State numbers.
      typedef int state_type;
 -    /// State stack type.
 -    typedef stack<state_type>    state_stack_type;
 -    /// Semantic value stack type.
 -    typedef stack<semantic_type> semantic_stack_type;
 -    /// location stack type.
 -    typedef stack<location_type> location_stack_type;
 -
 -    /// The state stack.
 -    state_stack_type yystate_stack_;
 -    /// The semantic value stack.
 -    semantic_stack_type yysemantic_stack_;
 -    /// The location stack.
 -    location_stack_type yylocation_stack_;
 +
 +    /// Generate an error message.
 +    /// \param yystate   the state where the error occurred.
 +    /// \param yytoken   the lookahead token.
 +    virtual std::string yysyntax_error_ (state_type yystate, int yytoken);
 +
 +    /// Compute post-reduction state.
 +    /// \param yystate   the current state
 +    /// \param yylhs     the nonterminal to push on the stack
 +    state_type yy_lr_goto_state_ (state_type yystate, int yylhs);
  
      /// Whether the given \c yypact_ value indicates a defaulted state.
      /// \param yyvalue   the value to check
  
      /// Internal symbol numbers.
      typedef ]b4_int_type_for([b4_translate])[ token_number_type;
 -    /* Tables.  */
 -    /// For a state, the index in \a yytable_ of its portion.
 -    static const ]b4_int_type_for([b4_pact])[ yypact_[];
      static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_;
 -
 -    /// For a state, default reduction number.
 -    /// Unless\a  yytable_ specifies something else to do.
 -    /// Zero means the default is an error.
 -    static const ]b4_int_type_for([b4_defact])[ yydefact_[];
 -
 -    static const ]b4_int_type_for([b4_pgoto])[ yypgoto_[];
 -    static const ]b4_int_type_for([b4_defgoto])[ yydefgoto_[];
 -
 -    /// What to do in a state.
 -    /// \a yytable_[yypact_[s]]: what to do in state \a s.
 -    /// - if positive, shift that token.
 -    /// - if negative, reduce the rule which number is the opposite.
 -    /// - if zero, do what YYDEFACT says.
 -    static const ]b4_int_type_for([b4_table])[ yytable_[];
      static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
  
 -    static const ]b4_int_type_for([b4_check])[ yycheck_[];
 -
 -    /// For a state, its accessing symbol.
 -    static const ]b4_int_type_for([b4_stos])[ yystos_[];
 -
 -    /// For a rule, its LHS.
 -    static const ]b4_int_type_for([b4_r1])[ yyr1_[];
 -    /// For a rule, its RHS length.
 -    static const ]b4_int_type_for([b4_r2])[ yyr2_[];
 +    /* Tables.  */
 +]b4_parser_tables_declare[
  
  #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
      /// For a symbol, its name in clear.
      static std::string yytnamerr_ (const char *n);])[
  
  #if YYDEBUG
 -    /// A type to store symbol numbers and -1.
 -    typedef ]b4_int_type_for([b4_rhs])[ rhs_number_type;
 -    /// A `-1'-separated list of the rules' RHS.
 -    static const rhs_number_type yyrhs_[];
 -    /// For each rule, the index of the first RHS symbol in \a yyrhs_.
 -    static const ]b4_int_type_for([b4_prhs])[ yyprhs_[];
 -    /// For each rule, its source line number.
 -    static const ]b4_int_type_for([b4_rline])[ yyrline_[];
 -    /// For each scanner token number, its symbol number.
 -    static const ]b4_int_type_for([b4_toknum])[ yytoken_number_[];
 +]b4_integral_parser_table_declare([rline], [b4_rline],
 +     [YYRLINE[YYN] -- Source line where rule number YYN was defined.])[
      /// Report on the debug stream that the rule \a r is going to be reduced.
      virtual void yy_reduce_print_ (int r);
      /// Print the state stack on the debug stream.
  #endif
  
      /// Convert a scanner token number \a t to a symbol number.
 -    token_number_type yytranslate_ (int t);
 +    static inline token_number_type yytranslate_ (]b4_lex_symbol_if([token_type], [int])[ t);
 +
 +#if YYDEBUG
 +    /// \brief Display a symbol type, value and location.
 +    /// \param yyo    The output stream.
 +    /// \param yysym  The symbol.
 +    template <typename Exact>
 +    void yy_print_ (std::ostream& yyo,
 +                    const symbol_base_type<Exact>& yysym) const;
 +#endif
  
      /// \brief Reclaim the memory associated to a symbol.
 -    /// \param yymsg        Why this token is reclaimed.
 -    /// \param yytype       The symbol type.
 -    /// \param yyvaluep     Its semantic value.
 -    /// \param yylocationp  Its location.
 -    inline void yydestruct_ (const char* yymsg,
 -                           int yytype,
 -                           semantic_type* yyvaluep,
 -                           location_type* yylocationp);
 +    /// \param yymsg     Why this token is reclaimed.
 +    ///                  If null, print nothing.
 +    /// \param s         The symbol.
 +    template <typename Exact>
 +    inline void yy_destroy_ (const char* yymsg,
 +                             symbol_base_type<Exact>& yysym) const;
 +
 +  private:
 +    /// Element of the stack: a state and its attributes.
 +    struct stack_symbol_type : symbol_base_type<stack_symbol_type>
 +    {
 +      /// The parent class.
 +      typedef symbol_base_type<stack_symbol_type> super_type;
 +
 +      /// Default constructor.
 +      inline stack_symbol_type ();
 +
 +      /// Constructor.
 +      inline stack_symbol_type (]b4_args([state_type s],
 +                                         [const semantic_type& v],
 +                                         b4_locations_if([const location_type& l]))[);
 +
 +      /// The state.
 +      state_type state;
 +
 +      /// The type (corresponding to \a state).
 +      inline int type_get_ () const;
 +    };
 +
 +    /// Stack type.
 +    typedef stack<stack_symbol_type> stack_type;
 +
 +    /// The stack.
 +    stack_type yystack_;
 +
 +    /// Push a new state on the stack.
 +    /// \param m    a debug message to display
 +    ///             if null, no trace is output.
 +    /// \param s    the symbol
 +    /// \warning the contents of \a s.value is stolen.
 +    inline void yypush_ (const char* m, stack_symbol_type& s);
 +
 +    /// Push a new look ahead token on the state on the stack.
 +    /// \param m    a debug message to display
 +    ///             if null, no trace is output.
 +    /// \param s    the state
 +    /// \param sym  the symbol (for its value and location).
 +    /// \warning the contents of \a s.value is stolen.
 +    inline void yypush_ (const char* m, state_type s, symbol_type& sym);
  
      /// Pop \a n symbols the three stacks.
      inline void yypop_ (unsigned int n = 1);
  
      /* Constants.  */
 -    static const int yyeof_;
 -    /* LAST_ -- Last index in TABLE_.  */
 -    static const int yylast_;
 -    static const int yynnts_;
 -    static const int yyempty_;
 -    static const int yyfinal_;
 -    static const int yyterror_;
 -    static const int yyerrcode_;
 -    static const int yyntokens_;
 -    static const unsigned int yyuser_token_number_max_;
 -    static const token_number_type yyundef_token_;
 +    enum
 +    {
 +      yyeof_ = 0,
 +      yylast_ = ]b4_last[,           //< Last index in yytable_.
 +      yynnts_ = ]b4_nterms_number[,  //< Number of nonterminal symbols.
 +      yyempty_ = -2,
 +      yyfinal_ = ]b4_final_state_number[, //< Termination state number.
 +      yyterror_ = 1,
 +      yyerrcode_ = 256,
 +      yyntokens_ = ]b4_tokens_number[    //< Number of tokens.
 +    };
 +
  ]b4_parse_param_vars[
    };
 +
 +]b4_lex_symbol_if([b4_yytranslate_define
 +b4_public_types_define])[
  ]b4_namespace_close[
  
  ]b4_percent_define_flag_if([[global_tokens_and_yystype]],
   /* Redirection for backward compatibility.  */
  # define YYSTYPE b4_namespace_ref::b4_parser_class_name::semantic_type
  #endif
- ])
- b4_percent_code_get([[provides]])[]dnl
- [#endif /* ! defined PARSER_HEADER_H */]
+ ])[
+ ]b4_percent_code_get([[provides]])[
+ ]b4_cpp_guard_close([b4_spec_defines_file])
 -])dnl
  @output(b4_parser_file_name@)@
 -b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++],
 -             [2002-2012])
 +b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++])
  b4_percent_code_get([[top]])[]dnl
  m4_if(b4_prefix, [yy], [],
  [
  #define yylex   b4_prefix[]lex])[
  
  /* First part of user declarations.  */
 -]b4_user_pre_prologue
 +]b4_user_pre_prologue[
  
 -b4_defines_if([[
 -#include "@basename(]b4_spec_defines_file[@)"]])[
 +#include "@basename(]b4_spec_defines_file[@)"
  
  /* User implementation prologue.  */
  ]b4_user_post_prologue
@@@ -391,12 -316,11 +393,12 @@@ b4_percent_code_get[]dn
  # endif
  #endif
  
 -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
 +]b4_locations_if([dnl
 +[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
     If N is 0, then set CURRENT to the empty location which ends
     the previous symbol: RHS[0] (always defined).  */
  
 -#define YYRHSLOC(Rhs, K) ((Rhs)[K])
 +#define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
  #ifndef YYLLOC_DEFAULT
  # define YYLLOC_DEFAULT(Current, Rhs, N)                               \
   do                                                                    \
         (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end;        \
       }                                                                 \
   while (false)
 -#endif
 +#endif]])[
  
  /* Suppress unused-variable warnings by "using" E.  */
  #define YYUSE(e) ((void) (e))
  /* A pseudo ostream that takes yydebug_ into account.  */
  # define YYCDEBUG if (yydebug_) (*yycdebug_)
  
 -# define YY_SYMBOL_PRINT(Title, Type, Value, Location)        \
 -do {                                                  \
 -  if (yydebug_)                                               \
 -    {                                                 \
 -      *yycdebug_ << Title << ' ';                     \
 -      yy_symbol_print_ ((Type), (Value), (Location)); \
 -      *yycdebug_ << std::endl;                                \
 -    }                                                 \
 -} while (false)
 -
 -# define YY_REDUCE_PRINT(Rule)                \
 -do {                                  \
 -  if (yydebug_)                               \
 -    yy_reduce_print_ (Rule);          \
 -} while (false)
 -
 -# define YY_STACK_PRINT()             \
 -do {                                  \
 -  if (yydebug_)                               \
 -    yystack_print_ ();                        \
 -} while (false)
 +# define YY_SYMBOL_PRINT(Title, Symbol)         \
 +  do {                                          \
 +    if (yydebug_)                               \
 +    {                                           \
 +      *yycdebug_ << Title << ' ';               \
 +      yy_print_ (*yycdebug_, Symbol);           \
 +      *yycdebug_ << std::endl;                  \
 +    }                                           \
 +  } while (false)
 +
 +# define YY_REDUCE_PRINT(Rule)          \
 +  do {                                  \
 +    if (yydebug_)                       \
 +      yy_reduce_print_ (Rule);          \
 +  } while (false)
 +
 +# define YY_STACK_PRINT()               \
 +  do {                                  \
 +    if (yydebug_)                       \
 +      yystack_print_ ();                \
 +  } while (false)
  
  #else /* !YYDEBUG */
  
  # define YYCDEBUG if (false) std::cerr
 -# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
 -# define YY_REDUCE_PRINT(Rule)
 -# define YY_STACK_PRINT()
 +# define YY_SYMBOL_PRINT(Title, Symbol)  YYUSE(Symbol)
 +# define YY_REDUCE_PRINT(Rule)           static_cast<void>(0)
 +# define YY_STACK_PRINT()                static_cast<void>(0)
  
  #endif /* !YYDEBUG */
  
 -#define yyerrok               (yyerrstatus_ = 0)
 -#define yyclearin     (yychar = yyempty_)
 +#define yyerrok         (yyerrstatus_ = 0)
 +#define yyclearin       (yyempty = true)
  
 -#define YYACCEPT      goto yyacceptlab
 -#define YYABORT               goto yyabortlab
 -#define YYERROR               goto yyerrorlab
 +#define YYACCEPT        goto yyacceptlab
 +#define YYABORT         goto yyabortlab
 +#define YYERROR         goto yyerrorlab
  #define YYRECOVERING()  (!!yyerrstatus_)
  
  ]b4_namespace_open[]b4_error_verbose_if([[
    {
    }
  
 -#if YYDEBUG
 -  /*--------------------------------.
 -  | Print this symbol on YYOUTPUT.  |
 -  `--------------------------------*/
  
 -  inline void
 -  ]b4_parser_class_name[::yy_symbol_value_print_ (int yytype,
 -                         const semantic_type* yyvaluep, const location_type* yylocationp)
 +  /*---------------.
 +  | Symbol types.  |
 +  `---------------*/
 +
 +]b4_lex_symbol_if([], [b4_public_types_define])[
 +
 +  // stack_symbol_type.
 +  ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type ()
 +    : super_type ()
 +    , state ()
 +  {
 +  }
 +
 +  ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (]b4_args(
 +                 [state_type s],
 +                 [const semantic_type& v],
 +                 b4_locations_if([const location_type& l]))[)
 +    : super_type (v]b4_locations_if([, l])[)
 +    , state (s)
 +  {
 +  }
 +
 +  int
 +  ]b4_parser_class_name[::stack_symbol_type::type_get_ () const
 +  {
 +    return yystos_[state];
 +  }
 +
 +
 +  template <typename Exact>
 +  void
 +  ]b4_parser_class_name[::yy_destroy_ (const char* yymsg,
 +                                       symbol_base_type<Exact>& yysym) const
 +  {
 +    if (yymsg)
 +      YY_SYMBOL_PRINT (yymsg, yysym);
 +
 +    // User destructor.
 +    int yytype = yysym.type_get ();
 +    switch (yytype)
 +      {
 +]b4_symbol_foreach([b4_symbol_destructor])dnl
 +[       default:
 +          break;
 +      }]b4_variant_if([
 +
 +    // Type destructor.
 +  b4_symbol_variant([[yytype]], [[yysym.value]], [[template destroy]])])[
 +  }
 +
 +#if YYDEBUG
 +  template <typename Exact>
 +  void
 +  ]b4_parser_class_name[::yy_print_ (std::ostream& yyo,
 +                                     const symbol_base_type<Exact>& yysym) const
    {
 -    YYUSE (yylocationp);
 -    YYUSE (yyvaluep);
 -    std::ostream& yyo = debug_stream ();
      std::ostream& yyoutput = yyo;
      YYUSE (yyoutput);
 +    int yytype = yysym.type_get ();
 +    yyo << (yytype < yyntokens_ ? "token" : "nterm")
 +        << ' ' << yytname_[yytype] << " ("]b4_locations_if([
 +        << yysym.location << ": "])[;
      switch (yytype)
        {
 -  ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
 +]b4_symbol_foreach([b4_symbol_printer])dnl
  [       default:
 -        break;
 +          break;
        }
 +    yyo << ')';
    }
 -
 +#endif
  
    void
 -  ]b4_parser_class_name[::yy_symbol_print_ (int yytype,
 -                         const semantic_type* yyvaluep, const location_type* yylocationp)
 +  ]b4_parser_class_name[::yypush_ (const char* m, state_type s,
 +                                   symbol_type& sym)
    {
 -    *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm")
 -             << ' ' << yytname_[yytype] << " ("
 -             << *yylocationp << ": ";
 -    yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
 -    *yycdebug_ << ')';
 +    if (m)
 +      YY_SYMBOL_PRINT (m, sym);
 +]b4_variant_if(
 +[[    yystack_.push (stack_symbol_type (]b4_args(
 +                    [s],
 +                    [semantic_type()],
 +                    b4_locations_if([sym.location]))[));
 +    ]b4_symbol_variant([[yystos_[s]]], [[yystack_[0].value]],
 +                       [build], [sym.value])],
 +[[    yystack_.push (stack_symbol_type (]b4_args(
 +                      [s],
 +                      [sym.value],
 +                      b4_locations_if([sym.location]))[));]])[
    }
 -#endif
  
    void
 -  ]b4_parser_class_name[::yydestruct_ (const char* yymsg,
 -                         int yytype, semantic_type* yyvaluep, location_type* yylocationp)
 +  ]b4_parser_class_name[::yypush_ (const char* m, stack_symbol_type& s)
    {
 -    YYUSE (yylocationp);
 -    YYUSE (yymsg);
 -    YYUSE (yyvaluep);
 -
 -    YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
 -
 -    switch (yytype)
 -      {
 -  ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
 -      default:
 -        break;
 -      }
 +    if (m)
 +      YY_SYMBOL_PRINT (m, s);
 +]b4_variant_if(
 +[[    yystack_.push (stack_symbol_type (]b4_args(
 +                       [s.state],
 +                       [semantic_type()],
 +                       b4_locations_if([s.location]))[));
 +    ]b4_symbol_variant([[yystos_[s.state]]], [[yystack_[0].value]],
 +                       [build], [s.value])],
 +[    yystack_.push (s);])[
    }
  
    void
    ]b4_parser_class_name[::yypop_ (unsigned int n)
    {
 -    yystate_stack_.pop (n);
 -    yysemantic_stack_.pop (n);
 -    yylocation_stack_.pop (n);
 +    yystack_.pop (n);
    }
  
  #if YYDEBUG
    }
  #endif
  
 +  inline ]b4_parser_class_name[::state_type
 +  ]b4_parser_class_name[::yy_lr_goto_state_ (state_type yystate, int yylhs)
 +  {
 +    int yyr = yypgoto_[yylhs - yyntokens_] + yystate;
 +    if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
 +      return yytable_[yyr];
 +    else
 +      return yydefgoto_[yylhs - yyntokens_];
 +  }
 +
    inline bool
    ]b4_parser_class_name[::yy_pact_value_is_default_ (int yyvalue)
    {
    int
    ]b4_parser_class_name[::parse ()
    {
 -    /// Lookahead and lookahead in internal form.
 -    int yychar = yyempty_;
 -    int yytoken = 0;
 +    /// Whether yyla contains a lookahead.
 +    bool yyempty = true;
  
      /* State.  */
      int yyn;
      int yylen = 0;
 -    int yystate = 0;
  
      /* Error handling.  */
      int yynerrs_ = 0;
      int yyerrstatus_ = 0;
  
 -    /// Semantic value of the lookahead.
 -    semantic_type yylval;
 -    /// Location of the lookahead.
 -    location_type yylloc;
 +    /// The lookahead symbol.
 +    symbol_type yyla;]b4_locations_if([[
 +
      /// The locations where the error started and ended.
 -    location_type yyerror_range[3];
 +    stack_symbol_type yyerror_range[3];]])[
  
 -    /// $$.
 -    semantic_type yyval;
 -    /// @@$.
 -    location_type yyloc;
 +    /// $$ and @@$.
 +    stack_symbol_type yylhs;
  
 +    /// The return value of parse().
      int yyresult;
  
      YYCDEBUG << "Starting parse" << std::endl;
  
  ]m4_ifdef([b4_initial_action], [
 -m4_pushdef([b4_at_dollar],     [yylloc])dnl
 -m4_pushdef([b4_dollar_dollar], [yylval])dnl
 +m4_pushdef([b4_at_dollar],     [yyla.location])dnl
 +m4_pushdef([b4_dollar_dollar], [yyla.value])dnl
      /* User initialization code.  */
      b4_user_initial_action
  m4_popdef([b4_dollar_dollar])dnl
  m4_popdef([b4_at_dollar])])dnl
  
 -  [  /* Initialize the stacks.  The initial state will be pushed in
 +  [  /* Initialize the stack.  The initial state will be set in
         yynewstate, since the latter expects the semantical and the
         location values to have been already stored, initialize these
         stacks with a primary value.  */
 -    yystate_stack_ = state_stack_type (0);
 -    yysemantic_stack_ = semantic_stack_type (0);
 -    yylocation_stack_ = location_stack_type (0);
 -    yysemantic_stack_.push (yylval);
 -    yylocation_stack_.push (yylloc);
 +    yystack_ = stack_type (0);
 +    yypush_ (YY_NULL, 0, yyla);
  
 -    /* New state.  */
 +    // A new symbol was pushed on the stack.
    yynewstate:
 -    yystate_stack_.push (yystate);
 -    YYCDEBUG << "Entering state " << yystate << std::endl;
 +    YYCDEBUG << "Entering state " << yystack_[0].state << std::endl;
  
      /* Accept?  */
 -    if (yystate == yyfinal_)
 +    if (yystack_[0].state == yyfinal_)
        goto yyacceptlab;
  
      goto yybackup;
    yybackup:
  
      /* Try to take a decision without lookahead.  */
 -    yyn = yypact_[yystate];
 +    yyn = yypact_[yystack_[0].state];
      if (yy_pact_value_is_default_ (yyn))
        goto yydefault;
  
      /* Read a lookahead token.  */
 -    if (yychar == yyempty_)
 -      {
 -      YYCDEBUG << "Reading a token: ";
 -      yychar = ]b4_c_function_call([yylex], [int],
 -                                   [[YYSTYPE*], [&yylval]][]dnl
 -b4_locations_if([, [[location*], [&yylloc]]])dnl
 -m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
 -      }
 -
 -
 -    /* Convert token to internal form.  */
 -    if (yychar <= yyeof_)
 -      {
 -      yychar = yytoken = yyeof_;
 -      YYCDEBUG << "Now at end of input." << std::endl;
 -      }
 -    else
 +    if (yyempty)
        {
 -      yytoken = yytranslate_ (yychar);
 -      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
 +        YYCDEBUG << "Reading a token: ";
 +        try
 +        {
 +]b4_lex_symbol_if(
 +[          yyla = b4_c_function_call([yylex], [symbol_type],
 +                                     m4_ifdef([b4_lex_param], b4_lex_param));],
 +[          yyla.type = yytranslate_ (b4_c_function_call([yylex], [int],
 +                                     [[YYSTYPE*], [&yyla.value]][]dnl
 +b4_locations_if([, [[location*], [&yyla.location]]])dnl
 +m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
 +        }
 +        catch (const syntax_error& yyexc)
 +        {
 +          error (yyexc);
 +          goto yyerrlab1;
 +        }
 +        yyempty = false;
        }
 +    YY_SYMBOL_PRINT ("Next token is", yyla);
  
 -    /* If the proper action on seeing token YYTOKEN is to reduce or to
 -       detect an error, take that action.  */
 -    yyn += yytoken;
 -    if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
 +    /* If the proper action on seeing token YYLA.TYPE is to reduce or
 +       to detect an error, take that action.  */
 +    yyn += yyla.type;
 +    if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.type)
        goto yydefault;
  
      /* Reduce or error.  */
      yyn = yytable_[yyn];
      if (yyn <= 0)
        {
 -      if (yy_table_value_is_error_ (yyn))
 -        goto yyerrlab;
 -      yyn = -yyn;
 -      goto yyreduce;
 +        if (yy_table_value_is_error_ (yyn))
 +          goto yyerrlab;
 +        yyn = -yyn;
 +        goto yyreduce;
        }
  
 -    /* Shift the lookahead token.  */
 -    YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
 -
      /* Discard the token being shifted.  */
 -    yychar = yyempty_;
 -
 -    yysemantic_stack_.push (yylval);
 -    yylocation_stack_.push (yylloc);
 +    yyempty = true;
  
      /* Count tokens shifted since error; after three, turn off error
         status.  */
      if (yyerrstatus_)
        --yyerrstatus_;
  
 -    yystate = yyn;
 +    /* Shift the lookahead token.  */
 +    yypush_ ("Shifting", yyn, yyla);
      goto yynewstate;
  
    /*-----------------------------------------------------------.
    | yydefault -- do the default action for the current state.  |
    `-----------------------------------------------------------*/
    yydefault:
 -    yyn = yydefact_[yystate];
 +    yyn = yydefact_[yystack_[0].state];
      if (yyn == 0)
        goto yyerrlab;
      goto yyreduce;
    `-----------------------------*/
    yyreduce:
      yylen = yyr2_[yyn];
 +    yylhs.state = yy_lr_goto_state_(yystack_[yylen].state, yyr1_[yyn]);]b4_variant_if([
 +    /* Variants are always initialized to an empty instance of the
 +       correct type. The default $$=$1 action is NOT applied when using
 +       variants.  */
 +    b4_symbol_variant([[yyr1_@{yyn@}]], [yylhs.value], [build])],[
      /* If YYLEN is nonzero, implement the default value of the action:
         `$$ = $1'.  Otherwise, use the top of the stack.
  
 -       Otherwise, the following line sets YYVAL to garbage.
 +       Otherwise, the following line sets YYLHS.VALUE to garbage.
         This behavior is undocumented and Bison
         users should not rely upon it.  */
      if (yylen)
 -      yyval = yysemantic_stack_[yylen - 1];
 +      yylhs.value = yystack_@{yylen - 1@}.value;
      else
 -      yyval = yysemantic_stack_[0];
 -
 +      yylhs.value = yystack_@{0@}.value;])[
 +]b4_locations_if([dnl
 +[
 +    // Compute the default @@$.
      {
 -      slice<location_type, location_stack_type> slice (yylocation_stack_, yylen);
 -      YYLLOC_DEFAULT (yyloc, slice, yylen);
 -    }
 +      slice<stack_symbol_type, stack_type> slice (yystack_, yylen);
 +      YYLLOC_DEFAULT (yylhs.location, slice, yylen);
 +    }]])[
 +
 +    // Perform the reduction.
      YY_REDUCE_PRINT (yyn);
 -    switch (yyn)
 +    try
 +    {
 +      switch (yyn)
        {
 -      ]b4_user_actions[
 -      default:
 +]b4_user_actions[
 +        default:
            break;
        }
 -    /* User semantic actions sometimes alter yychar, and that requires
 -       that yytoken be updated with the new translation.  We take the
 -       approach of translating immediately before every use of yytoken.
 -       One alternative is translating here after every semantic action,
 -       but that translation would be missed if the semantic action
 -       invokes YYABORT, YYACCEPT, or YYERROR immediately after altering
 -       yychar.  In the case of YYABORT or YYACCEPT, an incorrect
 -       destructor might then be invoked immediately.  In the case of
 -       YYERROR, subsequent parser actions might lead to an incorrect
 -       destructor call or verbose syntax error message before the
 -       lookahead is translated.  */
 -    YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
 +    }
 +    catch (const syntax_error& yyexc)
 +    {
 +      error (yyexc);
 +      YYERROR;
 +    }
 +    YY_SYMBOL_PRINT ("-> $$ =", yylhs);
 +]b4_variant_if([[
 +    // Destroy the rhs symbols.
 +    for (int i = 0; i < yylen; ++i)
 +      // Destroy a variant which value may have been swapped with
 +      // yylhs.value (for instance if the action was "std::swap($$,
 +      // $1)").  The value of yylhs.value (hence possibly one of these
 +      // rhs symbols) depends on the default contruction for this
 +      // type.  In the case of pointers for instance, no
 +      // initialization is done, so the value is junk.  Therefore do
 +      // not try to report the value of symbols about to be destroyed
 +      // in the debug trace, it's possibly junk.  Hence yymsg = 0.
 +      // Besides, that keeps exactly the same traces as with the other
 +      // Bison skeletons.
 +      yy_destroy_ (YY_NULL, yystack_[i]);]])[
  
      yypop_ (yylen);
      yylen = 0;
      YY_STACK_PRINT ();
  
 -    yysemantic_stack_.push (yyval);
 -    yylocation_stack_.push (yyloc);
 -
      /* Shift the result of the reduction.  */
 -    yyn = yyr1_[yyn];
 -    yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0];
 -    if (0 <= yystate && yystate <= yylast_
 -      && yycheck_[yystate] == yystate_stack_[0])
 -      yystate = yytable_[yystate];
 -    else
 -      yystate = yydefgoto_[yyn - yyntokens_];
 +    yypush_ (YY_NULL, yylhs);
      goto yynewstate;
  
 -  /*------------------------------------.
 -  | yyerrlab -- here on detecting error |
 -  `------------------------------------*/
 +  /*--------------------------------------.
 +  | yyerrlab -- here on detecting error |
 +  `--------------------------------------*/
    yyerrlab:
 -    /* Make sure we have latest lookahead translation.  See comments at
 -       user semantic actions for why this is necessary.  */
 -    yytoken = yytranslate_ (yychar);
 -
      /* If not already recovering from an error, report this error.  */
      if (!yyerrstatus_)
        {
 -      ++yynerrs_;
 -      if (yychar == yyempty_)
 -        yytoken = yyempty_;
 -      error (yylloc, yysyntax_error_ (yystate, yytoken));
 +        ++yynerrs_;
 +        error (]b4_args(b4_locations_if([yyla.location]),
 +                        [[yysyntax_error_ (yystack_[0].state,
 +                                           yyempty ? yyempty_ : yyla.type)]])[);
        }
  
 -    yyerror_range[1] = yylloc;
 +]b4_locations_if([[
 +    yyerror_range[1].location = yyla.location;]])[
      if (yyerrstatus_ == 3)
        {
 -      /* If just tried and failed to reuse lookahead token after an
 -       error, discard it.  */
 -
 -      if (yychar <= yyeof_)
 -        {
 -        /* Return failure if at end of input.  */
 -        if (yychar == yyeof_)
 -          YYABORT;
 -        }
 -      else
 -        {
 -          yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc);
 -          yychar = yyempty_;
 -        }
 +        /* If just tried and failed to reuse lookahead token after an
 +           error, discard it.  */
 +
 +        /* Return failure if at end of input.  */
 +        if (yyla.type == yyeof_)
 +          YYABORT;
 +        else if (!yyempty)
 +          {
 +            yy_destroy_ ("Error: discarding", yyla);
 +            yyempty = true;
 +          }
        }
  
      /* Else will try to reuse lookahead token after shifting the error
         YYERROR and the label yyerrorlab therefore never appears in user
         code.  */
      if (false)
 -      goto yyerrorlab;
 -
 -    yyerror_range[1] = yylocation_stack_[yylen - 1];
 +      goto yyerrorlab;]b4_locations_if([[
 +    yyerror_range[1].location = yystack_[yylen - 1].location;]])b4_variant_if([[
 +    /* $$ was initialized before running the user action.  */
 +    yy_destroy_ ("Error: discarding", yylhs);]])[
      /* Do not reclaim the symbols of the rule which action triggered
         this YYERROR.  */
      yypop_ (yylen);
      yylen = 0;
 -    yystate = yystate_stack_[0];
      goto yyerrlab1;
  
    /*-------------------------------------------------------------.
    | yyerrlab1 -- common code for both syntax error and YYERROR.  |
    `-------------------------------------------------------------*/
    yyerrlab1:
 -    yyerrstatus_ = 3; /* Each real token shifted decrements this.  */
 -
 -    for (;;)
 -      {
 -      yyn = yypact_[yystate];
 -      if (!yy_pact_value_is_default_ (yyn))
 -      {
 -        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 (yystate_stack_.height () == 1)
 -      YYABORT;
 -
 -      yyerror_range[1] = yylocation_stack_[0];
 -      yydestruct_ ("Error: popping",
 -                   yystos_[yystate],
 -                   &yysemantic_stack_[0], &yylocation_stack_[0]);
 -      yypop_ ();
 -      yystate = yystate_stack_[0];
 -      YY_STACK_PRINT ();
 -      }
 -
 -    yyerror_range[2] = yylloc;
 -    // Using YYLLOC is tempting, but would change the location of
 -    // the lookahead.  YYLOC is available though.
 -    YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
 -    yysemantic_stack_.push (yylval);
 -    yylocation_stack_.push (yyloc);
 +    yyerrstatus_ = 3;   /* Each real token shifted decrements this.  */
 +    {
 +      stack_symbol_type error_token;
 +      for (;;)
 +        {
 +          yyn = yypact_[yystack_[0].state];
 +          if (!yy_pact_value_is_default_ (yyn))
 +            {
 +              yyn += yyterror_;
 +              if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
 +                {
 +                  yyn = yytable_[yyn];
 +                  if (0 < yyn)
 +                    break;
 +                }
 +            }
  
 -    /* Shift the error token.  */
 -    YY_SYMBOL_PRINT ("Shifting", yystos_[yyn],
 -                   &yysemantic_stack_[0], &yylocation_stack_[0]);
 +          // Pop the current state because it cannot handle the error token.
 +          if (yystack_.size () == 1)
 +            YYABORT;
 +]b4_locations_if([[
 +          yyerror_range[1].location = yystack_[0].location;]])[
 +          yy_destroy_ ("Error: popping", yystack_[0]);
 +          yypop_ ();
 +          YY_STACK_PRINT ();
 +        }
 +]b4_locations_if([[
 +      yyerror_range[2].location = yyla.location;
 +      YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);]])[
  
 -    yystate = yyn;
 +      /* Shift the error token.  */
 +      error_token.state = yyn;
 +      yypush_ ("Shifting", error_token);
 +    }
      goto yynewstate;
  
      /* Accept.  */
      goto yyreturn;
  
    yyreturn:
 -    if (yychar != yyempty_)
 -      {
 -        /* Make sure we have latest lookahead translation.  See comments
 -           at user semantic actions for why this is necessary.  */
 -        yytoken = yytranslate_ (yychar);
 -        yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval,
 -                     &yylloc);
 -      }
 +    if (!yyempty)
 +      yy_destroy_ ("Cleanup: discarding lookahead", yyla);
  
      /* Do not reclaim the symbols of the rule which action triggered
         this YYABORT or YYACCEPT.  */
      yypop_ (yylen);
 -    while (yystate_stack_.height () != 1)
 +    while (yystack_.size () != 1)
        {
 -      yydestruct_ ("Cleanup: popping",
 -                 yystos_[yystate_stack_[0]],
 -                 &yysemantic_stack_[0],
 -                 &yylocation_stack_[0]);
 -      yypop_ ();
 +        yy_destroy_ ("Cleanup: popping", yystack_[0]);
 +        yypop_ ();
        }
  
      return yyresult;
    }
  
 +  void
 +  ]b4_parser_class_name[::error (const syntax_error& yyexc)
 +  {
 +    error (]b4_args(b4_locations_if([yyexc.location]),
 +                    [[yyexc.what()]])[);
 +  }
 +
    // Generate an error message.
    std::string
    ]b4_parser_class_name[::yysyntax_error_ (]dnl
 -b4_error_verbose_if([int yystate, int yytoken],
 +b4_error_verbose_if([state_type yystate, int yytoken],
                      [int, int])[)
    {]b4_error_verbose_if([[
      std::string yyres;
           a consistent state with a default action.  There might have
           been a previous inconsistent state, consistent state with a
           non-default action, or user semantic action that manipulated
 -         yychar.
 +         yyla.  (However, yyla is currently not documented for users.)
         - Of course, the expected token list depends on states to have
           correct lookahead information, and it depends on the parser not
           to perform extra reductions after fetching a lookahead from the
    }
  
  
 -  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
 -     STATE-NUM.  */
    const ]b4_int_type(b4_pact_ninf, b4_pact_ninf) b4_parser_class_name::yypact_ninf_ = b4_pact_ninf[;
 -  const ]b4_int_type_for([b4_pact])[
 -  ]b4_parser_class_name[::yypact_[] =
 -  {
 -    ]b4_pact[
 -  };
 -
 -  /* 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.  */
 -  const ]b4_int_type_for([b4_defact])[
 -  ]b4_parser_class_name[::yydefact_[] =
 -  {
 -    ]b4_defact[
 -  };
 -
 -  /* YYPGOTO[NTERM-NUM].  */
 -  const ]b4_int_type_for([b4_pgoto])[
 -  ]b4_parser_class_name[::yypgoto_[] =
 -  {
 -    ]b4_pgoto[
 -  };
 -
 -  /* YYDEFGOTO[NTERM-NUM].  */
 -  const ]b4_int_type_for([b4_defgoto])[
 -  ]b4_parser_class_name[::yydefgoto_[] =
 -  {
 -    ]b4_defgoto[
 -  };
  
 -  /* 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.  */
    const ]b4_int_type(b4_table_ninf, b4_table_ninf) b4_parser_class_name::yytable_ninf_ = b4_table_ninf[;
 -  const ]b4_int_type_for([b4_table])[
 -  ]b4_parser_class_name[::yytable_[] =
 -  {
 -    ]b4_table[
 -  };
 -
 -  /* YYCHECK.  */
 -  const ]b4_int_type_for([b4_check])[
 -  ]b4_parser_class_name[::yycheck_[] =
 -  {
 -    ]b4_check[
 -  };
  
 -  /* STOS_[STATE-NUM] -- The (internal number of the) accessing
 -     symbol of state STATE-NUM.  */
 -  const ]b4_int_type_for([b4_stos])[
 -  ]b4_parser_class_name[::yystos_[] =
 -  {
 -    ]b4_stos[
 -  };
 -
 -#if YYDEBUG
 -  /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
 -     to YYLEX-NUM.  */
 -  const ]b4_int_type_for([b4_toknum])[
 -  ]b4_parser_class_name[::yytoken_number_[] =
 -  {
 -    ]b4_toknum[
 -  };
 -#endif
 -
 -  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 -  const ]b4_int_type_for([b4_r1])[
 -  ]b4_parser_class_name[::yyr1_[] =
 -  {
 -    ]b4_r1[
 -  };
 -
 -  /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
 -  const ]b4_int_type_for([b4_r2])[
 -  ]b4_parser_class_name[::yyr2_[] =
 -  {
 -    ]b4_r2[
 -  };
 +]b4_parser_tables_define[
  
  #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
    /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
    const char*
    const ]b4_parser_class_name[::yytname_[] =
    {
 -    ]b4_tname[
 +  ]b4_tname[
    };
  #endif
  
  #if YYDEBUG
 -  /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
 -  const ]b4_parser_class_name[::rhs_number_type
 -  ]b4_parser_class_name[::yyrhs_[] =
 -  {
 -    ]b4_rhs[
 -  };
 -
 -  /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
 -     YYRHS.  */
 -  const ]b4_int_type_for([b4_prhs])[
 -  ]b4_parser_class_name[::yyprhs_[] =
 -  {
 -    ]b4_prhs[
 -  };
 -
 -  /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
 -  const ]b4_int_type_for([b4_rline])[
 -  ]b4_parser_class_name[::yyrline_[] =
 -  {
 -    ]b4_rline[
 -  };
 +]b4_integral_parser_table_define([rline], [b4_rline])[
  
    // Print the state stack on the debug stream.
    void
    ]b4_parser_class_name[::yystack_print_ ()
    {
      *yycdebug_ << "Stack now";
 -    for (state_stack_type::const_iterator i = yystate_stack_.begin ();
 -       i != yystate_stack_.end (); ++i)
 -      *yycdebug_ << ' ' << *i;
 +    for (stack_type::const_iterator
 +           i = yystack_.begin (),
 +           i_end = yystack_.end ();
 +         i != i_end; ++i)
 +      *yycdebug_ << ' ' << i->state;
      *yycdebug_ << std::endl;
    }
  
      int yynrhs = yyr2_[yyrule];
      /* Print the symbols being reduced, and their result.  */
      *yycdebug_ << "Reducing stack by rule " << yyrule - 1
 -             << " (line " << yylno << "):" << std::endl;
 +               << " (line " << yylno << "):" << std::endl;
      /* The symbols being reduced.  */
      for (int yyi = 0; yyi < yynrhs; yyi++)
        YY_SYMBOL_PRINT ("   $" << yyi + 1 << " =",
 -                     yyrhs_[yyprhs_[yyrule] + yyi],
 -                     &]b4_rhs_value(yynrhs, yyi + 1)[,
 -                     &]b4_rhs_location(yynrhs, yyi + 1)[);
 +                       ]b4_rhs_data(yynrhs, yyi + 1)[);
    }
  #endif // YYDEBUG
  
 -  /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
 -  ]b4_parser_class_name[::token_number_type
 -  ]b4_parser_class_name[::yytranslate_ (int t)
 -  {
 -    static
 -    const token_number_type
 -    translate_table[] =
 -    {
 -      ]b4_translate[
 -    };
 -    if ((unsigned int) t <= yyuser_token_number_max_)
 -      return translate_table[t];
 -    else
 -      return yyundef_token_;
 -  }
 -
 -  const int ]b4_parser_class_name[::yyeof_ = 0;
 -  const int ]b4_parser_class_name[::yylast_ = ]b4_last[;
 -  const int ]b4_parser_class_name[::yynnts_ = ]b4_nterms_number[;
 -  const int ]b4_parser_class_name[::yyempty_ = -2;
 -  const int ]b4_parser_class_name[::yyfinal_ = ]b4_final_state_number[;
 -  const int ]b4_parser_class_name[::yyterror_ = 1;
 -  const int ]b4_parser_class_name[::yyerrcode_ = 256;
 -  const int ]b4_parser_class_name[::yyntokens_ = ]b4_tokens_number[;
 -
 -  const unsigned int ]b4_parser_class_name[::yyuser_token_number_max_ = ]b4_user_token_number_max[;
 -  const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[;
 -
 +]b4_lex_symbol_if([], [b4_yytranslate_define])[
  ]b4_namespace_close[
 -]b4_epilogue
 +]b4_epilogue[]dnl
  m4_divert_pop(0)
 +m4_popdef([b4_copyright_years])dnl
diff --combined data/location.cc
index e750779c0fc8de053cf6c4e9ea3dd51d3ee664ba,f45f634e20b0dad26e1ea75c9912ec5732aa1855..976fc34b235fe9cec3f378ff9af61bc75d84145b
@@@ -1,6 -1,6 +1,6 @@@
  # C++ skeleton for Bison
  
 -# Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc.
 +# Copyright (C) 2002-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
  # You should have received a copy of the GNU General Public License
  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
 +m4_pushdef([b4_copyright_years],
 +           [2002-2012])
 +
  # We do want M4 expansion after # for CPP macros.
  m4_changecom()
  m4_divert_push(0)dnl
  @output(b4_dir_prefix[]position.hh@)@
 -b4_copyright([Positions for Bison parsers in C++],
 -             [2002-2007, 2009-2012])[
 +b4_copyright([Positions for Bison parsers in C++])[
  
  /**
-  ** \file position.hh
+  ** \file ]b4_dir_prefix[position.hh
   ** Define the ]b4_namespace_ref[::position class.
   */
  
- #ifndef BISON_POSITION_HH
- # define BISON_POSITION_HH
+ ]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[
  
  # include <iostream>
  # include <string>
    }
  
  ]b4_namespace_close[
- #endif // not BISON_POSITION_HH]
+ ]b4_cpp_guard_close([b4_dir_prefix[]position.hh])
  @output(b4_dir_prefix[]location.hh@)@
 -b4_copyright([Locations for Bison parsers in C++],
 -             [2002-2007, 2009-2012])[
 +b4_copyright([Locations for Bison parsers in C++])[
  
  /**
-  ** \file location.hh
+  ** \file ]b4_dir_prefix[location.hh
   ** Define the ]b4_namespace_ref[::location class.
   */
  
- #ifndef BISON_LOCATION_HH
- # define BISON_LOCATION_HH
+ ]b4_cpp_guard_open([b4_dir_prefix[]location.hh])[
  
  # include <iostream>
  # include <string>
      position last = loc.end - 1;
      ostr << loc.begin;
      if (last.filename
 -      && (!loc.begin.filename
 -          || *loc.begin.filename != *last.filename))
 +        && (!loc.begin.filename
 +            || *loc.begin.filename != *last.filename))
        ostr << '-' << last;
      else if (loc.begin.line != last.line)
        ostr << '-' << last.line  << '.' << last.column;
  
  ]b4_namespace_close[
  
- #endif // not BISON_LOCATION_HH]
+ ]b4_cpp_guard_close([b4_dir_prefix[]location.hh])
  m4_divert_pop(0)
 +m4_popdef([b4_copyright_years])dnl
  m4_changecom([#])
diff --combined data/stack.hh
index dcd0832b1cbbf572dbd430c3c01d6debafdf89c3,ddedc79bef7d25e1415f0f4345043fd8a6b98901..cea7b41a80100f3b2486c0deec1a0af19dab8ce6
@@@ -22,12 -22,17 +22,16 @@@ m4_pushdef([b4_copyright_years]
  m4_changecom()
  m4_divert_push(0)dnl
  @output(b4_dir_prefix[]stack.hh@)@
 -b4_copyright([Stack handling for Bison parsers in C++],
 -             [2002-2012])[
 +b4_copyright([Stack handling for Bison parsers in C++])[
  
- #ifndef BISON_STACK_HH
- # define BISON_STACK_HH
+ /**
+  ** \file ]b4_dir_prefix[stack.hh
+  ** Define the ]b4_namespace_ref[::stack class.
+  */
  
- #include <deque>
+ ]b4_cpp_guard_open([b4_dir_prefix[]stack.hh])[
+ # include <deque>
  
  ]b4_namespace_open[
    template <class T, class S = std::deque<T> >
      typedef typename S::reverse_iterator iterator;
      typedef typename S::const_reverse_iterator const_iterator;
  
 -    stack () : seq_ ()
 +    stack ()
 +      : seq_ ()
      {
      }
  
 -    stack (unsigned int n) : seq_ (n)
 +    stack (unsigned int n)
 +      : seq_ (n)
      {
      }
  
      }
  
      inline
 -    unsigned int
 -    height () const
 +    typename S::size_type
 +    size () const
      {
        return seq_.size ();
      }
  
 -    inline const_iterator begin () const { return seq_.rbegin (); }
 -    inline const_iterator end () const { return seq_.rend (); }
 +    inline
 +    const_iterator
 +    begin () const
 +    {
 +      return seq_.rbegin ();
 +    }
 +
 +    inline
 +    const_iterator
 +    end () const
 +    {
 +      return seq_.rend ();
 +    }
  
    private:
 +    /// The wrapped container.
      S seq_;
    };
  
    {
    public:
      slice (const S& stack, unsigned int range)
-       : stack_ (stack),
-         range_ (range)
+       : stack_ (stack)
+       , range_ (range)
      {
      }
  
    };
  ]b4_namespace_close[
  
- #endif // not BISON_STACK_HH[]dnl
- ]
+ ]b4_cpp_guard_close([b4_dir_prefix[]stack.hh])
  m4_divert_pop(0)
  m4_popdef([b4_copyright_years])dnl
  m4_changecom([#])
diff --combined doc/bison.texinfo
index 7740c775612477048396207851c5756638013672,97b327340b239ff7b62bc13f00e2b95e67a96423..3f24b9ac7f70d71f96b9273b1141e5fb6613225d
@@@ -135,8 -135,7 +135,8 @@@ Writing GLR Parser
  
  * Simple GLR Parsers::     Using GLR parsers on unambiguous grammars.
  * Merging GLR Parses::     Using GLR parsers to resolve ambiguities.
 -* GLR Semantic Actions::   Deferred semantic actions have special concerns.
 +* GLR Semantic Actions::   Considerations for semantic values and deferred actions.
 +* Semantic Predicates::    Controlling a parse with arbitrary computations.
  * Compiler Requirements::  GLR parsers require a modern C compiler.
  
  Examples
@@@ -163,9 -162,9 +163,9 @@@ Reverse Polish Notation Calculato
  
  Grammar Rules for @code{rpcalc}
  
 -* Rpcalc Input::
 -* Rpcalc Line::
 -* Rpcalc Expr::
 +* Rpcalc Input::            Explanation of the @code{input} nonterminal
 +* Rpcalc Line::             Explanation of the @code{line} nonterminal
 +* Rpcalc Expr::             Explanation of the @code{expr} nonterminal
  
  Location Tracking Calculator: @code{ltcalc}
  
@@@ -178,8 -177,6 +178,8 @@@ Multi-Function Calculator: @code{mfcalc
  * Mfcalc Declarations::    Bison declarations for multi-function calculator.
  * Mfcalc Rules::           Grammar rules for the calculator.
  * Mfcalc Symbol Table::    Symbol table management subroutines.
 +* Mfcalc Lexer::           The lexical analyzer.
 +* Mfcalc Main::            The controlling function.
  
  Bison Grammar Files
  
@@@ -276,8 -273,7 +276,8 @@@ The Bison Parser Algorith
  Operator Precedence
  
  * Why Precedence::    An example showing why precedence is needed.
 -* Using Precedence::  How to specify precedence in Bison grammars.
 +* Using Precedence::  How to specify precedence and associativity.
 +* Precedence Only::   How to specify precedence only.
  * Precedence Examples::  How these features are used in the previous example.
  * How Precedence::    How they work.
  
@@@ -773,8 -769,7 +773,8 @@@ merged result
  @menu
  * Simple GLR Parsers::     Using GLR parsers on unambiguous grammars.
  * Merging GLR Parses::     Using GLR parsers to resolve ambiguities.
 -* GLR Semantic Actions::   Deferred semantic actions have special concerns.
 +* GLR Semantic Actions::   Considerations for semantic values and deferred actions.
 +* Semantic Predicates::    Controlling a parse with arbitrary computations.
  * Compiler Requirements::  GLR parsers require a modern C compiler.
  @end menu
  
@@@ -1142,10 -1137,6 +1142,10 @@@ the offending merge
  @node GLR Semantic Actions
  @subsection GLR Semantic Actions
  
 +The nature of GLR parsing and the structure of the generated
 +parsers give rise to certain restrictions on semantic values and actions.
 +
 +@subsubsection Deferred semantic actions
  @cindex deferred semantic actions
  By definition, a deferred semantic action is not performed at the same time as
  the associated reduction.
@@@ -1179,7 -1170,6 +1179,7 @@@ For example, if a semantic action migh
  to invoke @code{yyclearin} (@pxref{Action Features}) or to attempt to free
  memory referenced by @code{yylval}.
  
 +@subsubsection YYERROR
  @findex YYERROR
  @cindex GLR parsers and @code{YYERROR}
  Another Bison feature requiring special consideration is @code{YYERROR}
  initiate error recovery.
  During deterministic GLR operation, the effect of @code{YYERROR} is
  the same as its effect in a deterministic parser.
 -In a deferred semantic action, its effect is undefined.
 -@c The effect is probably a syntax error at the split point.
 +The effect in a deferred action is similar, but the precise point of the
 +error is undefined;  instead, the parser reverts to deterministic operation,
 +selecting an unspecified stack on which to continue with a syntax error.
 +In a semantic predicate (see @ref{Semantic Predicates}) during nondeterministic
 +parsing, @code{YYERROR} silently prunes
 +the parse that invoked the test.
 +
 +@subsubsection Restrictions on semantic values and locations
 +GLR parsers require that you use POD (Plain Old Data) types for
 +semantic values and location types when using the generated parsers as
 +C++ code.
 +
 +@node Semantic Predicates
 +@subsection Controlling a Parse with Arbitrary Predicates
 +@findex %?
 +@cindex Semantic predicates in GLR parsers
 +
 +In addition to the @code{%dprec} and @code{%merge} directives,
 +GLR parsers
 +allow you to reject parses on the basis of arbitrary computations executed
 +in user code, without having Bison treat this rejection as an error
 +if there are alternative parses. (This feature is experimental and may
 +evolve.  We welcome user feedback.)  For example,
 +
 +@example
 +widget:
 +  %?@{  new_syntax @} "widget" id new_args  @{ $$ = f($3, $4); @}
 +| %?@{ !new_syntax @} "widget" id old_args  @{ $$ = f($3, $4); @}
 +;
 +@end example
 +
 +@noindent
 +is one way to allow the same parser to handle two different syntaxes for
 +widgets.  The clause preceded by @code{%?} is treated like an ordinary
 +action, except that its text is treated as an expression and is always
 +evaluated immediately (even when in nondeterministic mode).  If the
 +expression yields 0 (false), the clause is treated as a syntax error,
 +which, in a nondeterministic parser, causes the stack in which it is reduced
 +to die.  In a deterministic parser, it acts like YYERROR.
 +
 +As the example shows, predicates otherwise look like semantic actions, and
 +therefore you must be take them into account when determining the numbers
 +to use for denoting the semantic values of right-hand side symbols.
 +Predicate actions, however, have no defined value, and may not be given
 +labels.
 +
 +There is a subtle difference between semantic predicates and ordinary
 +actions in nondeterministic mode, since the latter are deferred.
 +For example, we could try to rewrite the previous example as
 +
 +@example
 +widget:
 +  @{ if (!new_syntax) YYERROR; @}
 +    "widget" id new_args  @{ $$ = f($3, $4); @}
 +|  @{ if (new_syntax) YYERROR; @}
 +    "widget" id old_args   @{ $$ = f($3, $4); @}
 +;
 +@end example
  
 -Also, see @ref{Location Default Action, ,Default Action for Locations}, which
 -describes a special usage of @code{YYLLOC_DEFAULT} in GLR parsers.
 +@noindent
 +(reversing the sense of the predicate tests to cause an error when they are
 +false).  However, this
 +does @emph{not} have the same effect if @code{new_args} and @code{old_args}
 +have overlapping syntax.
 +Since the mid-rule actions testing @code{new_syntax} are deferred,
 +a GLR parser first encounters the unresolved ambiguous reduction
 +for cases where @code{new_args} and @code{old_args} recognize the same string
 +@emph{before} performing the tests of @code{new_syntax}.  It therefore
 +reports an error.
 +
 +Finally, be careful in writing predicates: deferred actions have not been
 +evaluated, so that using them in a predicate will have undefined effects.
  
  @node Compiler Requirements
  @subsection Considerations when Compiling GLR Parsers
@@@ -1527,13 -1450,11 +1527,13 @@@ The source code for this calculator is 
  Here are the C and Bison declarations for the reverse polish notation
  calculator.  As in C, comments are placed between @samp{/*@dots{}*/}.
  
 +@comment file: rpcalc.y
  @example
  /* Reverse polish notation calculator.  */
  
  %@{
    #define YYSTYPE double
 +  #include <stdio.h>
    #include <math.h>
    int yylex (void);
    void yyerror (char const *);
@@@ -1578,7 -1499,6 +1578,7 @@@ type for numeric constants
  
  Here are the grammar rules for the reverse polish notation calculator.
  
 +@comment file: rpcalc.y
  @example
  @group
  input:
@@@ -1627,9 -1547,9 +1627,9 @@@ main job of most actions.  The semanti
  rule are referred to as @code{$1}, @code{$2}, and so on.
  
  @menu
 -* Rpcalc Input::
 -* Rpcalc Line::
 -* Rpcalc Expr::
 +* Rpcalc Input::            Explanation of the @code{input} nonterminal
 +* Rpcalc Line::             Explanation of the @code{line} nonterminal
 +* Rpcalc Expr::             Explanation of the @code{expr} nonterminal
  @end menu
  
  @node Rpcalc Input
@@@ -1793,7 -1713,6 +1793,7 @@@ A token type code of zero is returned i
  
  Here is the code for the lexical analyzer:
  
 +@comment file: rpcalc.y
  @example
  @group
  /* The lexical analyzer returns a double floating point
@@@ -1842,7 -1761,6 +1842,7 @@@ In keeping with the spirit of this exam
  kept to the bare minimum.  The only requirement is that it call
  @code{yyparse} to start the process of parsing.
  
 +@comment file: rpcalc.y
  @example
  @group
  int
@@@ -1863,7 -1781,6 +1863,7 @@@ always @code{"syntax error"}).  It is u
  @code{yyerror} (@pxref{Interface, ,Parser C-Language Interface}), so
  here is the definition we will use:
  
 +@comment file: rpcalc.y
  @example
  @group
  #include <stdio.h>
@@@ -1948,15 -1865,15 +1948,15 @@@ example session using @code{rpcalc}
  @example
  $ @kbd{rpcalc}
  @kbd{4 9 +}
 -13
 +@result{} 13
  @kbd{3 7 + 3 4 5 *+-}
 --13
 +@result{} -13
  @kbd{3 7 + 3 4 5 * + - n}              @r{Note the unary minus, @samp{n}}
 -13
 +@result{} 13
  @kbd{5 6 / 4 n +}
 --3.166666667
 +@result{} -3.166666667
  @kbd{3 4 ^}                            @r{Exponentiation}
 -81
 +@result{} 81
  @kbd{^D}                               @r{End-of-file indicator}
  $
  @end example
@@@ -1990,8 -1907,8 +1990,8 @@@ parentheses nested to arbitrary depth
  %token NUM
  %left '-' '+'
  %left '*' '/'
 -%left NEG     /* negation--unary minus */
 -%right '^'    /* exponentiation */
 +%precedence NEG   /* negation--unary minus */
 +%right '^'        /* exponentiation */
  @end group
  
  %% /* The grammar follows.  */
@@@ -2034,16 -1951,15 +2034,16 @@@ In the second section (Bison declaratio
  types and says they are left-associative operators.  The declarations
  @code{%left} and @code{%right} (right associativity) take the place of
  @code{%token} which is used to declare a token type name without
 -associativity.  (These tokens are single-character literals, which
 +associativity/precedence.  (These tokens are single-character literals, which
  ordinarily don't need to be declared.  We declare them here to specify
 -the associativity.)
 +the associativity/precedence.)
  
  Operator precedence is determined by the line ordering of the
  declarations; the higher the line number of the declaration (lower on
  the page or screen), the higher the precedence.  Hence, exponentiation
  has the highest precedence, unary minus (@code{NEG}) is next, followed
 -by @samp{*} and @samp{/}, and so on.  @xref{Precedence, ,Operator
 +by @samp{*} and @samp{/}, and so on.  Unary minus is not associative,
 +only precedence matters (@code{%precedence}. @xref{Precedence, ,Operator
  Precedence}.
  
  The other important new feature is the @code{%prec} in the grammar
@@@ -2147,7 -2063,7 +2147,7 @@@ the same as the declarations for the in
  
  %left '-' '+'
  %left '*' '/'
 -%left NEG
 +%precedence NEG
  %right '^'
  
  %% /* The grammar follows.  */
@@@ -2348,23 -2264,19 +2348,23 @@@ to create named variables, store value
  Here is a sample session with the multi-function calculator:
  
  @example
 +@group
  $ @kbd{mfcalc}
  @kbd{pi = 3.141592653589}
 -3.1415926536
 +@result{} 3.1415926536
 +@end group
 +@group
  @kbd{sin(pi)}
 -0.0000000000
 +@result{} 0.0000000000
 +@end group
  @kbd{alpha = beta1 = 2.3}
 -2.3000000000
 +@result{} 2.3000000000
  @kbd{alpha}
 -2.3000000000
 +@result{} 2.3000000000
  @kbd{ln(alpha)}
 -0.8329091229
 +@result{} 0.8329091229
  @kbd{exp(ln(beta1))}
 -2.3000000000
 +@result{} 2.3000000000
  $
  @end example
  
@@@ -2374,8 -2286,6 +2374,8 @@@ Note that multiple assignment and neste
  * Mfcalc Declarations::    Bison declarations for multi-function calculator.
  * Mfcalc Rules::           Grammar rules for the calculator.
  * Mfcalc Symbol Table::    Symbol table management subroutines.
 +* Mfcalc Lexer::           The lexical analyzer.
 +* Mfcalc Main::            The controlling function.
  @end menu
  
  @node Mfcalc Declarations
@@@ -2387,9 -2297,8 +2387,9 @@@ Here are the C and Bison declarations f
  @example
  @group
  %@{
 -  #include <math.h>  /* For math functions, cos(), sin(), etc.  */
 -  #include "calc.h"  /* Contains definition of `symrec'.  */
 +  #include <stdio.h>  /* For printf, etc. */
 +  #include <math.h>   /* For pow, used in the grammar.  */
 +  #include "calc.h"   /* Contains definition of `symrec'.  */
    int yylex (void);
    void yyerror (char const *);
  %@}
  %right '='
  %left '-' '+'
  %left '*' '/'
 -%left NEG     /* negation--unary minus */
 -%right '^'    /* exponentiation */
 +%precedence NEG /* negation--unary minus */
 +%right '^'      /* exponentiation */
  @end group
  @end example
  
@@@ -2526,11 -2435,23 +2526,11 @@@ symrec *getsym (char const *)
  @end group
  @end example
  
 -The new version of @code{main} includes a call to @code{init_table}, a
 -function that initializes the symbol table.  Here it is, and
 -@code{init_table} as well:
 +The new version of @code{main} will call @code{init_table} to initialize
 +the symbol table:
  
  @comment file: mfcalc.y: 3
  @example
 -#include <stdio.h>
 -
 -@group
 -/* Called by yyparse on error.  */
 -void
 -yyerror (char const *s)
 -@{
 -  printf ("%s\n", s);
 -@}
 -@end group
 -
  @group
  struct init
  @{
  @group
  struct init const arith_fncts[] =
  @{
 -  "sin",  sin,
 -  "cos",  cos,
 -  "atan", atan,
 -  "ln",   log,
 -  "exp",  exp,
 -  "sqrt", sqrt,
 -  0, 0
 +  @{ "atan", atan @},
 +  @{ "cos",  cos  @},
 +  @{ "exp",  exp  @},
 +  @{ "ln",   log  @},
 +  @{ "sin",  sin  @},
 +  @{ "sqrt", sqrt @},
 +  @{ 0, 0 @},
  @};
  @end group
  
@@@ -2559,7 -2480,6 +2559,7 @@@ symrec *sym_table
  
  @group
  /* Put arithmetic functions in table.  */
 +static
  void
  init_table (void)
  @{
      @}
  @}
  @end group
 -
 -@group
 -int
 -main (void)
 -@{
 -  init_table ();
 -  return yyparse ();
 -@}
 -@end group
  @end example
  
  By simply editing the initialization list and adding the necessary include
@@@ -2610,16 -2539,13 +2610,16 @@@ getsym (char const *sym_name
    symrec *ptr;
    for (ptr = sym_table; ptr != (symrec *) 0;
         ptr = (symrec *)ptr->next)
 -    if (strcmp (ptr->name,sym_name) == 0)
 +    if (strcmp (ptr->name, sym_name) == 0)
        return ptr;
    return 0;
  @}
  @end group
  @end example
  
 +@node Mfcalc Lexer
 +@subsection The @code{mfcalc} Lexer
 +
  The function @code{yylex} must now recognize variables, numeric values, and
  the single-character arithmetic operators.  Strings of alphanumeric
  characters with a leading letter are recognized as either variables or
@@@ -2676,6 -2602,7 +2676,6 @@@ yylex (void
        symrec *s;
        int i;
  @end group
 -
        if (!symbuf)
          symbuf = (char *) malloc (length + 1);
  
  @end group
  @end example
  
 +@node Mfcalc Main
 +@subsection The @code{mfcalc} Main
 +
  The error reporting function is unchanged, and the new version of
  @code{main} includes a call to @code{init_table} and sets the @code{yydebug}
  on user demand (@xref{Tracing, , Tracing Your Parser}, for details):
@@@ -4376,8 -4300,7 +4376,8 @@@ Bison will convert this into a @code{#d
  the parser, so that the function @code{yylex} (if it is in this file)
  can use the name @var{name} to stand for this token type's code.
  
 -Alternatively, you can use @code{%left}, @code{%right}, or
 +Alternatively, you can use @code{%left}, @code{%right},
 +@code{%precedence}, or
  @code{%nonassoc} instead of @code{%token}, if you wish to specify
  associativity and precedence.  @xref{Precedence Decl, ,Operator
  Precedence}.
@@@ -4453,8 -4376,7 +4453,8 @@@ of ``$end''
  @cindex declaring operator precedence
  @cindex operator precedence, declaring
  
 -Use the @code{%left}, @code{%right} or @code{%nonassoc} declaration to
 +Use the @code{%left}, @code{%right}, @code{%nonassoc}, or
 +@code{%precedence} declaration to
  declare a token and specify its precedence and associativity, all at
  once.  These are called @dfn{precedence declarations}.
  @xref{Precedence, ,Operator Precedence}, for general information on
@@@ -4490,10 -4412,6 +4490,10 @@@ left-associativity (grouping @var{x} wi
  means that @samp{@var{x} @var{op} @var{y} @var{op} @var{z}} is
  considered a syntax error.
  
 +@code{%precedence} gives only precedence to the @var{symbols}, and
 +defines no associativity at all.  Use this to define precedence only,
 +and leave any potential conflict due to associativity enabled.
 +
  @item
  The precedence of an operator determines how it nests with other operators.
  All the tokens declared in a single precedence declaration have equal
@@@ -4954,7 -4872,7 +4954,7 @@@ statically allocated variables for comm
  including @code{yylval} and @code{yylloc}.)
  
  Alternatively, you can generate a pure, reentrant parser.  The Bison
 -declaration @code{%define api.pure} says that you want the parser to be
 +declaration @samp{%define api.pure} says that you want the parser to be
  reentrant.  It looks like this:
  
  @example
@@@ -5058,14 -4976,14 +5058,14 @@@ for use by the next invocation of the @
  
  Bison also supports both the push parser interface along with the pull parser
  interface in the same generated parser.  In order to get this functionality,
 -you should replace the @code{%define api.push-pull push} declaration with the
 -@code{%define api.push-pull both} declaration.  Doing this will create all of
 +you should replace the @samp{%define api.push-pull push} declaration with the
 +@samp{%define api.push-pull both} declaration.  Doing this will create all of
  the symbols mentioned earlier along with the two extra symbols, @code{yyparse}
  and @code{yypull_parse}.  @code{yyparse} can be used exactly as it normally
  would be used.  However, the user should note that it is implemented in the
  generated parser by calling @code{yypull_parse}.
  This makes the @code{yyparse} function that is generated with the
 -@code{%define api.push-pull both} declaration slower than the normal
 +@samp{%define api.push-pull both} declaration slower than the normal
  @code{yyparse} function.  If the user
  calls the @code{yypull_parse} function it will parse the rest of the input
  stream.  It is possible to @code{yypush_parse} tokens to select a subgrammar
@@@ -5081,9 -4999,9 +5081,9 @@@ yypull_parse (ps); /* Will call the lex
  yypstate_delete (ps);
  @end example
  
 -Adding the @code{%define api.pure} declaration does exactly the same thing to
 -the generated parser with @code{%define api.push-pull both} as it did for
 -@code{%define api.push-pull push}.
 +Adding the @samp{%define api.pure} declaration does exactly the same thing to
 +the generated parser with @samp{%define api.push-pull both} as it did for
 +@samp{%define api.push-pull push}.
  
  @node Decl Summary
  @subsection Bison Declaration Summary
@@@ -5156,9 -5074,9 +5156,9 @@@ default location or at the location spe
  @end deffn
  
  @deffn {Directive} %debug
 -In the parser implementation file, define the macro @code{YYDEBUG} to
 -1 if it is not already defined, so that the debugging facilities are
 -compiled.  @xref{Tracing, ,Tracing Your Parser}.
 +Instrument the output parser for traces.  Obsoleted by @samp{%define
 +parse.trace}.
 +@xref{Tracing, ,Tracing Your Parser}.
  @end deffn
  
  @deffn {Directive} %define @var{variable}
@@@ -5247,7 -5165,7 +5247,7 @@@ is @code{yyparse}, @code{yylex}, @code{
  @code{yypstate_new} and @code{yypstate_delete} will
  also be renamed.  For example, if you use @samp{%name-prefix "c_"}, the
  names become @code{c_parse}, @code{c_lex}, and so on.
 -For C++ parsers, see the @code{%define namespace} documentation in this
 +For C++ parsers, see the @samp{%define api.namespace} documentation in this
  section.
  @xref{Multiple Parsers, ,Multiple Parsers in the Same Program}.
  @end deffn
@@@ -5275,7 -5193,7 +5275,7 @@@ Specify @var{file} for the parser imple
  @end deffn
  
  @deffn {Directive} %pure-parser
 -Deprecated version of @code{%define api.pure} (@pxref{%define
 +Deprecated version of @samp{%define api.pure} (@pxref{%define
  Summary,,api.pure}), for which Bison is more careful to warn about
  unreasonable usage.
  @end deffn
@@@ -5398,61 -5316,7 +5398,61 @@@ Summary,,%skeleton})
  Unaccepted @var{variable}s produce an error.
  Some of the accepted @var{variable}s are:
  
 -@itemize @bullet
 +@table @code
 +@c ================================================== api.namespace
 +@item api.namespace
 +@findex %define api.namespace
 +@itemize
 +@item Languages(s): C++
 +
 +@item Purpose: Specify the namespace for the parser class.
 +For example, if you specify:
 +
 +@example
 +%define api.namespace "foo::bar"
 +@end example
 +
 +Bison uses @code{foo::bar} verbatim in references such as:
 +
 +@example
 +foo::bar::parser::semantic_type
 +@end example
 +
 +However, to open a namespace, Bison removes any leading @code{::} and then
 +splits on any remaining occurrences:
 +
 +@example
 +namespace foo @{ namespace bar @{
 +  class position;
 +  class location;
 +@} @}
 +@end example
 +
 +@item Accepted Values:
 +Any absolute or relative C++ namespace reference without a trailing
 +@code{"::"}.  For example, @code{"foo"} or @code{"::foo::bar"}.
 +
 +@item Default Value:
 +The value specified by @code{%name-prefix}, which defaults to @code{yy}.
 +This usage of @code{%name-prefix} is for backward compatibility and can
 +be confusing since @code{%name-prefix} also specifies the textual prefix
 +for the lexical analyzer function.  Thus, if you specify
 +@code{%name-prefix}, it is best to also specify @samp{%define
 +api.namespace} so that @code{%name-prefix} @emph{only} affects the
 +lexical analyzer function.  For example, if you specify:
 +
 +@example
 +%define api.namespace "foo"
 +%name-prefix "bar::"
 +@end example
 +
 +The parser namespace is @code{foo} and @code{yylex} is referenced as
 +@code{bar::lex}.
 +@end itemize
 +@c namespace
 +
 +
 +
  @c ================================================== api.pure
  @item api.pure
  @findex %define api.pure
  
  @item Default Value: @code{false}
  @end itemize
 +@c api.pure
 +
 +
  
 +@c ================================================== api.push-pull
  @item api.push-pull
  @findex %define api.push-pull
  
@@@ -5487,69 -5347,6 +5487,69 @@@ More user feedback will help to stabili
  
  @item Default Value: @code{pull}
  @end itemize
 +@c api.push-pull
 +
 +
 +
 +@c ================================================== api.tokens.prefix
 +@item api.tokens.prefix
 +@findex %define api.tokens.prefix
 +
 +@itemize
 +@item Languages(s): all
 +
 +@item Purpose:
 +Add a prefix to the token names when generating their definition in the
 +target language.  For instance
 +
 +@example
 +%token FILE for ERROR
 +%define api.tokens.prefix "TOK_"
 +%%
 +start: FILE for ERROR;
 +@end example
 +
 +@noindent
 +generates the definition of the symbols @code{TOK_FILE}, @code{TOK_for},
 +and @code{TOK_ERROR} in the generated source files.  In particular, the
 +scanner must use these prefixed token names, while the grammar itself
 +may still use the short names (as in the sample rule given above).  The
 +generated informational files (@file{*.output}, @file{*.xml},
 +@file{*.dot}) are not modified by this prefix.  See @ref{Calc++ Parser}
 +and @ref{Calc++ Scanner}, for a complete example.
 +
 +@item Accepted Values:
 +Any string.  Should be a valid identifier prefix in the target language,
 +in other words, it should typically be an identifier itself (sequence of
 +letters, underscores, and ---not at the beginning--- digits).
 +
 +@item Default Value:
 +empty
 +@end itemize
 +@c api.tokens.prefix
 +
 +
 +@c ================================================== lex_symbol
 +@item lex_symbol
 +@findex %define lex_symbol
 +
 +@itemize @bullet
 +@item Language(s):
 +C++
 +
 +@item Purpose:
 +When variant-based semantic values are enabled (@pxref{C++ Variants}),
 +request that symbols be handled as a whole (type, value, and possibly
 +location) in the scanner.  @xref{Complete Symbols}, for details.
 +
 +@item Accepted Values:
 +Boolean.
 +
 +@item Default Value:
 +@code{false}
 +@end itemize
 +@c lex_symbol
 +
  
  @c ================================================== lr.default-reductions
  
@@@ -5584,7 -5381,6 +5584,7 @@@ remain in the parser tables.  @xref{Unr
  @item Accepted Values: Boolean
  @item Default Value: @code{false}
  @end itemize
 +@c lr.keep-unreachable-states
  
  @c ================================================== lr.type
  
@@@ -5603,59 -5399,57 +5603,59 @@@ More user feedback will help to stabili
  @item Default Value: @code{lalr}
  @end itemize
  
 +
 +@c ================================================== namespace
  @item namespace
  @findex %define namespace
 +Obsoleted by @code{api.namespace}
 +@c namespace
  
 -@itemize
 -@item Languages(s): C++
  
 -@item Purpose: Specify the namespace for the parser class.
 -For example, if you specify:
 +@c ================================================== parse.assert
 +@item parse.assert
 +@findex %define parse.assert
  
 -@smallexample
 -%define namespace "foo::bar"
 -@end smallexample
 +@itemize
 +@item Languages(s): C++
  
 -Bison uses @code{foo::bar} verbatim in references such as:
 +@item Purpose: Issue runtime assertions to catch invalid uses.
 +In C++, when variants are used (@pxref{C++ Variants}), symbols must be
 +constructed and
 +destroyed properly.  This option checks these constraints.
  
 -@smallexample
 -foo::bar::parser::semantic_type
 -@end smallexample
 +@item Accepted Values: Boolean
  
 -However, to open a namespace, Bison removes any leading @code{::} and then
 -splits on any remaining occurrences:
 +@item Default Value: @code{false}
 +@end itemize
 +@c parse.assert
  
 -@smallexample
 -namespace foo @{ namespace bar @{
 -  class position;
 -  class location;
 -@} @}
 -@end smallexample
 -
 -@item Accepted Values: Any absolute or relative C++ namespace reference without
 -a trailing @code{"::"}.
 -For example, @code{"foo"} or @code{"::foo::bar"}.
 -
 -@item Default Value: The value specified by @code{%name-prefix}, which defaults
 -to @code{yy}.
 -This usage of @code{%name-prefix} is for backward compatibility and can be
 -confusing since @code{%name-prefix} also specifies the textual prefix for the
 -lexical analyzer function.
 -Thus, if you specify @code{%name-prefix}, it is best to also specify
 -@code{%define namespace} so that @code{%name-prefix} @emph{only} affects the
 -lexical analyzer function.
 -For example, if you specify:
  
 -@smallexample
 -%define namespace "foo"
 -%name-prefix "bar::"
 -@end smallexample
 +@c ================================================== parse.error
 +@item parse.error
 +@findex %define parse.error
 +@itemize
 +@item Languages(s):
 +all
 +@item Purpose:
 +Control the kind of error messages passed to the error reporting
 +function.  @xref{Error Reporting, ,The Error Reporting Function
 +@code{yyerror}}.
 +@item Accepted Values:
 +@itemize
 +@item @code{simple}
 +Error messages passed to @code{yyerror} are simply @w{@code{"syntax
 +error"}}.
 +@item @code{verbose}
 +Error messages report the unexpected token, and possibly the expected ones.
 +However, this report can often be incorrect when LAC is not enabled
 +(@pxref{LAC}).
 +@end itemize
  
 -The parser namespace is @code{foo} and @code{yylex} is referenced as
 -@code{bar::lex}.
 +@item Default Value:
 +@code{simple}
  @end itemize
 +@c parse.error
 +
  
  @c ================================================== parse.lac
  @item parse.lac
@@@ -5669,46 -5463,7 +5669,46 @@@ syntax error handling.  @xref{LAC}
  @item Accepted Values: @code{none}, @code{full}
  @item Default Value: @code{none}
  @end itemize
 +@c parse.lac
 +
 +@c ================================================== parse.trace
 +@item parse.trace
 +@findex %define parse.trace
 +
 +@itemize
 +@item Languages(s): C, C++
 +
 +@item Purpose: Require parser instrumentation for tracing.
 +In C/C++, define the macro @code{YYDEBUG} to 1 in the parser implementation
 +file if it is not already defined, so that the debugging facilities are
 +compiled.  @xref{Tracing, ,Tracing Your Parser}.
 +
 +@item Accepted Values: Boolean
 +
 +@item Default Value: @code{false}
  @end itemize
 +@c parse.trace
 +
 +@c ================================================== variant
 +@item variant
 +@findex %define variant
 +
 +@itemize @bullet
 +@item Language(s):
 +C++
 +
 +@item Purpose:
 +Request variant-based semantic values.
 +@xref{C++ Variants}.
 +
 +@item Accepted Values:
 +Boolean.
 +
 +@item Default Value:
 +@code{false}
 +@end itemize
 +@c variant
 +@end table
  
  
  @node %code Summary
@@@ -5754,7 -5509,7 +5754,7 @@@ file
  Not all qualifiers are accepted for all target languages.  Unaccepted
  qualifiers produce an error.  Some of the accepted qualifiers are:
  
 -@itemize @bullet
 +@table @code
  @item requires
  @findex %code requires
  
@@@ -5818,7 -5573,7 +5818,7 @@@ parser implementation file.  For exampl
  @item Location(s): The parser Java file after any Java package directive and
  before any class definitions.
  @end itemize
 -@end itemize
 +@end table
  
  Though we say the insertion locations are language-dependent, they are
  technically skeleton-dependent.  Writers of non-standard skeletons
@@@ -5926,10 -5681,10 +5926,10 @@@ If you use a reentrant parser, you can 
  parameter information to it in a reentrant way.  To do so, use the
  declaration @code{%parse-param}:
  
 -@deffn {Directive} %parse-param @{@var{argument-declaration}@}
 +@deffn {Directive} %parse-param @{@var{argument-declaration}@} @dots{}
  @findex %parse-param
 -Declare that an argument declared by the braced-code
 -@var{argument-declaration} is an additional @code{yyparse} argument.
 +Declare that one or more
 +@var{argument-declaration} are additional @code{yyparse} arguments.
  The @var{argument-declaration} is used when declaring
  functions or prototypes.  The last identifier in
  @var{argument-declaration} must be the argument name.
  Here's an example.  Write this in the parser:
  
  @example
 -%parse-param @{int *nastiness@}
 -%parse-param @{int *randomness@}
 +%parse-param @{int *nastiness@} @{int *randomness@}
  @end example
  
  @noindent
@@@ -5968,8 -5724,8 +5968,8 @@@ exp: @dots{}    @{ @dots{}; *randomnes
  More user feedback will help to stabilize it.)
  
  You call the function @code{yypush_parse} to parse a single token.  This
 -function is available if either the @code{%define api.push-pull push} or
 -@code{%define api.push-pull both} declaration is used.
 +function is available if either the @samp{%define api.push-pull push} or
 +@samp{%define api.push-pull both} declaration is used.
  @xref{Push Decl, ,A Push Parser}.
  
  @deftypefun int yypush_parse (yypstate *yyps)
@@@ -5986,7 -5742,7 +5986,7 @@@ is required to finish parsing the gramm
  More user feedback will help to stabilize it.)
  
  You call the function @code{yypull_parse} to parse the rest of the input
 -stream.  This function is available if the @code{%define api.push-pull both}
 +stream.  This function is available if the @samp{%define api.push-pull both}
  declaration is used.
  @xref{Push Decl, ,A Push Parser}.
  
@@@ -6002,8 -5758,8 +6002,8 @@@ The value returned by @code{yypull_pars
  More user feedback will help to stabilize it.)
  
  You call the function @code{yypstate_new} to create a new parser instance.
 -This function is available if either the @code{%define api.push-pull push} or
 -@code{%define api.push-pull both} declaration is used.
 +This function is available if either the @samp{%define api.push-pull push} or
 +@samp{%define api.push-pull both} declaration is used.
  @xref{Push Decl, ,A Push Parser}.
  
  @deftypefun {yypstate*} yypstate_new (void)
@@@ -6021,8 -5777,8 +6021,8 @@@ allocated
  More user feedback will help to stabilize it.)
  
  You call the function @code{yypstate_delete} to delete a parser instance.
 -function is available if either the @code{%define api.push-pull push} or
 -@code{%define api.push-pull both} declaration is used.
 +function is available if either the @samp{%define api.push-pull push} or
 +@samp{%define api.push-pull both} declaration is used.
  @xref{Push Decl, ,A Push Parser}.
  
  @deftypefun void yypstate_delete (yypstate *yyps)
@@@ -6211,7 -5967,7 +6211,7 @@@ The data type of @code{yylloc} has the 
  @node Pure Calling
  @subsection Calling Conventions for Pure Parsers
  
 -When you use the Bison declaration @code{%define api.pure} to request a
 +When you use the Bison declaration @samp{%define api.pure} to request a
  pure, reentrant parser, the global communication variables @code{yylval}
  and @code{yylloc} cannot be used.  (@xref{Pure Decl, ,A Pure (Reentrant)
  Parser}.)  In such parsers the two global variables are replaced by
@@@ -6235,57 -5991,46 +6235,57 @@@ textual locations, then the type @code{
  this case, omit the second argument; @code{yylex} will be called with
  only one argument.
  
 -
 -If you wish to pass the additional parameter data to @code{yylex}, use
 +If you wish to pass additional arguments to @code{yylex}, use
  @code{%lex-param} just like @code{%parse-param} (@pxref{Parser
 -Function}).
 +Function}).  To pass additional arguments to both @code{yylex} and
 +@code{yyparse}, use @code{%param}.
  
 -@deffn {Directive} lex-param @{@var{argument-declaration}@}
 +@deffn {Directive} %lex-param @{@var{argument-declaration}@} @dots{}
  @findex %lex-param
 -Declare that the braced-code @var{argument-declaration} is an
 -additional @code{yylex} argument declaration.
 +Specify that @var{argument-declaration} are additional @code{yylex} argument
 +declarations.  You may pass one or more such declarations, which is
 +equivalent to repeating @code{%lex-param}.
 +@end deffn
 +
 +@deffn {Directive} %param @{@var{argument-declaration}@} @dots{}
 +@findex %param
 +Specify that @var{argument-declaration} are additional
 +@code{yylex}/@code{yyparse} argument declaration.  This is equivalent to
 +@samp{%lex-param @{@var{argument-declaration}@} @dots{} %parse-param
 +@{@var{argument-declaration}@} @dots{}}.  You may pass one or more
 +declarations, which is equivalent to repeating @code{%param}.
  @end deffn
  
  For instance:
  
  @example
 -%parse-param @{int *nastiness@}
 -%lex-param   @{int *nastiness@}
 -%parse-param @{int *randomness@}
 +%lex-param   @{scanner_mode *mode@}
 +%parse-param @{parser_mode *mode@}
 +%param       @{environment_type *env@}
  @end example
  
  @noindent
  results in the following signature:
  
  @example
 -int yylex   (int *nastiness);
 -int yyparse (int *nastiness, int *randomness);
 +int yylex   (scanner_mode *mode, environment_type *env);
 +int yyparse (parser_mode *mode, environment_type *env);
  @end example
  
 -If @code{%define api.pure} is added:
 +If @samp{%define api.pure} is added:
  
  @example
 -int yylex   (YYSTYPE *lvalp, int *nastiness);
 -int yyparse (int *nastiness, int *randomness);
 +int yylex   (YYSTYPE *lvalp, scanner_mode *mode, environment_type *env);
 +int yyparse (parser_mode *mode, environment_type *env);
  @end example
  
  @noindent
 -and finally, if both @code{%define api.pure} and @code{%locations} are used:
 +and finally, if both @samp{%define api.pure} and @code{%locations} are used:
  
  @example
 -int yylex   (YYSTYPE *lvalp, YYLTYPE *llocp, int *nastiness);
 -int yyparse (int *nastiness, int *randomness);
 +int yylex   (YYSTYPE *lvalp, YYLTYPE *llocp,
 +             scanner_mode *mode, environment_type *env);
 +int yyparse (parser_mode *mode, environment_type *env);
  @end example
  
  @node Error Reporting
  @cindex parse error
  @cindex syntax error
  
 -The Bison parser detects a @dfn{syntax error} or @dfn{parse error}
 +The Bison parser detects a @dfn{syntax error} (or @dfn{parse error})
  whenever it reads a token which cannot satisfy any syntax rule.  An
  action in the grammar can also explicitly proclaim an error, using the
  macro @code{YYERROR} (@pxref{Action Features, ,Special Features for Use
@@@ -6307,8 -6052,8 +6307,8 @@@ called by @code{yyparse} whenever a syn
  receives one argument.  For a syntax error, the string is normally
  @w{@code{"syntax error"}}.
  
 -@findex %error-verbose
 -If you invoke the directive @code{%error-verbose} in the Bison declarations
 +@findex %define parse.error
 +If you invoke @samp{%define parse.error verbose} in the Bison declarations
  section (@pxref{Bison Declarations, ,The Bison Declarations Section}), then
  Bison provides a more verbose and specific error message string instead of
  just plain @w{@code{"syntax error"}}.  However, that message sometimes
@@@ -6366,7 -6111,7 +6366,7 @@@ void yyerror (int *nastiness, char cons
  Finally, GLR and Yacc parsers share the same @code{yyerror} calling
  convention for absolutely pure parsers, i.e., when the calling
  convention of @code{yylex} @emph{and} the calling convention of
 -@code{%define api.pure} are pure.
 +@samp{%define api.pure} are pure.
  I.e.:
  
  @example
@@@ -6888,8 -6633,7 +6888,8 @@@ shift and when to reduce
  
  @menu
  * Why Precedence::    An example showing why precedence is needed.
 -* Using Precedence::  How to specify precedence in Bison grammars.
 +* Using Precedence::  How to specify precedence and associativity.
 +* Precedence Only::   How to specify precedence only.
  * Precedence Examples::  How these features are used in the previous example.
  * How Precedence::    How they work.
  @end menu
@@@ -6945,9 -6689,8 +6945,9 @@@ makes right-associativity
  @node Using Precedence
  @subsection Specifying Operator Precedence
  @findex %left
 -@findex %right
  @findex %nonassoc
 +@findex %precedence
 +@findex %right
  
  Bison allows you to specify these choices with the operator precedence
  declarations @code{%left} and @code{%right}.  Each such declaration
@@@ -6957,63 -6700,13 +6957,63 @@@ those operators left-associative and th
  them right-associative.  A third alternative is @code{%nonassoc}, which
  declares that it is a syntax error to find the same operator twice ``in a
  row''.
 +The last alternative, @code{%precedence}, allows to define only
 +precedence and no associativity at all.  As a result, any
 +associativity-related conflict that remains will be reported as an
 +compile-time error.  The directive @code{%nonassoc} creates run-time
 +error: using the operator in a associative way is a syntax error.  The
 +directive @code{%precedence} creates compile-time errors: an operator
 +@emph{can} be involved in an associativity-related conflict, contrary to
 +what expected the grammar author.
  
  The relative precedence of different operators is controlled by the
 -order in which they are declared.  The first @code{%left} or
 -@code{%right} declaration in the file declares the operators whose
 +order in which they are declared.  The first precedence/associativity
 +declaration in the file declares the operators whose
  precedence is lowest, the next such declaration declares the operators
  whose precedence is a little higher, and so on.
  
 +@node Precedence Only
 +@subsection Specifying Precedence Only
 +@findex %precedence
 +
 +Since POSIX Yacc defines only @code{%left}, @code{%right}, and
 +@code{%nonassoc}, which all defines precedence and associativity, little
 +attention is paid to the fact that precedence cannot be defined without
 +defining associativity.  Yet, sometimes, when trying to solve a
 +conflict, precedence suffices.  In such a case, using @code{%left},
 +@code{%right}, or @code{%nonassoc} might hide future (associativity
 +related) conflicts that would remain hidden.
 +
 +The dangling @code{else} ambiguity (@pxref{Shift/Reduce, , Shift/Reduce
 +Conflicts}) can be solved explicitly.  This shift/reduce conflicts occurs
 +in the following situation, where the period denotes the current parsing
 +state:
 +
 +@example
 +if @var{e1} then if  @var{e2} then @var{s1} . else @var{s2}
 +@end example
 +
 +The conflict involves the reduction of the rule @samp{IF expr THEN
 +stmt}, which precedence is by default that of its last token
 +(@code{THEN}), and the shifting of the token @code{ELSE}.  The usual
 +disambiguation (attach the @code{else} to the closest @code{if}),
 +shifting must be preferred, i.e., the precedence of @code{ELSE} must be
 +higher than that of @code{THEN}.  But neither is expected to be involved
 +in an associativity related conflict, which can be specified as follows.
 +
 +@example
 +%precedence THEN
 +%precedence ELSE
 +@end example
 +
 +The unary-minus is another typical example where associativity is
 +usually over-specified, see @ref{Infix Calc, , Infix Notation
 +Calculator: @code{calc}}.  The @code{%left} directive is traditionally
 +used to declare the precedence of @code{NEG}, which is more than needed
 +since it also defines its associativity.  While this is harmless in the
 +traditional example, who knows how @code{NEG} might be used in future
 +evolutions of the grammar@dots{}
 +
  @node Precedence Examples
  @subsection Precedence Examples
  
@@@ -7075,8 -6768,8 +7075,8 @@@ outlandish at first, but it is really v
  sign typically has a very high precedence as a unary operator, and a
  somewhat lower precedence (lower than multiplication) as a binary operator.
  
 -The Bison precedence declarations, @code{%left}, @code{%right} and
 -@code{%nonassoc}, can only be used once for a given token; so a token has
 +The Bison precedence declarations
 +can only be used once for a given token; so a token has
  only one precedence declared in this way.  For context-dependent
  precedence, you need to use an additional mechanism: the @code{%prec}
  modifier for rules.
@@@ -7421,9 -7114,9 +7421,9 @@@ The default behavior of Bison's LR-base
  historical reasons, but that behavior is often not robust.  For example, in
  the previous section, we discussed the mysterious conflicts that can be
  produced by LALR(1), Bison's default parser table construction algorithm.
 -Another example is Bison's @code{%error-verbose} directive, which instructs
 -the generated parser to produce verbose syntax error messages, which can
 -sometimes contain incorrect information.
 +Another example is Bison's @code{%define parse.error verbose} directive,
 +which instructs the generated parser to produce verbose syntax error
 +messages, which can sometimes contain incorrect information.
  
  In this section, we explore several modern features of Bison that allow you
  to tune fundamental aspects of the generated LR-based parsers.  Some of
@@@ -7914,7 -7607,7 +7914,7 @@@ calls @code{yyerror} and then returns 2
  
  Because Bison parsers have growing stacks, hitting the upper limit
  usually results from using a right recursion instead of a left
- recursion, @xref{Recursion, ,Recursive Rules}.
+ recursion, see @ref{Recursion, ,Recursive Rules}.
  
  @vindex YYMAXDEPTH
  By defining the macro @code{YYMAXDEPTH}, you can control how deep the
@@@ -7947,14 -7640,12 +7947,14 @@@ that allows variable-length arrays.  Th
  
  Do not allow @code{YYINITDEPTH} to be greater than @code{YYMAXDEPTH}.
  
 -@c FIXME: C++ output.
 -Because of semantic differences between C and C++, the deterministic
 -parsers in C produced by Bison cannot grow when compiled
 -by C++ compilers.  In this precise case (compiling a C parser as C++) you are
 -suggested to grow @code{YYINITDEPTH}.  The Bison maintainers hope to fix
 -this deficiency in a future release.
 +You can generate a deterministic parser containing C++ user code from
 +the default (C) skeleton, as well as from the C++ skeleton
 +(@pxref{C++ Parsers}).  However, if you do use the default skeleton
 +and want to allow the parsing stack to grow,
 +be careful not to use semantic types or location types that require
 +non-trivial copy constructors.
 +The C skeleton bypasses these constructors when copying data to
 +new, larger stacks.
  
  @node Error Recovery
  @chapter Error Recovery
@@@ -8752,20 -8443,15 +8752,20 @@@ Use the @samp{-t} option when you run B
  
  @item the directive @samp{%debug}
  @findex %debug
 -Add the @code{%debug} directive (@pxref{Decl Summary, ,Bison
 -Declaration Summary}).  This is a Bison extension, which will prove
 -useful when Bison will output parsers for languages that don't use a
 -preprocessor.  Unless POSIX and Yacc portability matter to
 -you, this is
 -the preferred solution.
 +Add the @code{%debug} directive (@pxref{Decl Summary, ,Bison Declaration
 +Summary}).  This Bison extension is maintained for backward
 +compatibility with previous versions of Bison.
 +
 +@item the variable @samp{parse.trace}
 +@findex %define parse.trace
 +Add the @samp{%define parse.trace} directive (@pxref{%define
 +Summary,,parse.trace}), or pass the @option{-Dparse.trace} option
 +(@pxref{Bison Options}).  This is a Bison extension, which is especially
 +useful for languages that don't use a preprocessor.  Unless POSIX and Yacc
 +portability matter to you, this is the preferred solution.
  @end table
  
 -We suggest that you always enable the debug option so that debugging is
 +We suggest that you always enable the trace option so that debugging is
  always possible.
  
  @findex YYFPRINTF
@@@ -9416,16 -9102,16 +9416,16 @@@ The C++ deterministic parser is selecte
  
  When run, @command{bison} will create several entities in the @samp{yy}
  namespace.
 -@findex %define namespace
 -Use the @samp{%define namespace} directive to change the namespace
 -name, see @ref{%define Summary,,namespace}.  The various classes are
 -generated in the following files:
 +@findex %define api.namespace
 +Use the @samp{%define api.namespace} directive to change the namespace name,
 +see @ref{%define Summary,,api.namespace}.  The various classes are generated
 +in the following files:
  
  @table @file
  @item position.hh
  @itemx location.hh
  The definition of the classes @code{position} and @code{location},
 -used for location tracking.  @xref{C++ Location Values}.
 +used for location tracking when enabled.  @xref{C++ Location Values}.
  
  @item stack.hh
  An auxiliary class @code{stack} used by the parser.
@@@ -9451,22 -9137,11 +9451,22 @@@ for a complete and accurate documentati
  @c - YYSTYPE
  @c - Printer and destructor
  
 +Bison supports two different means to handle semantic values in C++.  One is
 +alike the C interface, and relies on unions (@pxref{C++ Unions}).  As C++
 +practitioners know, unions are inconvenient in C++, therefore another
 +approach is provided, based on variants (@pxref{C++ Variants}).
 +
 +@menu
 +* C++ Unions::             Semantic values cannot be objects
 +* C++ Variants::           Using objects as semantic values
 +@end menu
 +
 +@node C++ Unions
 +@subsubsection C++ Unions
 +
  The @code{%union} directive works as for C, see @ref{Union Decl, ,The
  Collection of Value Types}.  In particular it produces a genuine
 -@code{union}@footnote{In the future techniques to allow complex types
 -within pseudo-unions (similar to Boost variants) might be implemented to
 -alleviate these issues.}, which have a few specific features in C++.
 +@code{union}, which have a few specific features in C++.
  @itemize @minus
  @item
  The type @code{YYSTYPE} is defined but its use is discouraged: rather
@@@ -9483,98 -9158,6 +9483,98 @@@ reclaimed automatically: using the @cod
  only means to avoid leaks.  @xref{Destructor Decl, , Freeing Discarded
  Symbols}.
  
 +@node C++ Variants
 +@subsubsection C++ Variants
 +
 +Starting with version 2.6, Bison provides a @emph{variant} based
 +implementation of semantic values for C++.  This alleviates all the
 +limitations reported in the previous section, and in particular, object
 +types can be used without pointers.
 +
 +To enable variant-based semantic values, set @code{%define} variable
 +@code{variant} (@pxref{%define Summary,, variant}).  Once this defined,
 +@code{%union} is ignored, and instead of using the name of the fields of the
 +@code{%union} to ``type'' the symbols, use genuine types.
 +
 +For instance, instead of
 +
 +@example
 +%union
 +@{
 +  int ival;
 +  std::string* sval;
 +@}
 +%token <ival> NUMBER;
 +%token <sval> STRING;
 +@end example
 +
 +@noindent
 +write
 +
 +@example
 +%token <int> NUMBER;
 +%token <std::string> STRING;
 +@end example
 +
 +@code{STRING} is no longer a pointer, which should fairly simplify the user
 +actions in the grammar and in the scanner (in particular the memory
 +management).
 +
 +Since C++ features destructors, and since it is customary to specialize
 +@code{operator<<} to support uniform printing of values, variants also
 +typically simplify Bison printers and destructors.
 +
 +Variants are stricter than unions.  When based on unions, you may play any
 +dirty game with @code{yylval}, say storing an @code{int}, reading a
 +@code{char*}, and then storing a @code{double} in it.  This is no longer
 +possible with variants: they must be initialized, then assigned to, and
 +eventually, destroyed.
 +
 +@deftypemethod {semantic_type} {T&} build<T> ()
 +Initialize, but leave empty.  Returns the address where the actual value may
 +be stored.  Requires that the variant was not initialized yet.
 +@end deftypemethod
 +
 +@deftypemethod {semantic_type} {T&} build<T> (const T& @var{t})
 +Initialize, and copy-construct from @var{t}.
 +@end deftypemethod
 +
 +
 +@strong{Warning}: We do not use Boost.Variant, for two reasons.  First, it
 +appeared unacceptable to require Boost on the user's machine (i.e., the
 +machine on which the generated parser will be compiled, not the machine on
 +which @command{bison} was run).  Second, for each possible semantic value,
 +Boost.Variant not only stores the value, but also a tag specifying its
 +type.  But the parser already ``knows'' the type of the semantic value, so
 +that would be duplicating the information.
 +
 +Therefore we developed light-weight variants whose type tag is external (so
 +they are really like @code{unions} for C++ actually).  But our code is much
 +less mature that Boost.Variant.  So there is a number of limitations in
 +(the current implementation of) variants:
 +@itemize
 +@item
 +Alignment must be enforced: values should be aligned in memory according to
 +the most demanding type.  Computing the smallest alignment possible requires
 +meta-programming techniques that are not currently implemented in Bison, and
 +therefore, since, as far as we know, @code{double} is the most demanding
 +type on all platforms, alignments are enforced for @code{double} whatever
 +types are actually used.  This may waste space in some cases.
 +
 +@item
 +Our implementation is not conforming with strict aliasing rules.  Alias
 +analysis is a technique used in optimizing compilers to detect when two
 +pointers are disjoint (they cannot ``meet'').  Our implementation breaks
 +some of the rules that G++ 4.4 uses in its alias analysis, so @emph{strict
 +alias analysis must be disabled}.  Use the option
 +@option{-fno-strict-aliasing} to compile the generated parser.
 +
 +@item
 +There might be portability issues we are not aware of.
 +@end itemize
 +
 +As far as we know, these limitations @emph{can} be alleviated.  All it takes
 +is some time and/or some talented C++ hacker willing to contribute to Bison.
  
  @node C++ Location Values
  @subsection C++ Location Values
@@@ -9718,7 -9301,7 +9718,7 @@@ additional argument for its constructor
  
  @defcv {Type} {parser} {semantic_type}
  @defcvx {Type} {parser} {location_type}
 -The types for semantics value and locations.
 +The types for semantic values and locations (if enabled).
  @end defcv
  
  @defcv {Type} {parser} {token}
@@@ -9729,27 -9312,11 +9729,27 @@@ use @code{yy::parser::token::FOO}.  Th
  (@pxref{Calc++ Scanner}).
  @end defcv
  
 +@defcv {Type} {parser} {syntax_error}
 +This class derives from @code{std::runtime_error}.  Throw instances of it
 +from the scanner or from the user actions to raise parse errors.  This is
 +equivalent with first
 +invoking @code{error} to report the location and message of the syntax
 +error, and then to invoke @code{YYERROR} to enter the error-recovery mode.
 +But contrary to @code{YYERROR} which can only be invoked from user actions
 +(i.e., written in the action itself), the exception can be thrown from
 +function invoked from the user action.
 +@end defcv
 +
  @deftypemethod {parser} {} parser (@var{type1} @var{arg1}, ...)
  Build a new parser object.  There are no arguments by default, unless
  @samp{%parse-param @{@var{type1} @var{arg1}@}} was used.
  @end deftypemethod
  
 +@deftypemethod {syntax_error} {} syntax_error (const location_type& @var{l}, const std::string& @var{m})
 +@deftypemethodx {syntax_error} {} syntax_error (const std::string& @var{m})
 +Instantiate a syntax-error exception.
 +@end deftypemethod
 +
  @deftypemethod {parser} {int} parse ()
  Run the syntactic analysis, and return 0 on success, 1 otherwise.
  @end deftypemethod
@@@ -9767,11 -9334,9 +9767,11 @@@ or nonzero, full tracing
  @end deftypemethod
  
  @deftypemethod {parser} {void} error (const location_type& @var{l}, const std::string& @var{m})
 +@deftypemethodx {parser} {void} error (const std::string& @var{m})
  The definition for this member function must be supplied by the user:
  the parser uses it to report a parser error occurring at @var{l},
 -described by @var{m}.
 +described by @var{m}.  If location tracking is not enabled, the second
 +signature is used.
  @end deftypemethod
  
  
  
  The parser invokes the scanner by calling @code{yylex}.  Contrary to C
  parsers, C++ parsers are always pure: there is no point in using the
 -@code{%define api.pure} directive.  Therefore the interface is as follows.
 +@samp{%define api.pure} directive.  The actual interface with @code{yylex}
 +depends whether you use unions, or variants.
 +
 +@menu
 +* Split Symbols::         Passing symbols as two/three components
 +* Complete Symbols::      Making symbols a whole
 +@end menu
 +
 +@node Split Symbols
 +@subsubsection Split Symbols
 +
 +Therefore the interface is as follows.
  
  @deftypemethod {parser} {int} yylex (semantic_type* @var{yylval}, location_type* @var{yylloc}, @var{type1} @var{arg1}, ...)
 -Return the next token.  Its type is the return value, its semantic
 -value and location being @var{yylval} and @var{yylloc}.  Invocations of
 +@deftypemethodx {parser} {int} yylex (semantic_type* @var{yylval}, @var{type1} @var{arg1}, ...)
 +Return the next token.  Its type is the return value, its semantic value and
 +location (if enabled) being @var{yylval} and @var{yylloc}.  Invocations of
  @samp{%lex-param @{@var{type1} @var{arg1}@}} yield additional arguments.
  @end deftypemethod
  
 +Note that when using variants, the interface for @code{yylex} is the same,
 +but @code{yylval} is handled differently.
 +
 +Regular union-based code in Lex scanner typically look like:
 +
 +@example
 +[0-9]+   @{
 +           yylval.ival = text_to_int (yytext);
 +           return yy::parser::INTEGER;
 +         @}
 +[a-z]+   @{
 +           yylval.sval = new std::string (yytext);
 +           return yy::parser::IDENTIFIER;
 +         @}
 +@end example
 +
 +Using variants, @code{yylval} is already constructed, but it is not
 +initialized.  So the code would look like:
 +
 +@example
 +[0-9]+   @{
 +           yylval.build<int>() = text_to_int (yytext);
 +           return yy::parser::INTEGER;
 +         @}
 +[a-z]+   @{
 +           yylval.build<std::string> = yytext;
 +           return yy::parser::IDENTIFIER;
 +         @}
 +@end example
 +
 +@noindent
 +or
 +
 +@example
 +[0-9]+   @{
 +           yylval.build(text_to_int (yytext));
 +           return yy::parser::INTEGER;
 +         @}
 +[a-z]+   @{
 +           yylval.build(yytext);
 +           return yy::parser::IDENTIFIER;
 +         @}
 +@end example
 +
 +
 +@node Complete Symbols
 +@subsubsection Complete Symbols
 +
 +If you specified both @code{%define variant} and @code{%define lex_symbol},
 +the @code{parser} class also defines the class @code{parser::symbol_type}
 +which defines a @emph{complete} symbol, aggregating its type (i.e., the
 +traditional value returned by @code{yylex}), its semantic value (i.e., the
 +value passed in @code{yylval}, and possibly its location (@code{yylloc}).
 +
 +@deftypemethod {symbol_type} {} symbol_type (token_type @var{type},  const semantic_type& @var{value}, const location_type& @var{location})
 +Build a complete terminal symbol which token type is @var{type}, and which
 +semantic value is @var{value}.  If location tracking is enabled, also pass
 +the @var{location}.
 +@end deftypemethod
 +
 +This interface is low-level and should not be used for two reasons.  First,
 +it is inconvenient, as you still have to build the semantic value, which is
 +a variant, and second, because consistency is not enforced: as with unions,
 +it is still possible to give an integer as semantic value for a string.
 +
 +So for each token type, Bison generates named constructors as follows.
 +
 +@deftypemethod {symbol_type} {} make_@var{token} (const @var{value_type}& @var{value}, const location_type& @var{location})
 +@deftypemethodx {symbol_type} {} make_@var{token} (const location_type& @var{location})
 +Build a complete terminal symbol for the token type @var{token} (not
 +including the @code{api.tokens.prefix}) whose possible semantic value is
 +@var{value} of adequate @var{value_type}.  If location tracking is enabled,
 +also pass the @var{location}.
 +@end deftypemethod
 +
 +For instance, given the following declarations:
 +
 +@example
 +%define api.tokens.prefix "TOK_"
 +%token <std::string> IDENTIFIER;
 +%token <int> INTEGER;
 +%token COLON;
 +@end example
 +
 +@noindent
 +Bison generates the following functions:
 +
 +@example
 +symbol_type make_IDENTIFIER(const std::string& v,
 +                            const location_type& l);
 +symbol_type make_INTEGER(const int& v,
 +                         const location_type& loc);
 +symbol_type make_COLON(const location_type& loc);
 +@end example
 +
 +@noindent
 +which should be used in a Lex-scanner as follows.
 +
 +@example
 +[0-9]+   return yy::parser::make_INTEGER(text_to_int (yytext), loc);
 +[a-z]+   return yy::parser::make_IDENTIFIER(yytext, loc);
 +":"      return yy::parser::make_COLON(loc);
 +@end example
 +
 +Tokens that do not have an identifier are not accessible: you cannot simply
 +use characters such as @code{':'}, they must be declared with @code{%token}.
  
  @node A Complete C++ Example
  @subsection A Complete C++ Example
  
  This section demonstrates the use of a C++ parser with a simple but
  complete example.  This example should be available on your system,
 -ready to compile, in the directory @dfn{../bison/examples/calc++}.  It
 +ready to compile, in the directory @dfn{.../bison/examples/calc++}.  It
  focuses on the use of Bison, therefore the design of the various C++
  classes is very naive: no accessors, no encapsulation of members etc.
  We will use a Lex scanner, and more precisely, a Flex scanner, to
 -demonstrate the various interaction.  A hand written scanner is
 +demonstrate the various interactions.  A hand-written scanner is
  actually easier to interface with.
  
  @menu
@@@ -9983,8 -9430,11 +9983,8 @@@ factor both as follows
  @comment file: calc++-driver.hh
  @example
  // Tell Flex the lexer's prototype ...
 -# define YY_DECL                                        \
 -  yy::calcxx_parser::token_type                         \
 -  yylex (yy::calcxx_parser::semantic_type* yylval,      \
 -         yy::calcxx_parser::location_type* yylloc,      \
 -         calcxx_driver& driver)
 +# define YY_DECL \
 +  yy::calcxx_parser::symbol_type yylex (calcxx_driver& driver)
  // ... and declare it for the parser's sake.
  YY_DECL;
  @end example
@@@ -10008,8 -9458,8 +10008,8 @@@ public
  @end example
  
  @noindent
 -To encapsulate the coordination with the Flex scanner, it is useful to
 -have two members function to open and close the scanning phase.
 +To encapsulate the coordination with the Flex scanner, it is useful to have
 +member functions to open and close the scanning phase.
  
  @comment file: calc++-driver.hh
  @example
@@@ -10024,13 -9474,9 +10024,13 @@@ Similarly for the parser itself
  
  @comment file: calc++-driver.hh
  @example
 -  // Run the parser.  Return 0 on success.
 +  // Run the parser on file F.
 +  // Return 0 on success.
    int parse (const std::string& f);
 +  // The name of the file being parsed.
 +  // Used later to pass the file name to the location tracker.
    std::string file;
 +  // Whether parser traces should be generated.
    bool trace_parsing;
  @end example
  
@@@ -10112,35 -9558,19 +10112,35 @@@ the grammar for
  %define parser_class_name "calcxx_parser"
  @end example
  
 +@noindent
 +@findex %define variant
 +@findex %define lex_symbol
 +This example will use genuine C++ objects as semantic values, therefore, we
 +require the variant-based interface.  To make sure we properly use it, we
 +enable assertions.  To fully benefit from type-safety and more natural
 +definition of ``symbol'', we enable @code{lex_symbol}.
 +
 +@comment file: calc++-parser.yy
 +@example
 +%define variant
 +%define parse.assert
 +%define lex_symbol
 +@end example
 +
  @noindent
  @findex %code requires
 -Then come the declarations/inclusions needed to define the
 -@code{%union}.  Because the parser uses the parsing driver and
 -reciprocally, both cannot include the header of the other.  Because the
 +Then come the declarations/inclusions needed by the semantic values.
 +Because the parser uses the parsing driver and reciprocally, both would like
 +to include the header of the other, which is, of course, insane.  This
 +mutual dependency will be broken using forward declarations.  Because the
  driver's header needs detailed knowledge about the parser class (in
 -particular its inner types), it is the parser's header which will simply
 -use a forward declaration of the driver.
 -@xref{%code Summary}.
 +particular its inner types), it is the parser's header which will use a
 +forward declaration of the driver.  @xref{%code Summary}.
  
  @comment file: calc++-parser.yy
  @example
 -%code requires @{
 +%code requires
 +@{
  # include <string>
  class calcxx_driver;
  @}
@@@ -10154,14 -9584,15 +10154,14 @@@ global variables
  @comment file: calc++-parser.yy
  @example
  // The parsing context.
 -%parse-param @{ calcxx_driver& driver @}
 -%lex-param   @{ calcxx_driver& driver @}
 +%param @{ calcxx_driver& driver @}
  @end example
  
  @noindent
 -Then we request the location tracking feature, and initialize the
 +Then we request location tracking, and initialize the
  first location's file name.  Afterward new locations are computed
  relatively to the previous locations: the file name will be
 -automatically propagated.
 +propagated.
  
  @comment file: calc++-parser.yy
  @example
  @end example
  
  @noindent
 -Use the two following directives to enable parser tracing and verbose error
 +Use the following two directives to enable parser tracing and verbose error
  messages.  However, verbose error messages can contain incorrect information
  (@pxref{LAC}).
  
  @comment file: calc++-parser.yy
  @example
 -%debug
 -%error-verbose
 -@end example
 -
 -@noindent
 -Semantic values cannot use ``real'' objects, but only pointers to
 -them.
 -
 -@comment file: calc++-parser.yy
 -@example
 -// Symbols.
 -%union
 -@{
 -  int          ival;
 -  std::string *sval;
 -@};
 +%define parse.trace
 +%define parse.error verbose
  @end example
  
  @noindent
@@@ -10191,8 -9636,7 +10191,8 @@@ The code between @samp{%code @{} and @s
  
  @comment file: calc++-parser.yy
  @example
 -%code @{
 +%code
 +@{
  # include "calc++-driver.hh"
  @}
  @end example
  
  @noindent
  The token numbered as 0 corresponds to end of file; the following line
 -allows for nicer error messages referring to ``end of file'' instead
 -of ``$end''.  Similarly user friendly named are provided for each
 -symbol.  Note that the tokens names are prefixed by @code{TOKEN_} to
 -avoid name clashes.
 +allows for nicer error messages referring to ``end of file'' instead of
 +``$end''.  Similarly user friendly names are provided for each symbol.  To
 +avoid name clashes in the generated files (@pxref{Calc++ Scanner}), prefix
 +tokens with @code{TOK_} (@pxref{%define Summary,,api.tokens.prefix}).
  
  @comment file: calc++-parser.yy
  @example
 -%token        END      0 "end of file"
 -%token        ASSIGN     ":="
 -%token <sval> IDENTIFIER "identifier"
 -%token <ival> NUMBER     "number"
 -%type  <ival> exp
 +%define api.tokens.prefix "TOK_"
 +%token
 +  END  0  "end of file"
 +  ASSIGN  ":="
 +  MINUS   "-"
 +  PLUS    "+"
 +  STAR    "*"
 +  SLASH   "/"
 +  LPAREN  "("
 +  RPAREN  ")"
 +;
  @end example
  
  @noindent
 -To enable memory deallocation during error recovery, use
 -@code{%destructor}.
 +Since we use variant-based semantic values, @code{%union} is not used, and
 +both @code{%type} and @code{%token} expect genuine types, as opposed to type
 +tags.
  
 -@c FIXME: Document %printer, and mention that it takes a braced-code operand.
  @comment file: calc++-parser.yy
  @example
 -%printer    @{ yyoutput << *$$; @} "identifier"
 -%destructor @{ delete $$; @} "identifier"
 +%token <std::string> IDENTIFIER "identifier"
 +%token <int> NUMBER "number"
 +%type  <int> exp
 +@end example
 +
 +@noindent
 +No @code{%destructor} is needed to enable memory deallocation during error
 +recovery; the memory, for strings for instance, will be reclaimed by the
 +regular destructors.  All the values are printed using their
 +@code{operator<<}.
  
 -%printer    @{ yyoutput << $$; @} <ival>
 +@c FIXME: Document %printer, and mention that it takes a braced-code operand.
 +@comment file: calc++-parser.yy
 +@example
 +%printer @{ yyoutput << $$; @} <*>;
  @end example
  
  @noindent
 -The grammar itself is straightforward.
 +The grammar itself is straightforward (@pxref{Location Tracking Calc, ,
 +Location Tracking Calculator: @code{ltcalc}}).
  
  @comment file: calc++-parser.yy
  @example
@@@ -10259,18 -9685,17 +10259,18 @@@ assignments
  | assignments assignment @{@};
  
  assignment:
 -     "identifier" ":=" exp
 -       @{ driver.variables[*$1] = $3; delete $1; @};
 -
 -%left '+' '-';
 -%left '*' '/';
 -exp: exp '+' exp   @{ $$ = $1 + $3; @}
 -   | exp '-' exp   @{ $$ = $1 - $3; @}
 -   | exp '*' exp   @{ $$ = $1 * $3; @}
 -   | exp '/' exp   @{ $$ = $1 / $3; @}
 -   | "identifier"  @{ $$ = driver.variables[*$1]; delete $1; @}
 -   | "number"      @{ $$ = $1; @};
 +  "identifier" ":=" exp @{ driver.variables[$1] = $3; @};
 +
 +%left "+" "-";
 +%left "*" "/";
 +exp:
 +  exp "+" exp   @{ $$ = $1 + $3; @}
 +| exp "-" exp   @{ $$ = $1 - $3; @}
 +| exp "*" exp   @{ $$ = $1 * $3; @}
 +| exp "/" exp   @{ $$ = $1 / $3; @}
 +| "(" exp ")"   @{ std::swap ($$, $2); @}
 +| "identifier"  @{ $$ = driver.variables[$1]; @}
 +| "number"      @{ std::swap ($$, $1); @};
  %%
  @end example
  
@@@ -10281,7 -9706,7 +10281,7 @@@ driver
  @comment file: calc++-parser.yy
  @example
  void
 -yy::calcxx_parser::error (const yy::calcxx_parser::location_type& l,
 +yy::calcxx_parser::error (const location_type& l,
                            const std::string& m)
  @{
    driver.error (l, m);
@@@ -10297,22 -9722,24 +10297,22 @@@ parser's to get the set of defined toke
  @comment file: calc++-scanner.ll
  @example
  %@{ /* -*- C++ -*- */
 -# include <cstdlib>
  # include <cerrno>
  # include <climits>
 +# include <cstdlib>
  # include <string>
  # include "calc++-driver.hh"
  # include "calc++-parser.hh"
  
 -/* Work around an incompatibility in flex (at least versions
 -   2.5.31 through 2.5.33): it generates code that does
 -   not conform to C89.  See Debian bug 333231
 -   <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>.  */
 +// Work around an incompatibility in flex (at least versions
 +// 2.5.31 through 2.5.33): it generates code that does
 +// not conform to C89.  See Debian bug 333231
 +// <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>.
  # undef yywrap
  # define yywrap() 1
  
 -/* By default yylex returns int, we use token_type.
 -   Unfortunately yyterminate by default returns 0, which is
 -   not of token_type.  */
 -#define yyterminate() return token::END
 +// The location of the current token.
 +static yy::location loc;
  %@}
  @end example
  
  Because there is no @code{#include}-like feature we don't need
  @code{yywrap}, we don't need @code{unput} either, and we parse an
  actual file, this is not an interactive session with the user.
 -Finally we enable the scanner tracing features.
 +Finally, we enable scanner tracing.
  
  @comment file: calc++-scanner.ll
  @example
@@@ -10340,8 -9767,8 +10340,8 @@@ blank [ \t
  @noindent
  The following paragraph suffices to track locations accurately.  Each
  time @code{yylex} is invoked, the begin position is moved onto the end
 -position.  Then when a pattern is matched, the end position is
 -advanced of its width.  In case it matched ends of lines, the end
 +position.  Then when a pattern is matched, its width is added to the end
 +column.  When matching ends of lines, the end
  cursor is adjusted, and each time blanks are matched, the begin cursor
  is moved onto the end cursor to effectively ignore the blanks
  preceding tokens.  Comments would be treated equally.
  @example
  @group
  %@{
 -# define YY_USER_ACTION  yylloc->columns (yyleng);
 +  // Code run each time a pattern is matched.
 +  # define YY_USER_ACTION  loc.columns (yyleng);
  %@}
  @end group
  %%
 +@group
  %@{
 -  yylloc->step ();
 +  // Code run each time yylex is called.
 +  loc.step ();
  %@}
 -@{blank@}+   yylloc->step ();
 -[\n]+      yylloc->lines (yyleng); yylloc->step ();
 +@end group
 +@{blank@}+   loc.step ();
 +[\n]+      loc.lines (yyleng); loc.step ();
  @end example
  
  @noindent
 -The rules are simple, just note the use of the driver to report errors.
 -It is convenient to use a typedef to shorten
 -@code{yy::calcxx_parser::token::identifier} into
 -@code{token::identifier} for instance.
 +The rules are simple.  The driver is used to report errors.
  
  @comment file: calc++-scanner.ll
  @example
 -%@{
 -  typedef yy::calcxx_parser::token token;
 -%@}
 -           /* Convert ints to the actual type of tokens.  */
 -[-+*/]     return yy::calcxx_parser::token_type (yytext[0]);
 -":="       return token::ASSIGN;
 +"-"      return yy::calcxx_parser::make_MINUS(loc);
 +"+"      return yy::calcxx_parser::make_PLUS(loc);
 +"*"      return yy::calcxx_parser::make_STAR(loc);
 +"/"      return yy::calcxx_parser::make_SLASH(loc);
 +"("      return yy::calcxx_parser::make_LPAREN(loc);
 +")"      return yy::calcxx_parser::make_RPAREN(loc);
 +":="     return yy::calcxx_parser::make_ASSIGN(loc);
 +
 +@group
  @{int@}      @{
    errno = 0;
    long n = strtol (yytext, NULL, 10);
    if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
 -    driver.error (*yylloc, "integer is out of range");
 -  yylval->ival = n;
 -  return token::NUMBER;
 +    driver.error (loc, "integer is out of range");
 +  return yy::calcxx_parser::make_NUMBER(n, loc);
  @}
 -@{id@}       yylval->sval = new std::string (yytext); return token::IDENTIFIER;
 -.          driver.error (*yylloc, "invalid character");
 +@end group
 +@{id@}       return yy::calcxx_parser::make_IDENTIFIER(yytext, loc);
 +.          driver.error (loc, "invalid character");
 +<<EOF>>    return yy::calcxx_parser::make_END(loc);
  %%
  @end example
  
  @noindent
 -Finally, because the scanner related driver's member function depend
 +Finally, because the scanner-related driver's member-functions depend
  on the scanner's data, it is simpler to implement them in this file.
  
  @comment file: calc++-scanner.ll
@@@ -10437,7 -9859,6 +10437,7 @@@ The top level file, @file{calc++.cc}, p
  int
  main (int argc, char *argv[])
  @{
 +  int res = 0;
    calcxx_driver driver;
    for (int i = 1; i < argc; ++i)
      if (argv[i] == std::string ("-p"))
        driver.trace_scanning = true;
      else if (!driver.parse (argv[i]))
        std::cout << driver.result << std::endl;
 +    else
 +      res = 1;
 +  return res;
  @}
  @end group
  @end example
@@@ -10493,7 -9911,7 +10493,7 @@@ You can create documentation for genera
  Contrary to C parsers, Java parsers do not use global variables; the
  state of the parser is always local to an instance of the parser class.
  Therefore, all Java parsers are ``pure'', and the @code{%pure-parser}
 -and @code{%define api.pure} directives does not do anything when used in
 +and @samp{%define api.pure} directives does not do anything when used in
  Java.
  
  Push parsers are currently unsupported in Java and @code{%define
@@@ -10506,23 -9924,15 +10506,23 @@@ No header file can be generated for Jav
  @code{%defines} directive or the @option{-d}/@option{--defines} options.
  
  @c FIXME: Possible code change.
 -Currently, support for debugging and verbose errors are always compiled
 -in.  Thus the @code{%debug} and @code{%token-table} directives and the
 +Currently, support for tracing is always compiled
 +in.  Thus the @samp{%define parse.trace} and @samp{%token-table}
 +directives and the
  @option{-t}/@option{--debug} and @option{-k}/@option{--token-table}
  options have no effect.  This may change in the future to eliminate
 -unused code in the generated parser, so use @code{%debug} and
 -@code{%verbose-error} explicitly if needed.  Also, in the future the
 +unused code in the generated parser, so use @samp{%define parse.trace}
 +explicitly
 +if needed.  Also, in the future the
  @code{%token-table} directive might enable a public interface to
  access the token names and codes.
  
 +Getting a ``code too large'' error from the Java compiler means the code
 +hit the 64KB bytecode per method limitation of the Java class file.
 +Try reducing the amount of code in actions and static initializers;
 +otherwise, report a bug so that the parser skeleton will be improved.
 +
 +
  @node Java Semantic Values
  @subsection Java Semantic Values
  @c - No %union, specify type in %type/%token.
@@@ -10541,7 -9951,7 +10541,7 @@@ semantic values' types (class names) sh
  By default, the semantic stack is declared to have @code{Object} members,
  which means that the class types you specify can be of any class.
  To improve the type safety of the parser, you can declare the common
 -superclass of all the semantic values using the @code{%define stype}
 +superclass of all the semantic values using the @samp{%define stype}
  directive.  For example, after the following declaration:
  
  @example
@@@ -10580,11 -9990,11 +10580,11 @@@ class defines a @dfn{position}, a singl
  defines a class representing a @dfn{location}, a range composed of a pair of
  positions (possibly spanning several files).  The location class is an inner
  class of the parser; the name is @code{Location} by default, and may also be
 -renamed using @code{%define location_type "@var{class-name}"}.
 +renamed using @samp{%define location_type "@var{class-name}"}.
  
  The location class treats the position as a completely opaque value.
  By default, the class name is @code{Position}, but this can be changed
 -with @code{%define position_type "@var{class-name}"}.  This class must
 +with @samp{%define position_type "@var{class-name}"}.  This class must
  be supplied by the user.
  
  
@@@ -10619,22 -10029,20 +10619,22 @@@ properly, the position class should ove
  The name of the generated parser class defaults to @code{YYParser}.  The
  @code{YY} prefix may be changed using the @code{%name-prefix} directive
  or the @option{-p}/@option{--name-prefix} option.  Alternatively, use
 -@code{%define parser_class_name "@var{name}"} to give a custom name to
 +@samp{%define parser_class_name "@var{name}"} to give a custom name to
  the class.  The interface of this class is detailed below.
  
  By default, the parser class has package visibility.  A declaration
 -@code{%define public} will change to public visibility.  Remember that,
 +@samp{%define public} will change to public visibility.  Remember that,
  according to the Java language specification, the name of the @file{.java}
  file should match the name of the class in this case.  Similarly, you can
  use @code{abstract}, @code{final} and @code{strictfp} with the
  @code{%define} declaration to add other modifiers to the parser class.
 +A single @samp{%define annotations "@var{annotations}"} directive can
 +be used to add any number of annotations to the parser class.
  
  The Java package name of the parser class can be specified using the
 -@code{%define package} directive.  The superclass and the implemented
 +@samp{%define package} directive.  The superclass and the implemented
  interfaces of the parser class can be specified with the @code{%define
 -extends} and @code{%define implements} directives.
 +extends} and @samp{%define implements} directives.
  
  The parser class defines an inner class, @code{Location}, that is used
  for location tracking (see @ref{Java Location Values}), and a inner
@@@ -10643,33 -10051,30 +10643,33 @@@ these inner class/interface, and the me
  below, all the other members and fields are preceded with a @code{yy} or
  @code{YY} prefix to avoid clashes with user code.
  
 -@c FIXME: The following constants and variables are still undocumented:
 -@c @code{bisonVersion}, @code{bisonSkeleton} and @code{errorVerbose}.
 -
  The parser class can be extended using the @code{%parse-param}
  directive. Each occurrence of the directive will add a @code{protected
  final} field to the parser class, and an argument to its constructor,
  which initialize them automatically.
  
 -Token names defined by @code{%token} and the predefined @code{EOF} token
 -name are added as constant fields to the parser class.
 -
  @deftypeop {Constructor} {YYParser} {} YYParser (@var{lex_param}, @dots{}, @var{parse_param}, @dots{})
  Build a new parser object with embedded @code{%code lexer}.  There are
 -no parameters, unless @code{%parse-param}s and/or @code{%lex-param}s are
 -used.
 +no parameters, unless @code{%param}s and/or @code{%parse-param}s and/or
 +@code{%lex-param}s are used.
 +
 +Use @code{%code init} for code added to the start of the constructor
 +body. This is especially useful to initialize superclasses. Use
 +@samp{%define init_throws} to specify any uncaught exceptions.
  @end deftypeop
  
  @deftypeop {Constructor} {YYParser} {} YYParser (Lexer @var{lexer}, @var{parse_param}, @dots{})
  Build a new parser object using the specified scanner.  There are no
 -additional parameters unless @code{%parse-param}s are used.
 +additional parameters unless @code{%param}s and/or @code{%parse-param}s are
 +used.
  
  If the scanner is defined by @code{%code lexer}, this constructor is
  declared @code{protected} and is called automatically with a scanner
 -created with the correct @code{%lex-param}s.
 +created with the correct @code{%param}s and/or @code{%lex-param}s.
 +
 +Use @code{%code init} for code added to the start of the constructor
 +body. This is especially useful to initialize superclasses. Use
 +@samp{%define init_throws} to specify any uncaught exceptions.
  @end deftypeop
  
  @deftypemethod {YYParser} {boolean} parse ()
@@@ -10677,21 -10082,6 +10677,21 @@@ Run the syntactic analysis, and return 
  @code{false} otherwise.
  @end deftypemethod
  
 +@deftypemethod {YYParser} {boolean} getErrorVerbose ()
 +@deftypemethodx {YYParser} {void} setErrorVerbose (boolean @var{verbose})
 +Get or set the option to produce verbose error messages.  These are only
 +available with @samp{%define parse.error verbose}, which also turns on
 +verbose error messages.
 +@end deftypemethod
 +
 +@deftypemethod {YYParser} {void} yyerror (String @var{msg})
 +@deftypemethodx {YYParser} {void} yyerror (Position @var{pos}, String @var{msg})
 +@deftypemethodx {YYParser} {void} yyerror (Location @var{loc}, String @var{msg})
 +Print an error message using the @code{yyerror} method of the scanner
 +instance in use. The @code{Location} and @code{Position} parameters are
 +available only if location tracking is active.
 +@end deftypemethod
 +
  @deftypemethod {YYParser} {boolean} recovering ()
  During the syntactic analysis, return @code{true} if recovering
  from a syntax error.
@@@ -10710,11 -10100,6 +10710,11 @@@ Get or set the tracing level.  Currentl
  or nonzero, full tracing.
  @end deftypemethod
  
 +@deftypecv {Constant} {YYParser} {String} {bisonVersion}
 +@deftypecvx {Constant} {YYParser} {String} {bisonSkeleton}
 +Identify the Bison version and skeleton used to generate this parser.
 +@end deftypecv
 +
  
  @node Java Scanner Interface
  @subsection Java Scanner Interface
  There are two possible ways to interface a Bison-generated Java parser
  with a scanner: the scanner may be defined by @code{%code lexer}, or
  defined elsewhere.  In either case, the scanner has to implement the
 -@code{Lexer} inner interface of the parser class.
 +@code{Lexer} inner interface of the parser class.  This interface also
 +contain constants for all user-defined token names and the predefined
 +@code{EOF} token.
  
  In the first case, the body of the scanner class is placed in
  @code{%code lexer} blocks.  If you want to pass parameters from the
@@@ -10746,7 -10129,7 +10746,7 @@@ In both cases, the scanner has to imple
  @deftypemethod {Lexer} {void} yyerror (Location @var{loc}, String @var{msg})
  This method is defined by the user to emit an error message.  The first
  parameter is omitted if location tracking is not active.  Its type can be
 -changed using @code{%define location_type "@var{class-name}".}
 +changed using @samp{%define location_type "@var{class-name}".}
  @end deftypemethod
  
  @deftypemethod {Lexer} {int} yylex ()
@@@ -10754,7 -10137,7 +10754,7 @@@ Return the next token.  Its type is th
  value and location are saved and returned by the their methods in the
  interface.
  
 -Use @code{%define lex_throws} to specify any uncaught exceptions.
 +Use @samp{%define lex_throws} to specify any uncaught exceptions.
  Default is @code{java.io.IOException}.
  @end deftypemethod
  
@@@ -10764,14 -10147,14 +10764,14 @@@ Return respectively the first position 
  @code{yylex} returned, and the first position beyond it.  These
  methods are not needed unless location tracking is active.
  
 -The return type can be changed using @code{%define position_type
 +The return type can be changed using @samp{%define position_type
  "@var{class-name}".}
  @end deftypemethod
  
  @deftypemethod {Lexer} {Object} getLVal ()
  Return the semantic value of the last token that yylex returned.
  
 -The return type can be changed using @code{%define stype
 +The return type can be changed using @samp{%define stype
  "@var{class-name}".}
  @end deftypemethod
  
  The following special constructs can be uses in Java actions.
  Other analogous C action features are currently unavailable for Java.
  
 -Use @code{%define throws} to specify any uncaught exceptions from parser
 +Use @samp{%define throws} to specify any uncaught exceptions from parser
  actions, and initial actions specified by @code{%initial-action}.
  
  @defvar $@var{n}
@@@ -10799,7 -10182,7 +10799,7 @@@ Like @code{$@var{n}} but specifies a al
  @defvar $$
  The semantic value for the grouping made by the current rule.  As a
  value, this is in the base type (@code{Object} or as specified by
 -@code{%define stype}) as in not cast to the declared subtype because
 +@samp{%define stype}) as in not cast to the declared subtype because
  casts are not allowed on the left-hand side of Java assignments.
  Use an explicit Java cast if the correct subtype is needed.
  @xref{Java Semantic Values}.
@@@ -10846,12 -10229,11 +10846,12 @@@ operation
  @xref{Error Recovery}.
  @end deftypefn
  
 -@deftypefn  {Function} {protected void} yyerror (String msg)
 -@deftypefnx {Function} {protected void} yyerror (Position pos, String msg)
 -@deftypefnx {Function} {protected void} yyerror (Location loc, String msg)
 +@deftypefn  {Function} {void} yyerror (String @var{msg})
 +@deftypefnx {Function} {void} yyerror (Position @var{loc}, String @var{msg})
 +@deftypefnx {Function} {void} yyerror (Location @var{loc}, String @var{msg})
  Print an error message using the @code{yyerror} method of the scanner
 -instance in use.
 +instance in use. The @code{Location} and @code{Position} parameters are
 +available only if location tracking is active.
  @end deftypefn
  
  
@@@ -10895,7 -10277,7 +10895,7 @@@ The prologue declarations have a differ
  @item @code{%code imports}
  blocks are placed at the beginning of the Java source code.  They may
  include copyright notices.  For a @code{package} declarations, it is
 -suggested to use @code{%define package} instead.
 +suggested to use @samp{%define package} instead.
  
  @item unqualified @code{%code}
  blocks are placed inside the parser class.
@@@ -10936,7 -10318,7 +10936,7 @@@ constructor that @emph{creates} a lexer
  
  @deffn {Directive} %name-prefix "@var{prefix}"
  The prefix of the parser class name @code{@var{prefix}Parser} if
 -@code{%define parser_class_name} is not used.  Default is @code{YY}.
 +@samp{%define parser_class_name} is not used.  Default is @code{YY}.
  @xref{Java Bison Interface}.
  @end deffn
  
@@@ -10967,11 -10349,6 +10967,11 @@@ Code inserted just after the @code{pack
  @xref{Java Differences}.
  @end deffn
  
 +@deffn {Directive} {%code init} @{ @var{code} @dots{} @}
 +Code inserted at the beginning of the parser constructor body.
 +@xref{Java Parser Interface}.
 +@end deffn
 +
  @deffn {Directive} {%code lexer} @{ @var{code} @dots{} @}
  Code added to the body of a inner lexer class within the parser class.
  @xref{Java Scanner Interface}.
@@@ -10984,7 -10361,7 +10984,7 @@@ Code (after the second @code{%%}) appen
  @end deffn
  
  @deffn {Directive} %@{ @var{code} @dots{} %@}
 -Not supported.  Use @code{%code import} instead.
 +Not supported.  Use @code{%code imports} instead.
  @xref{Java Differences}.
  @end deffn
  
@@@ -10993,11 -10370,6 +10993,11 @@@ Whether the parser class is declared @c
  @xref{Java Bison Interface}.
  @end deffn
  
 +@deffn {Directive} {%define annotations} "@var{annotations}"
 +The Java annotations for the parser class.  Default is none.
 +@xref{Java Bison Interface}.
 +@end deffn
 +
  @deffn {Directive} {%define extends} "@var{superclass}"
  The superclass of the parser class.  Default is none.
  @xref{Java Bison Interface}.
@@@ -11014,12 -10386,6 +11014,12 @@@ Default is none
  @xref{Java Bison Interface}.
  @end deffn
  
 +@deffn {Directive} {%define init_throws} "@var{exceptions}"
 +The exceptions thrown by @code{%code init} from the parser class
 +constructor.  Default is none.
 +@xref{Java Parser Interface}.
 +@end deffn
 +
  @deffn {Directive} {%define lex_throws} "@var{exceptions}"
  The exceptions thrown by the @code{yylex} method of the lexer, a
  comma-separated list.  Default is @code{java.io.IOException}.
@@@ -11105,8 -10471,8 +11105,8 @@@ My parser returns with error with a @sa
  message.  What can I do?
  @end quotation
  
- This question is already addressed elsewhere, @xref{Recursion,
,Recursive Rules}.
+ This question is already addressed elsewhere, see @ref{Recursion, ,Recursive
+ Rules}.
  
  @node How Can I Reset the Parser
  @section How Can I Reset the Parser
@@@ -11537,19 -10903,6 +11537,19 @@@ the grammar file.  @xref{Grammar Outlin
  Grammar}.
  @end deffn
  
 +@deffn {Directive} %?@{@var{expression}@}
 +Predicate actions.  This is a type of action clause that may appear in
 +rules. The expression is evaluated, and if false, causes a syntax error.  In
 +GLR parsers during nondeterministic operation,
 +this silently causes an alternative parse to die.  During deterministic
 +operation, it is the same as the effect of YYERROR.
 +@xref{Semantic Predicates}.
 +
 +This feature is experimental.
 +More user feedback will help to determine whether it should become a permanent
 +feature.
 +@end deffn
 +
  @deffn {Construct} /*@dots{}*/
  Comment delimiters, as in C.
  @end deffn
@@@ -11659,8 -11012,8 +11659,8 @@@ token is reset to the token that origin
  @end deffn
  
  @deffn {Directive} %error-verbose
 -Bison declaration to request verbose, specific error message strings
 -when @code{yyerror} is called.  @xref{Error Reporting}.
 +An obsolete directive standing for @samp{%define parse.error verbose}
 +(@pxref{Error Reporting, ,The Error Reporting Function @code{yyerror}}).
  @end deffn
  
  @deffn {Directive} %file-prefix "@var{prefix}"
@@@ -11683,12 -11036,12 +11683,12 @@@ Specify the programming language for th
  @end deffn
  
  @deffn {Directive} %left
 -Bison declaration to assign left associativity to token(s).
 +Bison declaration to assign precedence and left associativity to token(s).
  @xref{Precedence Decl, ,Operator Precedence}.
  @end deffn
  
 -@deffn {Directive} %lex-param @{@var{argument-declaration}@}
 -Bison declaration to specifying an additional parameter that
 +@deffn {Directive} %lex-param @{@var{argument-declaration}@} @dots{}
 +Bison declaration to specifying additional arguments that
  @code{yylex} should accept.  @xref{Pure Calling,, Calling Conventions
  for Pure Parsers}.
  @end deffn
@@@ -11718,7 -11071,7 +11718,7 @@@ parser implementation file.  @xref{Dec
  @end deffn
  
  @deffn {Directive} %nonassoc
 -Bison declaration to assign nonassociativity to token(s).
 +Bison declaration to assign precedence and nonassociativity to token(s).
  @xref{Precedence Decl, ,Operator Precedence}.
  @end deffn
  
@@@ -11727,15 -11080,10 +11727,15 @@@ Bison declaration to set the name of th
  @xref{Decl Summary}.
  @end deffn
  
 -@deffn {Directive} %parse-param @{@var{argument-declaration}@}
 -Bison declaration to specifying an additional parameter that
 -@code{yyparse} should accept.  @xref{Parser Function,, The Parser
 -Function @code{yyparse}}.
 +@deffn {Directive} %param @{@var{argument-declaration}@} @dots{}
 +Bison declaration to specify additional arguments that both
 +@code{yylex} and @code{yyparse} should accept.  @xref{Parser Function,, The
 +Parser Function @code{yyparse}}.
 +@end deffn
 +
 +@deffn {Directive} %parse-param @{@var{argument-declaration}@} @dots{}
 +Bison declaration to specify additional arguments that @code{yyparse}
 +should accept.  @xref{Parser Function,, The Parser Function @code{yyparse}}.
  @end deffn
  
  @deffn {Directive} %prec
@@@ -11743,13 -11091,8 +11743,13 @@@ Bison declaration to assign a precedenc
  @xref{Contextual Precedence, ,Context-Dependent Precedence}.
  @end deffn
  
 +@deffn {Directive} %precedence
 +Bison declaration to assign precedence to token(s), but no associativity
 +@xref{Precedence Decl, ,Operator Precedence}.
 +@end deffn
 +
  @deffn {Directive} %pure-parser
 -Deprecated version of @code{%define api.pure} (@pxref{%define
 +Deprecated version of @samp{%define api.pure} (@pxref{%define
  Summary,,api.pure}), for which Bison is more careful to warn about
  unreasonable usage.
  @end deffn
@@@ -11760,7 -11103,7 +11760,7 @@@ Require a Version of Bison}
  @end deffn
  
  @deffn {Directive} %right
 -Bison declaration to assign right associativity to token(s).
 +Bison declaration to assign precedence and right associativity to token(s).
  @xref{Precedence Decl, ,Operator Precedence}.
  @end deffn
  
@@@ -11865,16 -11208,16 +11865,16 @@@ instead
  
  @deffn {Function} yyerror
  User-supplied function to be called by @code{yyparse} on error.
 -@xref{Error Reporting, ,The Error
 -Reporting Function @code{yyerror}}.
 +@xref{Error Reporting, ,The Error Reporting Function @code{yyerror}}.
  @end deffn
  
  @deffn {Macro} YYERROR_VERBOSE
 -An obsolete macro that you define with @code{#define} in the prologue
 -to request verbose, specific error message strings
 -when @code{yyerror} is called.  It doesn't matter what definition you
 -use for @code{YYERROR_VERBOSE}, just whether you define it.  Using
 -@code{%error-verbose} is preferred.  @xref{Error Reporting}.
 +An obsolete macro used in the @file{yacc.c} skeleton, that you define
 +with @code{#define} in the prologue to request verbose, specific error
 +message strings when @code{yyerror} is called.  It doesn't matter what
 +definition you use for @code{YYERROR_VERBOSE}, just whether you define
 +it.  Using @samp{%define parse.error verbose} is preferred
 +(@pxref{Error Reporting, ,The Error Reporting Function @code{yyerror}}).
  @end deffn
  
  @deffn {Macro} YYFPRINTF
diff --combined m4/.gitignore
index 90e5ae15f760377d57d49e8fb11caedcb13f8bc6,d47aee025bfdb4aa01bbfbb705f8276f9163abbb..990b1a57ff71a4e7f760b96fabed58b302b554b4
@@@ -38,6 -38,7 +38,7 @@@
  /getdtablesize.m4
  /getopt.m4
  /gettext.m4
+ /glibc2.m4
  /glibc21.m4
  /gnulib-cache.m4
  /gnulib-common.m4
  /iconv.m4
  /include_next.m4
  /inline.m4
+ /intdiv0.m4
+ /intl.m4
++/intl.m4~
+ /intldir.m4
  /intlmacosx.m4
+ /intmax.m4
  /intmax_t.m4
  /inttypes-pri.m4
  /inttypes.m4
@@@ -61,6 -66,7 +67,7 @@@
  /javacomp.m4
  /javaexec.m4
  /largefile.m4
+ /lcmessage.m4
  /ldexp.m4
  /ldexpl.m4
  /lib-ld.m4
@@@ -71,6 -77,7 +78,7 @@@
  /locale-fr.m4
  /locale-ja.m4
  /locale-zh.m4
+ /lock.m4
  /longlong.m4
  /malloc.m4
  /math_h.m4
  /multiarch.m4
  /nls.m4
  /nocrash.m4
++/off_t.m4
  /open.m4
  /pathmax.m4
  /perror.m4
- /pipe.m4
  /pipe2.m4
  /po.m4
++/po.m4~
  /posix_spawn.m4
  /printf-frexp.m4
  /printf-frexpl.m4
  /sys_ioctl_h.m4
  /sys_socket_h.m4
  /sys_stat_h.m4
++/sys_types_h.m4
  /sys_wait_h.m4
+ /sysexits.m4
  /threadlib.m4
  /time_h.m4
+ /uintmax_t.m4
  /unistd-safer.m4
  /unistd_h.m4
  /unlocked-io.m4
  /vasnprintf.m4
  /vfprintf-posix.m4
+ /visibility.m4
  /vsnprintf-posix.m4
  /vsnprintf.m4
  /vsprintf-posix.m4
  /xalloc.m4
  /xsize.m4
  /xstrndup.m4
- /sysexits.m4
 -/off_t.m4
 -/sys_types_h.m4
diff --combined po/.gitignore
index 79594c04304c4a8b5f5545c7fdd7b3302fccbd77,79594c04304c4a8b5f5545c7fdd7b3302fccbd77..940ce9efe690d672f6cb2b0432d62df006ae5f45
@@@ -6,6 -6,6 +6,7 @@@
  /Makefile
  /Makefile.in
  /Makefile.in.in
++/Makefile.in.in~
  /Makevars
  /Makevars.template
  /POTFILES
diff --combined runtime-po/.gitignore
index 44ff89631ff95a91c769e6eb4bd7f8d72a90ef14,44ff89631ff95a91c769e6eb4bd7f8d72a90ef14..8675428f03af08d946bf95ad25b0e53daf2f6d9c
@@@ -6,6 -6,6 +6,7 @@@
  /Makefile
  /Makefile.in
  /Makefile.in.in
++/Makefile.in.in~
  /Makevars
  /Makevars.template
  /POTFILES
diff --combined src/flex-scanner.h
index 572464afa469b29960e35ebf5136ffa6b597ecda,997984117848430a48d54896ba8999f64b11f9a3..cf2b6b9eb8ec78c1a1ac30f181aa1d6ecb630833
  # error "FLEX_PREFIX not defined"
  #endif
  
+ /* Whether this version of Flex is (strictly) greater than
+    Major.Minor.Subminor.  */
+ #define FLEX_VERSION_GT(Major, Minor, Subminor)                         \
+   (defined YY_FLEX_MAJOR_VERSION                                        \
+    && (Major < YY_FLEX_MAJOR_VERSION                                    \
+        || (Major == YY_FLEX_MAJOR_VERSION                               \
+            && (defined YY_FLEX_MINOR_VERSION                            \
+                && (Minor < YY_FLEX_MINOR_VERSION                        \
+                    || (Minor == YY_FLEX_MINOR_VERSION                   \
+                        && defined YY_FLEX_SUBMINOR_VERSION              \
+                        && Subminor < YY_FLEX_SUBMINOR_VERSION))))))
  /* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used.  */
 -# if ! FLEX_VERSION_GT (2, 5, 31)
++#if ! FLEX_VERSION_GT (2, 5, 31)
  int   FLEX_PREFIX (get_lineno) (void);
  FILE *FLEX_PREFIX (get_in) (void);
  FILE *FLEX_PREFIX (get_out) (void);
@@@ -33,6 -46,7 +46,7 @@@ void  FLEX_PREFIX (set_out) (FILE *)
  int   FLEX_PREFIX (get_debug) (void);
  void  FLEX_PREFIX (set_debug) (int);
  int   FLEX_PREFIX (lex_destroy) (void);
+ #endif
  
  #define last_string    FLEX_PREFIX (last_string)
  
     versions according to the Flex manual) leak memory if yylex_destroy is not
     invoked.  However, yylex_destroy is not defined before Flex 2.5.9, so give
     an implementation here that at least appears to work with Flex 2.5.4.  */
- #if !defined YY_FLEX_MAJOR_VERSION || YY_FLEX_MAJOR_VERSION < 2 \
-     || (YY_FLEX_MAJOR_VERSION == 2 \
-         && (!defined YY_FLEX_MINOR_VERSION || YY_FLEX_MINOR_VERSION < 5 \
-             || (YY_FLEX_MINOR_VERSION == 5 \
-                 && (!defined YY_FLEX_SUBMINOR_VERSION \
-                     || YY_FLEX_SUBMINOR_VERSION < 9))))
+ #if ! FLEX_VERSION_GT (2, 5, 9)
  # define yylex_destroy() yy_delete_buffer (YY_CURRENT_BUFFER)
  #endif
  
  
  static struct obstack obstack_for_string;
  
- #define STRING_GROW   \
 -# define STRING_GROW   \
++# define STRING_GROW                                    \
    obstack_grow (&obstack_for_string, yytext, yyleng)
  
- #define STRING_FINISH                                   \
 -# define STRING_FINISH                                        \
 -  do {                                                        \
 -    obstack_1grow (&obstack_for_string, '\0');                \
 -    last_string = obstack_finish (&obstack_for_string);       \
++# define STRING_FINISH                                  \
 +  do {                                                  \
 +    obstack_1grow (&obstack_for_string, '\0');          \
 +    last_string = obstack_finish (&obstack_for_string); \
    } while (0)
  
- #define STRING_FREE \
 -# define STRING_FREE \
++# define STRING_FREE                                    \
    obstack_free (&obstack_for_string, last_string)
  
  #endif
diff --combined src/getargs.c
index 06e6e972be3ee13f26970fadac923dec92534e94,3fa2a7af25c816f3a4bc3141e6416166d1d736de..8a3714e23f6995dfbb66ae7092f42228b68c4e6b
  #include "quote.h"
  #include "uniqstr.h"
  
 -bool debug_flag;
  bool defines_flag;
  bool graph_flag;
  bool xml_flag;
 -bool locations_flag;
  bool no_lines_flag;
  bool token_table_flag;
 -bool yacc_flag;       /* for -y */
 -
 -bool error_verbose = false;
 +bool yacc_flag; /* for -y */
  
  bool nondeterministic_parser = false;
  bool glr_parser = false;
@@@ -94,32 -98,32 +94,32 @@@ const char *include = NULL
   */
  static void
  flags_argmatch (const char *option,
 -              const char * const keys[], const int values[],
 -              int all, int *flags, char *args)
 +                const char * const keys[], const int values[],
 +                int all, int *flags, char *args)
  {
    if (args)
      {
        args = strtok (args, ",");
        while (args)
 -      {
 -        int no = strncmp (args, "no-", 3) == 0 ? 3 : 0;
 -        int value = XARGMATCH (option, args + no, keys, values);
 -        if (value == 0)
 -          {
 -            if (no)
 -              *flags |= all;
 -            else
 -              *flags &= ~all;
 -          }
 -        else
 -          {
 -            if (no)
 -              *flags &= ~value;
 -            else
 -              *flags |= value;
 -          }
 -        args = strtok (NULL, ",");
 -      }
 +        {
 +          int no = STRPREFIX_LIT ("no-", args) ? 3 : 0;
 +          int value = XARGMATCH (option, args + no, keys, values);
 +          if (value == 0)
 +            {
 +              if (no)
 +                *flags |= all;
 +              else
 +                *flags &= ~all;
 +            }
 +          else
 +            {
 +              if (no)
 +                *flags &= ~value;
 +              else
 +                *flags |= value;
 +            }
 +          args = strtok (NULL, ",");
 +        }
      }
    else
      *flags |= all;
   *  \arg FlagName_all    the all value.
   *  \arg FlagName_flag   the flag to update.
   */
 -#define FLAGS_ARGMATCH(FlagName, Args)                                        \
 +#define FLAGS_ARGMATCH(FlagName, Args)                                  \
    flags_argmatch ("--" #FlagName, FlagName ## _args, FlagName ## _types, \
 -                FlagName ## _all, &FlagName ## _flag, Args)
 +                  FlagName ## _all, &FlagName ## _flag, Args)
  
  
  /*----------------------.
@@@ -265,13 -269,13 +265,13 @@@ usage (int status
  {
    if (status != 0)
      fprintf (stderr, _("Try `%s --help' for more information.\n"),
 -           program_name);
 +             program_name);
    else
      {
        /* For ../build-aux/cross-options.pl to work, use the format:
 -              ^  -S, --long[=ARGS] (whitespace)
 -       A --long option is required.
 -       Otherwise, add exceptions to ../build-aux/cross-options.pl.  */
 +                ^  -S, --long[=ARGS] (whitespace)
 +         A --long option is required.
 +         Otherwise, add exceptions to ../build-aux/cross-options.pl.  */
  
        printf (_("Usage: %s [OPTION]... FILE\n"), program_name);
        fputs (_("\
@@@ -305,8 -309,7 +305,8 @@@ Parser:\n
    -L, --language=LANGUAGE          specify the output programming language\n\
                                     (this is an experimental feature)\n\
    -S, --skeleton=FILE              specify the skeleton to use\n\
 -  -t, --debug                      instrument the parser for debugging\n\
 +  -t, --debug                      instrument the parser for tracing\n\
 +                                   same as `-Dparse.trace'\n\
        --locations                  enable location support\n\
    -D, --define=NAME[=VALUE]        similar to `%define NAME \"VALUE\"'\n\
    -F, --force-define=NAME[=VALUE]  override `%define NAME \"VALUE\"'\n\
@@@ -379,14 -382,14 +379,14 @@@ version (void
    putc ('\n', stdout);
  
    fprintf (stdout,
 -         _("Copyright (C) %d Free Software Foundation, Inc.\n"),
 -         PACKAGE_COPYRIGHT_YEAR);
 +           _("Copyright (C) %d Free Software Foundation, Inc.\n"),
 +           PACKAGE_COPYRIGHT_YEAR);
  
    fputs (_("\
  This is free software; see the source for copying conditions.  There is NO\n\
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
  "),
 -       stdout);
 +         stdout);
  }
  
  
@@@ -474,25 -477,25 +474,25 @@@ enu
  static struct option const long_options[] =
  {
    /* Operation modes. */
 -  { "help",            no_argument,     0,   'h' },
 -  { "version",         no_argument,     0,   'V' },
 -  { "print-localedir", no_argument,     0,   PRINT_LOCALEDIR_OPTION },
 -  { "print-datadir",   no_argument,     0,   PRINT_DATADIR_OPTION   },
 +  { "help",            no_argument,       0,   'h' },
 +  { "version",         no_argument,       0,   'V' },
 +  { "print-localedir", no_argument,       0,   PRINT_LOCALEDIR_OPTION },
 +  { "print-datadir",   no_argument,       0,   PRINT_DATADIR_OPTION   },
    { "warnings",        optional_argument, 0,   'W' },
  
    /* Parser. */
 -  { "name-prefix",   required_argument,         0,   'p' },
 +  { "name-prefix",   required_argument,   0,   'p' },
    { "include",       required_argument,   0,   'I' },
  
    /* Output. */
 -  { "file-prefix", required_argument, 0,   'b' },
 -  { "output",    required_argument,   0,   'o' },
 -  { "output-file", required_argument, 0,   'o' },
 -  { "graph",     optional_argument,   0,   'g' },
 +  { "file-prefix", required_argument,   0,   'b' },
 +  { "output",      required_argument,   0,   'o' },
 +  { "output-file", required_argument,   0,   'o' },
 +  { "graph",       optional_argument,   0,   'g' },
    { "xml",         optional_argument,   0,   'x' },
 -  { "report",    required_argument,   0,   'r' },
 +  { "report",      required_argument,   0,   'r' },
    { "report-file", required_argument,   0,   REPORT_FILE_OPTION },
 -  { "verbose",           no_argument,         0,   'v' },
 +  { "verbose",     no_argument,         0,   'v' },
  
    /* Hidden. */
    { "trace",         optional_argument,   0,     'T' },
  
    /* Operation modes.  */
    { "fixed-output-files", no_argument,  0,   'y' },
 -  { "yacc",             no_argument,  0,   'y' },
 +  { "yacc",               no_argument,  0,   'y' },
  
    /* Parser.  */
 -  { "debug",        no_argument,               0,   't' },
 -  { "define",       required_argument,         0,   'D' },
 +  { "debug",          no_argument,               0,   't' },
 +  { "define",         required_argument,         0,   'D' },
    { "force-define",   required_argument,         0,   'F' },
 -  { "locations",      no_argument,             0, LOCATIONS_OPTION },
 +  { "locations",      no_argument,               0, LOCATIONS_OPTION },
    { "no-lines",       no_argument,               0,   'l' },
    { "raw",            no_argument,               0,     0 },
    { "skeleton",       required_argument,         0,   'S' },
@@@ -545,15 -548,15 +545,15 @@@ getargs (int argc, char *argv[]
    int c;
  
    while ((c = getopt_long (argc, argv, short_options, long_options, NULL))
 -       != -1)
 +         != -1)
      switch (c)
        {
          /* ASCII Sorting for short options (i.e., upper case then
             lower case), and then long-only options.  */
  
        case 0:
 -      /* Certain long options cause getopt_long to return 0.  */
 -      break;
 +        /* Certain long options cause getopt_long to return 0.  */
 +        break;
  
        case 'D': /* -DNAME[=VALUE]. */
        case 'F': /* -FNAME[=VALUE]. */
                                          c == 'D' ? MUSCLE_PERCENT_DEFINE_D
                                                   : MUSCLE_PERCENT_DEFINE_F);
          }
 -      break;
 +        break;
  
        case 'I':
 -      include = AS_FILE_NAME (optarg);
 -      break;
 +        include = AS_FILE_NAME (optarg);
 +        break;
  
        case 'L':
 -      language_argmatch (optarg, command_line_prio,
 -                         command_line_location ());
 -      break;
 +        language_argmatch (optarg, command_line_prio,
 +                           command_line_location ());
 +        break;
  
        case 'S':
 -      skeleton_arg (AS_FILE_NAME (optarg), command_line_prio,
 -                    command_line_location ());
 -      break;
 +        skeleton_arg (AS_FILE_NAME (optarg), command_line_prio,
 +                      command_line_location ());
 +        break;
  
        case 'T':
 -      FLAGS_ARGMATCH (trace, optarg);
 -      break;
 +        FLAGS_ARGMATCH (trace, optarg);
 +        break;
  
        case 'V':
 -      version ();
 -      exit (EXIT_SUCCESS);
 +        version ();
 +        exit (EXIT_SUCCESS);
  
        case 'W':
 -      FLAGS_ARGMATCH (warnings, optarg);
 -      break;
 +        FLAGS_ARGMATCH (warnings, optarg);
 +        break;
  
        case 'b':
 -      spec_file_prefix = AS_FILE_NAME (optarg);
 -      break;
 +        spec_file_prefix = AS_FILE_NAME (optarg);
 +        break;
  
        case 'd':
          /* Here, the -d and --defines options are differentiated.  */
          defines_flag = true;
          if (optarg)
-           spec_defines_file = xstrdup (AS_FILE_NAME (optarg));
+           {
+             free (spec_defines_file);
+             spec_defines_file = xstrdup (AS_FILE_NAME (optarg));
+           }
          break;
  
        case 'g':
 -      graph_flag = true;
 -      if (optarg)
 +        graph_flag = true;
 +        if (optarg)
-           spec_graph_file = xstrdup (AS_FILE_NAME (optarg));
+           {
+             free (spec_graph_file);
+             spec_graph_file = xstrdup (AS_FILE_NAME (optarg));
+           }
 -      break;
 +        break;
  
        case 'h':
 -      usage (EXIT_SUCCESS);
 +        usage (EXIT_SUCCESS);
  
        case 'k':
 -      token_table_flag = true;
 -      break;
 +        token_table_flag = true;
 +        break;
  
        case 'l':
 -      no_lines_flag = true;
 -      break;
 +        no_lines_flag = true;
 +        break;
  
        case 'o':
 -      spec_outfile = AS_FILE_NAME (optarg);
 -      break;
 +        spec_outfile = AS_FILE_NAME (optarg);
 +        break;
  
        case 'p':
 -      spec_name_prefix = optarg;
 -      break;
 +        spec_name_prefix = optarg;
 +        break;
  
        case 'r':
 -      FLAGS_ARGMATCH (report, optarg);
 -      break;
 +        FLAGS_ARGMATCH (report, optarg);
 +        break;
  
        case 't':
 -      debug_flag = true;
 -      break;
 +        muscle_percent_define_insert ("parse.trace",
 +                                      command_line_location (), "",
 +                                      MUSCLE_PERCENT_DEFINE_D);
 +        break;
  
        case 'v':
 -      report_flag |= report_states;
 -      break;
 +        report_flag |= report_states;
 +        break;
  
        case 'x':
 -      xml_flag = true;
 -      if (optarg)
 +        xml_flag = true;
 +        if (optarg)
-           spec_xml_file = xstrdup (AS_FILE_NAME (optarg));
+           {
+             free (spec_xml_file);
+             spec_xml_file = xstrdup (AS_FILE_NAME (optarg));
+           }
 -      break;
 +        break;
  
        case 'y':
 -      yacc_flag = true;
 -      break;
 +        yacc_flag = true;
 +        break;
  
        case LOCATIONS_OPTION:
 -      locations_flag = true;
 -      break;
 +        muscle_percent_define_ensure ("locations",
 +                                      command_line_location (), true);
 +        break;
  
        case PRINT_LOCALEDIR_OPTION:
 -      printf ("%s\n", LOCALEDIR);
 -      exit (EXIT_SUCCESS);
 +        printf ("%s\n", LOCALEDIR);
 +        exit (EXIT_SUCCESS);
  
        case PRINT_DATADIR_OPTION:
 -      printf ("%s\n", compute_pkgdatadir ());
 -      exit (EXIT_SUCCESS);
 +        printf ("%s\n", compute_pkgdatadir ());
 +        exit (EXIT_SUCCESS);
  
        case REPORT_FILE_OPTION:
 -      spec_verbose_file = xstrdup (AS_FILE_NAME (optarg));
 -      break;
+         free (spec_verbose_file);
 +        spec_verbose_file = xstrdup (AS_FILE_NAME (optarg));
 +        break;
  
        default:
 -      usage (EXIT_FAILURE);
 +        usage (EXIT_FAILURE);
        }
  
    if (argc - optind != 1)
diff --combined src/parse-gram.y
index 532349bbe40230c346b85986efd8acffe4abe397,eb034b0823a18240fa325f12a3bb6f421ba04c35..74eb4aee2e81a2240c87700e5c6d557f8e7cb922
  #include "symlist.h"
  #include "scan-gram.h"
  #include "scan-code.h"
+ #include "xmemdup0.h"
  
  #define YYLLOC_DEFAULT(Current, Rhs, N)  (Current) = lloc_default (Rhs, N)
  static YYLTYPE lloc_default (YYLTYPE const *, int);
  
  #define YY_LOCATION_PRINT(File, Loc) \
 -        location_print (File, Loc)
 +          location_print (File, Loc)
  
  static void version_check (location const *loc, char const *version);
  
     FIXME: depends on the undocumented availability of YYLLOC.  */
  #undef  yyerror
  #define yyerror(Msg) \
 -      gram_error (&yylloc, Msg)
 +        gram_error (&yylloc, Msg)
  static void gram_error (location const *, char const *);
  
  static char const *char_name (char);
 +%}
  
 -/** Add a lex-param or a parse-param.
 - *
 - * \param type  \a lex_param or \a parse_param
 - * \param decl  the formal argument
 - * \param loc   the location in the source.
 - */
 -static void add_param (char const *type, char *decl, location loc);
 -
 -
 -static symbol_class current_class = unknown_sym;
 -static uniqstr current_type = NULL;
 -static symbol *current_lhs_symbol;
 -static location current_lhs_location;
 -static named_ref *current_lhs_named_ref;
 -static int current_prec = 0;
 -
 -/** Set the new current left-hand side symbol, possibly common
 - * to several right-hand side parts of rule.
 - */
 -static
 -void
 -current_lhs(symbol *sym, location loc, named_ref *ref)
 +%code
  {
 -  current_lhs_symbol = sym;
 -  current_lhs_location = loc;
 -  /* In order to simplify memory management, named references for lhs
 -     are always assigned by deep copy into the current symbol_list
 -     node.  This is because a single named-ref in the grammar may
 -     result in several uses when the user factors lhs between several
 -     rules using "|".  Therefore free the parser's original copy.  */
 -  free (current_lhs_named_ref);
 -  current_lhs_named_ref = ref;
 -}
 -
 +  static int current_prec = 0;
 +  static location current_lhs_location;
 +  static named_ref *current_lhs_named_ref;
 +  static symbol *current_lhs_symbol;
 +  static symbol_class current_class = unknown_sym;
 +  static uniqstr current_type = NULL;
 +
 +  /** Set the new current left-hand side symbol, possibly common
 +   * to several right-hand side parts of rule.
 +   */
 +  static
 +  void
 +  current_lhs(symbol *sym, location loc, named_ref *ref)
 +  {
 +    current_lhs_symbol = sym;
 +    current_lhs_location = loc;
 +    /* In order to simplify memory management, named references for lhs
 +       are always assigned by deep copy into the current symbol_list
 +       node.  This is because a single named-ref in the grammar may
 +       result in several uses when the user factors lhs between several
 +       rules using "|".  Therefore free the parser's original copy.  */
 +    free (current_lhs_named_ref);
 +    current_lhs_named_ref = ref;
 +  }
  
 -#define YYTYPE_INT16 int_fast16_t
 -#define YYTYPE_INT8 int_fast8_t
 -#define YYTYPE_UINT16 uint_fast16_t
 -#define YYTYPE_UINT8 uint_fast8_t
 -%}
 +  #define YYTYPE_INT16 int_fast16_t
 +  #define YYTYPE_INT8 int_fast8_t
 +  #define YYTYPE_UINT16 uint_fast16_t
 +  #define YYTYPE_UINT8 uint_fast8_t
 +}
  
  %debug
  %verbose
  %defines
  %locations
  %pure-parser
 -%error-verbose
 +%define parse.error "verbose"
  %define parse.lac full
  %name-prefix="gram_"
  %expect 0
  
  %union
  {
 +  assoc assoc;
 +  char *code;
 +  char const *chars;
 +  int integer;
 +  named_ref *named_ref;
    symbol *symbol;
    symbol_list *list;
 -  int integer;
 -  char const *chars;
 -  char *code;
 -  assoc assoc;
    uniqstr uniqstr;
    unsigned char character;
 -  named_ref *named_ref;
  };
  
  /* Define the tokens together with their human representation.  */
  %token PERCENT_LEFT        "%left"
  %token PERCENT_RIGHT       "%right"
  %token PERCENT_NONASSOC    "%nonassoc"
 +%token PERCENT_PRECEDENCE  "%precedence"
  
  %token PERCENT_PREC          "%prec"
  %token PERCENT_DPREC         "%dprec"
  %token PERCENT_MERGE         "%merge"
  
 -
  /*----------------------.
  | Global Declarations.  |
  `----------------------*/
  
  %token
    PERCENT_CODE            "%code"
 -  PERCENT_DEBUG           "%debug"
    PERCENT_DEFAULT_PREC    "%default-prec"
    PERCENT_DEFINE          "%define"
    PERCENT_DEFINES         "%defines"
    PERCENT_ERROR_VERBOSE   "%error-verbose"
    PERCENT_EXPECT          "%expect"
 -  PERCENT_EXPECT_RR     "%expect-rr"
 +  PERCENT_EXPECT_RR       "%expect-rr"
 +  PERCENT_FLAG            "%<flag>"
    PERCENT_FILE_PREFIX     "%file-prefix"
    PERCENT_GLR_PARSER      "%glr-parser"
    PERCENT_INITIAL_ACTION  "%initial-action"
    PERCENT_LANGUAGE        "%language"
 -  PERCENT_LEX_PARAM       "%lex-param"
 -  PERCENT_LOCATIONS       "%locations"
    PERCENT_NAME_PREFIX     "%name-prefix"
    PERCENT_NO_DEFAULT_PREC "%no-default-prec"
    PERCENT_NO_LINES        "%no-lines"
    PERCENT_NONDETERMINISTIC_PARSER
 -                        "%nondeterministic-parser"
 +                          "%nondeterministic-parser"
    PERCENT_OUTPUT          "%output"
 -  PERCENT_PARSE_PARAM     "%parse-param"
 -  PERCENT_PURE_PARSER     "%pure-parser"
 -  PERCENT_REQUIRE       "%require"
 +  PERCENT_REQUIRE         "%require"
    PERCENT_SKELETON        "%skeleton"
    PERCENT_START           "%start"
    PERCENT_TOKEN_TABLE     "%token-table"
  ;
  
  %token BRACED_CODE     "{...}"
 +%token BRACED_PREDICATE "%?{...}"
  %token BRACKETED_ID    "[identifier]"
  %token CHAR            "char"
  %token EPILOGUE        "epilogue"
  %token PIPE            "|"
  %token PROLOGUE        "%{...%}"
  %token SEMICOLON       ";"
 -%token TYPE            "type"
 -%token TYPE_TAG_ANY    "<*>"
 -%token TYPE_TAG_NONE   "<>"
 +%token TAG             "<tag>"
 +%token TAG_ANY         "<*>"
 +%token TAG_NONE        "<>"
  
  %type <character> CHAR
  %printer { fputs (char_name ($$), stderr); } CHAR
  /* braceless is not to be used for rule or symbol actions, as it
     calls code_props_plain_init.  */
  %type <chars> STRING "%{...%}" EPILOGUE braceless content.opt
 -%type <code> "{...}"
 +%type <code> "{...}" "%?{...}"
  %printer { fputs (quotearg_style (c_quoting_style, $$), stderr); }
 -       STRING
 +         STRING
  %printer { fprintf (stderr, "{\n%s\n}", $$); }
 -       braceless content.opt "{...}" "%{...%}" EPILOGUE
 +         braceless content.opt "{...}" "%{...%}" EPILOGUE
  
 -%type <uniqstr> BRACKETED_ID ID ID_COLON TYPE variable
 +%type <uniqstr> BRACKETED_ID ID ID_COLON PERCENT_FLAG TAG variable
  %printer { fputs ($$, stderr); } <uniqstr>
  %printer { fprintf (stderr, "[%s]", $$); } BRACKETED_ID
  %printer { fprintf (stderr, "%s:", $$); } ID_COLON
 -%printer { fprintf (stderr, "<%s>", $$); } TYPE
 +%printer { fprintf (stderr, "%%%s", $$); } PERCENT_FLAG
 +%printer { fprintf (stderr, "<%s>", $$); } TAG
  
  %type <integer> INT
  %printer { fprintf (stderr, "%d", $$); } <integer>
  %type <list>  symbols.1 symbols.prec generic_symlist generic_symlist_item
  %type <named_ref> named_ref.opt
  
 +/*---------.
 +| %param.  |
 +`---------*/
 +%code requires
 +{
 +# ifndef PARAM_TYPE
 +#  define PARAM_TYPE
 +  typedef enum
 +  {
 +    param_none   = 0,
 +    param_lex    = 1 << 0,
 +    param_parse  = 1 << 1,
 +    param_both   = param_lex | param_parse
 +  } param_type;
 +# endif
 +};
 +%code
 +{
 +  /** Add a lex-param and/or a parse-param.
 +   *
 +   * \param type  where to push this formal argument.
 +   * \param decl  the formal argument.  Destroyed.
 +   * \param loc   the location in the source.
 +   */
 +  static void add_param (param_type type, char *decl, location loc);
 +  static param_type current_param = param_none;
 +};
 +%union
 +{
 +  param_type param;
 +}
 +%token <param> PERCENT_PARAM "%param";
 +%printer
 +{
 +  switch ($$)
 +    {
 +#define CASE(In, Out)                                           \
 +      case param_ ## In: fputs ("%" #Out, stderr); break
 +      CASE(lex,   lex-param);
 +      CASE(parse, parse-param);
 +      CASE(both,  param);
 +#undef CASE
 +      case param_none: aver (false); break;
 +    }
 +} <param>;
 +
 +
 +                     /*==========\
 +                     | Grammar.  |
 +                     \==========*/
  %%
  
  input:
  ;
  
  
 -      /*------------------------------------.
 -      | Declarations: before the first %%.  |
 -      `------------------------------------*/
 +        /*------------------------------------.
 +        | Declarations: before the first %%.  |
 +        `------------------------------------*/
  
  prologue_declarations:
    /* Nothing */
@@@ -291,10 -251,7 +292,10 @@@ prologue_declaration
                          plain_code.code, @1);
        code_scanner_last_string_free ();
      }
 -| "%debug"                         { debug_flag = true; }
 +| "%<flag>"
 +    {
 +      muscle_percent_define_ensure ($1, @1, true);
 +    }
  | "%define" variable content.opt
      {
        muscle_percent_define_insert ($2, @2, $3,
        defines_flag = true;
        spec_defines_file = xstrdup ($2);
      }
 -| "%error-verbose"                 { error_verbose = true; }
 +| "%error-verbose"
 +    {
 +      muscle_percent_define_insert ("parse.error", @1, "verbose",
 +                                    MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
 +    }
  | "%expect" INT                    { expected_sr_conflicts = $2; }
 -| "%expect-rr" INT               { expected_rr_conflicts = $2; }
 +| "%expect-rr" INT                 { expected_rr_conflicts = $2; }
  | "%file-prefix" STRING            { spec_file_prefix = $2; }
  | "%file-prefix" "=" STRING        { spec_file_prefix = $3; } /* deprecated */
  | "%glr-parser"
        muscle_code_grow ("initial_action", action.code, @2);
        code_scanner_last_string_free ();
      }
 -| "%language" STRING          { language_argmatch ($2, grammar_prio, @1); }
 -| "%lex-param" "{...}"                { add_param ("lex_param", $2, @2); }
 -| "%locations"                  { locations_flag = true; }
 +| "%language" STRING            { language_argmatch ($2, grammar_prio, @1); }
  | "%name-prefix" STRING         { spec_name_prefix = $2; }
  | "%name-prefix" "=" STRING     { spec_name_prefix = $3; } /* deprecated */
  | "%no-lines"                   { no_lines_flag = true; }
 -| "%nondeterministic-parser"  { nondeterministic_parser = true; }
 +| "%nondeterministic-parser"    { nondeterministic_parser = true; }
  | "%output" STRING              { spec_outfile = $2; }
  | "%output" "=" STRING          { spec_outfile = $3; }  /* deprecated */
 -| "%parse-param" "{...}"      { add_param ("parse_param", $2, @2); }
 -| "%pure-parser"
 -    {
 -      /* %pure-parser is deprecated in favor of `%define api.pure', so use
 -         `%define api.pure' in a backward-compatible manner here.  First, don't
 -         complain if %pure-parser is specified multiple times.  */
 -      if (!muscle_find_const ("percent_define(api.pure)"))
 -        muscle_percent_define_insert ("api.pure", @1, "",
 -                                      MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
 -      /* In all cases, use api.pure now so that the backend doesn't complain if
 -         the skeleton ignores api.pure, but do warn now if there's a previous
 -         conflicting definition from an actual %define.  */
 -      if (!muscle_percent_define_flag_if ("api.pure"))
 -        muscle_percent_define_insert ("api.pure", @1, "",
 -                                      MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
 -    }
 +| "%param" { current_param = $1; } params { current_param = param_none; }
  | "%require" STRING             { version_check (&@2, $2); }
  | "%skeleton" STRING
      {
              xmalloc (dir_length + 1 + strlen (skeleton_user) + 1);
            if (dir_length > 0)
              {
-               strncpy (skeleton_build, current_file, dir_length);
+               memcpy (skeleton_build, current_file, dir_length);
                skeleton_build[dir_length++] = '/';
              }
            strcpy (skeleton_build + dir_length, skeleton_user);
  | /*FIXME: Err?  What is this horror doing here? */ ";"
  ;
  
 +params:
 +   params "{...}"  { add_param (current_param, $2, @2); }
 +| "{...}"          { add_param (current_param, $1, @1); }
 +;
 +
 +
 +/*----------------------.
 +| grammar_declaration.  |
 +`----------------------*/
 +
  grammar_declaration:
    precedence_declaration
  | symbol_declaration
      {
        symbol_list *list;
        for (list = $3; list; list = list->next)
 -      symbol_list_destructor_set (list, $2, @2);
 +        symbol_list_destructor_set (list, $2, @2);
        symbol_list_free ($3);
      }
  | "%printer" "{...}" generic_symlist
      {
        symbol_list *list;
        for (list = $3; list; list = list->next)
 -      symbol_list_printer_set (list, $2, @2);
 +        symbol_list_printer_set (list, $2, @2);
        symbol_list_free ($3);
      }
  | "%default-prec"
  ;
  
  
 -/*----------*
 - | %union.  |
 - *----------*/
 +/*---------.
 +| %union.  |
 +`---------*/
  
  %token PERCENT_UNION "%union";
  
@@@ -456,41 -416,40 +457,41 @@@ symbol_declaration
        current_class = unknown_sym;
        current_type = NULL;
      }
 -| "%type" TYPE symbols.1
 +| "%type" TAG symbols.1
      {
        symbol_list *list;
        tag_seen = true;
        for (list = $3; list; list = list->next)
 -      symbol_type_set (list->content.sym, $2, @2);
 +        symbol_type_set (list->content.sym, $2, @2);
        symbol_list_free ($3);
      }
  ;
  
  precedence_declaration:
 -  precedence_declarator type.opt symbols.prec
 +  precedence_declarator tag.opt symbols.prec
      {
        symbol_list *list;
        ++current_prec;
        for (list = $3; list; list = list->next)
 -      {
 -        symbol_type_set (list->content.sym, current_type, @2);
 -        symbol_precedence_set (list->content.sym, current_prec, $1, @1);
 -      }
 +        {
 +          symbol_type_set (list->content.sym, current_type, @2);
 +          symbol_precedence_set (list->content.sym, current_prec, $1, @1);
 +        }
        symbol_list_free ($3);
        current_type = NULL;
      }
  ;
  
  precedence_declarator:
 -  "%left"     { $$ = left_assoc; }
 -| "%right"    { $$ = right_assoc; }
 -| "%nonassoc" { $$ = non_assoc; }
 +  "%left"       { $$ = left_assoc; }
 +| "%right"      { $$ = right_assoc; }
 +| "%nonassoc"   { $$ = non_assoc; }
 +| "%precedence" { $$ = precedence_assoc; }
  ;
  
 -type.opt:
 +tag.opt:
    /* Nothing. */ { current_type = NULL; }
 -| TYPE           { current_type = $1; tag_seen = true; }
 +| TAG            { current_type = $1; tag_seen = true; }
  ;
  
  /* Just like symbols.1 but accept INT for the sake of POSIX.  */
@@@ -520,15 -479,15 +521,15 @@@ generic_symlist
  ;
  
  generic_symlist_item:
 -  symbol            { $$ = symbol_list_sym_new ($1, @1); }
 -| TYPE              { $$ = symbol_list_type_new ($1, @1); }
 -| "<*>"             { $$ = symbol_list_default_tagged_new (@1); }
 -| "<>"             { $$ = symbol_list_default_tagless_new (@1); }
 +  symbol    { $$ = symbol_list_sym_new ($1, @1); }
 +| TAG       { $$ = symbol_list_type_new ($1, @1); }
 +| "<*>"     { $$ = symbol_list_default_tagged_new (@1); }
 +| "<>"      { $$ = symbol_list_default_tagless_new (@1); }
  ;
  
  /* One token definition.  */
  symbol_def:
 -  TYPE
 +  TAG
       {
         current_type = $1;
         tag_seen = true;
@@@ -566,9 -525,9 +567,9 @@@ symbol_defs.1
  ;
  
  
 -      /*------------------------------------------.
 -      | The grammar section: between the two %%.  |
 -      `------------------------------------------*/
 +        /*------------------------------------------.
 +        | The grammar section: between the two %%.  |
 +        `------------------------------------------*/
  
  grammar:
    rules_or_grammar_declaration
@@@ -603,18 -562,16 +604,18 @@@ rhses.1
  rhs:
    /* Nothing.  */
      { grammar_current_rule_begin (current_lhs_symbol, current_lhs_location,
 -                                current_lhs_named_ref); }
 +                                  current_lhs_named_ref); }
  | rhs symbol named_ref.opt
      { grammar_current_rule_symbol_append ($2, @2, $3); }
  | rhs "{...}" named_ref.opt
 -    { grammar_current_rule_action_append ($2, @2, $3); }
 +    { grammar_current_rule_action_append ($2, @2, $3, false); }
 +| rhs "%?{...}"
 +    { grammar_current_rule_action_append ($2, @2, NULL, true); }
  | rhs "%prec" symbol
      { grammar_current_rule_prec_set ($3, @3); }
  | rhs "%dprec" INT
      { grammar_current_rule_dprec_set ($3, @3); }
 -| rhs "%merge" TYPE
 +| rhs "%merge" TAG
      { grammar_current_rule_merge_set ($3, @3); }
  ;
  
@@@ -624,9 -581,10 +625,9 @@@ named_ref.opt
    BRACKETED_ID   { $$ = named_ref_new($1, @1); }
  ;
  
 -
 -/*----------------------------*
 - | variable and content.opt.  |
 - *---------------------------*/
 +/*---------------------------.
 +| variable and content.opt.  |
 +`---------------------------*/
  
  /* The STRING form of variable is deprecated and is not M4-friendly.
     For example, M4 fails for `%define "[" "value"'.  */
@@@ -643,9 -601,9 +644,9 @@@ content.opt
  ;
  
  
 -/*-------------*
 - | braceless.  |
 - *-------------*/
 +/*------------.
 +| braceless.  |
 +`------------*/
  
  braceless:
    "{...}"
  ;
  
  
 -/*---------------*
 - | Identifiers.  |
 - *---------------*/
 +/*--------------.
 +| Identifiers.  |
 +`--------------*/
  
  /* Identifiers are returned as uniqstr values by the scanner.
     Depending on their use, we may need to make them genuine symbols.  */
@@@ -735,61 -693,49 +736,51 @@@ lloc_default (YYLTYPE const *rhs, int n
    for (i = 1; i <= n; i++)
      if (! equal_boundaries (rhs[i].start, rhs[i].end))
        {
 -      loc.start = rhs[i].start;
 -      break;
 +        loc.start = rhs[i].start;
 +        break;
        }
  
    return loc;
  }
  
  
 -/* Add a lex-param or a parse-param (depending on TYPE) with
 -   declaration DECL and location LOC.  */
 -
  static void
 -add_param (char const *type, char *decl, location loc)
 +add_param (param_type type, char *decl, location loc)
  {
    static char const alphanum[26 + 26 + 1 + 10] =
      "abcdefghijklmnopqrstuvwxyz"
      "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
      "_"
      "0123456789";
 +
    char const *name_start = NULL;
 -  char *p;
 -
 -  /* Stop on last actual character.  */
 -  for (p = decl; p[1]; p++)
 -    if ((p == decl
 -       || ! memchr (alphanum, p[-1], sizeof alphanum))
 -      && memchr (alphanum, p[0], sizeof alphanum - 10))
 -      name_start = p;
 -
 -  /* Strip the surrounding '{' and '}', and any blanks just inside
 -     the braces.  */
 -  while (*--p == ' ' || *p == '\t')
 -    continue;
 -  p[1] = '\0';
 -  while (*++decl == ' ' || *decl == '\t')
 -    continue;
 +  {
 +    char *p;
 +    /* Stop on last actual character.  */
 +    for (p = decl; p[1]; p++)
 +      if ((p == decl
 +           || ! memchr (alphanum, p[-1], sizeof alphanum))
 +          && memchr (alphanum, p[0], sizeof alphanum - 10))
 +        name_start = p;
 +
 +    /* Strip the surrounding '{' and '}', and any blanks just inside
 +       the braces.  */
 +    while (*--p == ' ' || *p == '\t')
 +      continue;
 +    p[1] = '\0';
 +    while (*++decl == ' ' || *decl == '\t')
 +      continue;
 +  }
  
    if (! name_start)
      complain_at (loc, _("missing identifier in parameter declaration"));
    else
      {
-       char *name;
-       size_t name_len;
-       for (name_len = 1;
-            memchr (alphanum, name_start[name_len], sizeof alphanum);
-            name_len++)
-         continue;
-       name = xmalloc (name_len + 1);
-       memcpy (name, name_start, name_len);
-       name[name_len] = '\0';
+       char *name = xmemdup0 (name_start, strspn (name_start, alphanum));
 -      muscle_pair_list_grow (type, decl, name);
 +      if (type & param_lex)
 +        muscle_pair_list_grow ("lex_param", decl, name);
 +      if (type & param_parse)
 +        muscle_pair_list_grow ("parse_param", decl, name);
        free (name);
      }
  
diff --combined src/scan-skel.l
index e15294a1e219292be2114417857233c99cb1db8c,2433905728f222be0a97373a3bd5f4cc0b493dd9..284a12074c7a1b84909cf722c9418a90ed2ddd26
@@@ -1,6 -1,6 +1,6 @@@
  /* Scan Bison Skeletons.                                       -*- C -*-
  
 -   Copyright (C) 2001-2007, 2009-2012 Free Software Foundation, Inc.
 +   Copyright (C) 2001-2012 Free Software Foundation, Inc.
  
     This file is part of Bison, the GNU Compiler Compiler.
  
  #define skel_wrap() 1
  
  #define FLEX_PREFIX(Id) skel_ ## Id
 -#include "flex-scanner.h"
 +#include <src/flex-scanner.h>
  
  #include <dirname.h>
  #include <error.h>
  #include <quotearg.h>
  
 -#include "complain.h"
 -#include "getargs.h"
 -#include "files.h"
 -#include "scan-skel.h"
 +#include <src/complain.h>
 +#include <src/getargs.h>
 +#include <src/files.h>
 +#include <src/scan-skel.h>
  
  #define YY_DECL static int skel_lex (void)
  YY_DECL;
@@@ -77,7 -77,6 +77,6 @@@ static void fail_for_invalid_at (char c
  
  "@oline@"  fprintf (yyout, "%d", out_lineno + 1);
  "@ofile@"  QPUTS (outname);
- "@dir_prefix@" QPUTS (dir_prefix);
  
  @[a-z_]+"(" {
    yytext[yyleng-1] = '\0';
@@@ -89,8 -88,8 +88,8 @@@
  
    /* This pattern must not match more than the previous @ patterns. */
  @[^@{}`(\n]* fail_for_invalid_at (yytext);
 -\n       out_lineno++; ECHO;
 -[^@\n]+          ECHO;
 +\n         out_lineno++; ECHO;
 +[^@\n]+    ECHO;
  
  <INITIAL><<EOF>> {
    if (outname)
@@@ -179,15 -178,15 +178,15 @@@ at_directive_perform (int at_directive_
                        char *at_directive_argv[],
                        char **outnamep, int *out_linenop)
  {
 -  if (0 == strcmp (at_directive_argv[0], "@basename"))
 +  if (STREQ (at_directive_argv[0], "@basename"))
      {
        if (at_directive_argc > 2)
          fail_for_at_directive_too_many_args (at_directive_argv[0]);
        fputs (last_component (at_directive_argv[1]), yyout);
      }
 -  else if (0 == strcmp (at_directive_argv[0], "@warn")
 -           || 0 == strcmp (at_directive_argv[0], "@complain")
 -           || 0 == strcmp (at_directive_argv[0], "@fatal"))
 +  else if (STREQ (at_directive_argv[0], "@warn")
 +           || STREQ (at_directive_argv[0], "@complain")
 +           || STREQ (at_directive_argv[0], "@fatal"))
      {
        void (*func)(char const *, ...);
        switch (at_directive_argv[0][1])
              break;
          }
      }
 -  else if (0 == strcmp (at_directive_argv[0], "@warn_at")
 -           || 0 == strcmp (at_directive_argv[0], "@complain_at")
 -           || 0 == strcmp (at_directive_argv[0], "@fatal_at"))
 +  else if (STREQ (at_directive_argv[0], "@warn_at")
 +           || STREQ (at_directive_argv[0], "@complain_at")
 +           || STREQ (at_directive_argv[0], "@fatal_at"))
      {
        void (*func)(location, char const *, ...);
        location loc;
              break;
          }
      }
 -  else if (0 == strcmp (at_directive_argv[0], "@output"))
 +  else if (STREQ (at_directive_argv[0], "@output"))
      {
        if (at_directive_argc > 2)
          fail_for_at_directive_too_many_args (at_directive_argv[0]);
diff --combined tests/local.at
index 02e45597f8261791edd1bfcb596c9c3c6c8ea601,65e528f98637e48f2713826c4e8320324036d51b..c71a2a96949d46523f5aa411f41d607699894e44
@@@ -37,6 -37,33 +37,33 @@@ printf "$count\n";' $1], [0], [$
  ])])
  
  
+ # AT_SAVE_SPECIAL_FILES / AT_RESTORE_SPECIAL_FILES
+ # ------------------------------------------------
+ # Don't interfere with caller's files.
+ m4_divert_text([PREPARE_TESTS],
+ [at_save_special_files ()
+ {
+   for at_save_file in stderr experr expout
+   do
+     test ! -f $at_save_file || mv $at_save_file at-bison-check-$at_save_file.bak
+   done
+ }
+ at_restore_special_files ()
+ {
+   for at_save_file in stderr experr expout
+   do
+     test ! -f at-bison-check-$at_save_file.bak ||
+       mv at-bison-check-$at_save_file.bak $at_save_file
+   done
+ }
+ ])
+ m4_define([AT_SAVE_SPECIAL_FILES],    [at_save_special_files])
+ m4_define([AT_RESTORE_SPECIAL_FILES], [at_restore_special_files])
  ## ------------------------------- ##
  ## Macros decoding Bison options.  ##
  ## ------------------------------- ##
@@@ -71,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
@@@ -110,40 -137,37 +137,40 @@@ m4_pushdef([AT_NAME_PREFIX]
  [m4_bmatch([$3], [%name-prefix ".*"],
             [m4_bregexp([$3], [name-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)]])
@@@ -162,8 -186,6 +189,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
  
  
@@@ -288,10 -310,7 +315,7 @@@ m4_if(m4_bregexp([$4], [: warning: ]), 
          # are added after the grammar file name, so skip these checks
          # in that case.
          if test -z "${POSIXLY_CORRECT+set}"; then
-           # Don't interfere with caller's files.
-           if test -f stderr; then mv stderr at-bison-check-stderr.bak; fi
-           if test -f experr; then mv experr at-bison-check-experr.bak; fi
-           if test -f expout; then mv expout at-bison-check-expout.bak; fi
+           ]AT_SAVE_SPECIAL_FILES[
  
            # To avoid expanding it repeatedly, store specified stdout.
            ]AT_DATA([expout], [$3])[
            ]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ --warnings=none \
                      -Werror]], [[0]], [expout])[
  
-           # Restore caller's files.
-           if test -f at-bison-check-expout.bak; then
-             mv at-bison-check-expout.bak expout
-           fi
-           if test -f at-bison-check-experr.bak; then
-             mv at-bison-check-experr.bak experr
-           fi
-           if test -f at-bison-check-stderr.bak; then
-             mv at-bison-check-stderr.bak stderr
-           fi
+           ]AT_RESTORE_SPECIAL_FILES[
          fi
        ]])
  ])
  # defined.  It doesn't make sense to invoke this macro if Bison is expected to
  # have a non-zero exit status.
  m4_define([AT_BISON_CHECK_XML],
- [[if test x"$BISON_TEST_XML" = x1 && test x"$XSLTPROC" != x""; then
-   mkdir xml-tests]
+ [[if test x"$BISON_TEST_XML" = x1 && test x"$XSLTPROC" != x""; then]
+   AT_SAVE_SPECIAL_FILES
+   [mkdir xml-tests]
    m4_pushdef([AT_BISON_ARGS],
               [m4_bpatsubsts([[$1]],
                              [--report(-file)?=[^][ ]*], [],
    AT_CHECK([[$XSLTPROC \
               `]]AT_QUELL_VALGRIND[[ bison --print-datadir`/xslt/xml2dot.xsl \
               xml-tests/test.xml]], [[0]], [expout])
-   [rm -rf xml-tests expout
- fi]])
+   [rm -rf xml-tests expout]
+   AT_RESTORE_SPECIAL_FILES
+ [fi]])
  
  # AT_QUELL_VALGRIND
  # -----------------
@@@ -414,7 -426,7 +431,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])
  # --------------------------------------------
@@@ -425,7 -437,7 +442,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)
  # ------------------------
diff --combined tests/regression.at
index 41a2939d182ec0d7d001f47f04397992159b389f,f5603eae9f49bef6b10d5c97dc5bd288dd5c5734..ff798a87a85cd0190b154210f8733cc0f49d6ae9
@@@ -532,7 -532,7 +532,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 -542,12 +542,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 -753,15 +753,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 -775,32 +766,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 -814,6 +797,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,7 -834,7 +825,7 @@@ 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 *);])
@@@ -877,7 -886,7 +877,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;
  }
@@@ -953,7 -962,7 +953,7 @@@ m4_define([_AT_DATA_EXPECT2_Y]
  [AT_DATA_GRAMMAR([expect2.y],
  [%{
  static int yylex (AT_LALR1_CC_IF([int *], [void]));
 -AT_LALR1_CC_IF([],
 +AT_LALR1_CC_IF([#include <cstdlib>],
  [#include <stdio.h>
  #include <stdlib.h>
  static void yyerror (const char *);])
@@@ -976,7 -985,7 +976,7 @@@ t: A | B
  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;
  }
@@@ -1062,7 -1071,7 +1062,7 @@@ static int yylex (void)
  start:
    {
      printf ("Bison would once convert this action to a midrule because of the"
 -          " subsequent braced code.\n");
 +            " subsequent braced code.\n");
    }
    ;
  
@@@ -1253,25 -1262,26 +1253,27 @@@ 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 expout]
+ [mv input.c lalr.c]
+ AT_CAPTURE_FILE([lalr.c])
  AT_BISON_CHECK([[-o input.c -Dlr.type=ielr input.y]])
  [mv input.c ielr.c]
- AT_CHECK([[cat ielr.c]], [[0]], [[expout]])
+ AT_CAPTURE_FILE([ielr.c])
+ AT_CHECK([[diff lalr.c ielr.c]], [[0]])
  
  AT_CLEANUP
  
  
  
 -## --------------------------------------- ##
 -## %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_DATA_GRAMMAR([input.y],
  [[%code {
    #define YYSTACK_USE_ALLOCA 1
  }
  
 -%error-verbose
 +%define parse.error verbose
  
  %%
  
@@@ -1347,9 -1357,9 +1349,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_DATA_GRAMMAR([input.y],
  [[%code {
    #define YYMAXDEPTH 100
  }
  
 -%error-verbose
 +%define parse.error verbose
  
  %%
  
@@@ -1494,7 -1504,7 +1496,7 @@@ AT_DATA_GRAMMAR([input.y]
  }
  
  ]$1[
 -%error-verbose
 +%define parse.error verbose
  %token 'c'
  
  %%