]> git.saurik.com Git - bison.git/commitdiff
Merge remote-tracking branch 'origin/maint'
authorAkim Demaille <akim@lrde.epita.fr>
Thu, 19 Jul 2012 15:32:01 +0000 (17:32 +0200)
committerAkim Demaille <akim@lrde.epita.fr>
Thu, 19 Jul 2012 15:39:13 +0000 (17:39 +0200)
* origin/maint:
  maint: update gnu-web-doc-update.
  maint: post-release administrivia
  version 2.6
  maint: prepare for release 2.6
  maint: post-release administrivia
  version 2.5.91
  maint: prepare NEWS.
  maint: fix spaces.
  tests: adjust to case where the C compiler is actually a C++ compiler
  tests: fix dependencies
  doc: fix Texinfo command
  maint: Valgrind on OS X.
  tests: be sure that backups are safe.
  maint: dead comment.
  tests: refactor for legibility.
  tests: refactor the bison invocations.
  maint: fix syntax-check ignore patterns.
  gnulib: update
  gnulib: update.
  gnulib: update

Conflicts:
build-aux/Makefile.am
cfg.mk
tests/Makefile.am

13 files changed:
1  2 
Makefile.am
NEWS
README-hacking
bootstrap
build-aux/local.mk
cfg.mk
configure.ac
doc/bison.texi
m4/.gitignore
tests/atlocal.in
tests/headers.at
tests/local.at
tests/local.mk

diff --combined Makefile.am
index ab3460d88da265eaa4adf6ea3778f0f04069d1bb,aed166e6148fe8aeb2722a65cca054f7d93fb264..a98611901aab7d267c0e6e54a61e932fcc27b145
@@@ -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
@@@ -96,6 -74,7 +96,7 @@@ gen-ChangeLog
            --strip-cherry-pick                         \
            --no-cluster                                \
            --amend=$(srcdir)/build-aux/git-log-fix     \
+           --srcdir=$(srcdir)                          \
            --since=$(gen_start_date) > $$cl.tmp &&     \
          mv -f $$cl.tmp $$cl;                          \
        fi
diff --combined NEWS
index 0552ba212a001a5e30d8b8a479b674c0074010e5,be9ed7ca11cfdff9832721e78c232caaa7a82308..8db03d609b02b7fb9d610c871be11ed4aa1419f4
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -2,129 -2,10 +2,129 @@@ GNU Bison NEW
  
  * Noteworthy changes in release ?.? (????-??-??) [?]
  
 +** Warnings
 +
 +*** Warning categories are now displayed in warnings
 +
 +  For instance:
 +
 +  foo.y:4.6: warning: type clash on default action: <foo> != <bar> [-Wother]
 +
 +*** Useless semantic types
 +
 +  Bison now warns about useless (uninhabited) semantic types.  Since
 +  semantic types are not declared to Bison (they are defined in the opaque
 +  %union structure), it is %printer/%destructor directives about useless
 +  types that trigger the warning:
 +
 +    %token <type1> term
 +    %type  <type2> nterm
 +    %printer    {} <type1> <type3>
 +    %destructor {} <type2> <type4>
 +    %%
 +    nterm: term { $$ = $1; };
 +
 +    3.28-34: warning: type <type3> is used, but is not associated to any symbol
 +    4.28-34: warning: type <type4> is used, but is not associated to any symbol
 +
 +*** Undeclared symbols
 +
 +  Bison used to raise an error for %printer and %destructor directives for
 +  undefined symbols.
 +
 +    %printer    {} symbol1
 +    %destructor {} symbol2
 +    %%
 +    exp: "a";
 +
 +  This is now only a warning.
 +
 +*** Useless destructors or printers
 +
 +  Bison now warns about useless destructors or printers.  In the following
 +  example, the printer for <type1>, and the destructor for <type2> are
 +  useless: all symbols of <type1> (token1) already have a printer, and all
 +  symbols of type <type2> (token2) already have a destructor.
 +
 +    %token <type1> token1
 +           <type2> token2
 +           <type3> token3
 +           <type4> token4
 +    %printer    {} token1 <type1> <type3>
 +    %destructor {} token2 <type2> <type4>
 +
 +** Additional yylex/yyparse arguments
 +
 +  The new directive %param declares additional arguments 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
 +  run-time expressions.
 +
 +* Noteworthy changes in release ?.? (????-??-??) [?]
 +
  
- * Noteworthy changes in release 2.5.90 (2012-07-05) [beta]
+ * Noteworthy changes in release 2.6 (2012-07-19) [stable]
  
 -** Future Changes
 +** Future changes:
  
    The next major release of Bison will drop support for the following
    deprecated features.  Please report disagreements to bug-bison@gnu.org.
@@@ -1925,8 -1806,7 +1925,8 @@@ along with this program.  If not, see <
   LocalWords:  namespaces strerror const autoconfiguration Dconst Autoconf's FDL
   LocalWords:  Automake TMPDIR LESSEQ ylwrap endif yydebug YYTOKEN YYLSP ival hh
   LocalWords:  extern YYTOKENTYPE TOKENTYPE yytokentype tokentype STYPE lval pdf
 - LocalWords:  lang yyoutput dvi html ps POSIX lvalp llocp
 + LocalWords:  lang yyoutput dvi html ps POSIX lvalp llocp Wother nterm arg init
 + LocalWords:  TOK
  
  Local Variables:
  mode: outline
diff --combined README-hacking
index f128c9c5b2a9cc448f1da5b4f3d437da4d201b34,bb91ac063ac9cba844b42f82cb914c082350c010..2b92edcf0c7c1ae97f4b3799a594da35a9c9bd9e
@@@ -1,5 -1,3 +1,3 @@@
- -*- outline -*-
  This file attempts to describe the rules to use when hacking Bison.
  Don't put this file into the distribution.
  
@@@ -37,13 -35,6 +35,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
  
@@@ -67,8 -58,8 +65,8 @@@ tools we depend upon, including
  - Rsync <http://samba.anu.edu.au/rsync/>
  - Tar <http://www.gnu.org/software/tar/>
  
- Valgrind <http://valgrind.org/> is also highly recommended, if
Valgrind supports your architecture.
+ Valgrind <http://valgrind.org/> is also highly recommended, if it supports
+ your architecture.
  
  Bison is written using Bison grammars, so there are bootstrapping
  issues.  The bootstrap script attempts to discover when the C code
@@@ -131,7 -122,7 +129,7 @@@ import requests for updated submodules
  reveal if the current version of the submodule (i.e., the actual
  contents of the gnulib directory) and the current request from the
  subscriber (i.e., the reference of the version of gnulib that the
- Bison reporitory requests) differ.  To upgrade the submodules (i.e.,
+ Bison repository requests) differ.  To upgrade the submodules (i.e.,
  to check out the version that is actually requested by the subscriber,
  run "git submodule update".
  
@@@ -162,7 -153,7 +160,7 @@@ formal release, see the ChangeLog in th
  
          http://erislabs.net/ianb/projects/gnulib/
  
- The autoconf files we use are currently:
+ The Autoconf files we use are currently:
  
          m4/m4.m4
          lib/m4sugar/m4sugar.m4
@@@ -177,6 -168,23 +175,23 @@@ decide whether to update
  ** make check
  Use liberally.
  
+ ** make maintainer-check-valgrind
+ This target uses valgrind both to check bison, and the generated parsers.
+ This is not mature on Mac OS X.  First, Valgrind does support the way bison
+ calls m4, so Valgrind cannot be used to check bison on Mac OS X.
+ Second, there are many errors that come from the platform itself, not from
+ bison.  build-aux/darwin11.4.0.valgrind addresses some of them.
+ Third, valgrind issues warnings such as:
+   --99312:0:syswrap- WARNING: Ignoring sigreturn( ..., UC_RESET_ALT_STACK );
+ which cause the test to fail uselessly.  It is hard to ignore these errors
+ with a major overhaul of the way instrumentation is performed in the test
+ suite.  So currently, do not try to run valgrind on Mac OS X.
  ** Release checks
  Try to run the test suite with more severe conditions before a
  release:
    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
  This section needs to be updated to take into account features from
@@@ -387,7 -392,6 +402,6 @@@ spaces)
  
  Push these changes.
  
  -----
  
  Copyright (C) 2002-2005, 2007-2012 Free Software Foundation, Inc.
@@@ -406,3 -410,14 +420,14 @@@ GNU General Public License for more det
  
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  LocalWords:  Automake Autoconf Gettext Gzip Rsync Valgrind gnulib submodules
+  LocalWords:  submodule init cd distcheck checkin ChangeLog valgrind sigreturn
+  LocalWords:  UC gcc DGNULIB POSIXCHECK xml XSLT glr lalr README po runtime rc
+  LocalWords:  gnupload gnupg gpg keyserver BDF ncftp filename clearsign cvs dir
+  LocalWords:  symlinks vti html lt POSIX Cc'ed
+ Local Variables:
+ mode: outline
+ fill-column: 76
+ End:
diff --combined bootstrap
index e9849102d8777bcbb19f2d37d386ce0ba45f7466,e00c8bbba0aea75d1e629930231a65be3da31c87..e3e270b007f658edd2ca3ec6aa590ecf14f29c27
+++ b/bootstrap
@@@ -1,6 -1,6 +1,6 @@@
  #! /bin/sh
  # Print a version string.
- scriptversion=2012-07-03.20; # UTC
 -scriptversion=2012-07-10.09; # UTC
++scriptversion=2012-07-19.14; # UTC
  
  # Bootstrap this package from checked-out sources.
  
@@@ -77,6 -77,33 +77,33 @@@ Running without arguments will suffice 
  EOF
  }
  
+ # warnf_ FORMAT-STRING ARG1...
+ warnf_ ()
+ {
+   warnf_format_=$1
+   shift
+   nl='
+ '
+   case $* in
+     *$nl*) me_=$(printf "$me"|tr "$nl|" '??')
+        printf "$warnf_format_" "$@" | sed "s|^|$me_: |" ;;
+     *) printf "$me: $warnf_format_" "$@" ;;
+   esac >&2
+ }
+ # warn_ WORD1...
+ warn_ ()
+ {
+   # If IFS does not start with ' ', set it and emit the warning in a subshell.
+   case $IFS in
+     ' '*) warnf_ '%s\n' "$*";;
+     *)    (IFS=' '; warn_ "$@");;
+   esac
+ }
+ # die WORD1...
+ die() { warn_ "$@"; exit 1; }
  # Configuration.
  
  # Name of the Makefile.am
@@@ -130,7 -157,8 +157,8 @@@ extract_package_name=
       p
    }
  '
- package=$(sed -n "$extract_package_name" configure.ac) || exit
+ package=$(sed -n "$extract_package_name" configure.ac) \
+   || die 'cannot find package name in configure.ac'
  gnulib_name=lib$package
  
  build_aux=build-aux
@@@ -186,6 -214,6 +214,8 @@@ use_git=tru
  # otherwise find the first of the NAMES that can be run (i.e.,
  # supports --version).  If found, set ENVVAR to the program name,
  # die otherwise.
++#
++# FIXME: code duplication, see also gnu-web-doc-update.
  find_tool ()
  {
    find_tool_envvar=$1
    else
      find_tool_error_prefix="\$$find_tool_envvar: "
    fi
-   if test x"$find_tool_res" = x; then
-     echo >&2 "$me: one of these is required: $find_tool_names"
-     exit 1
-   fi
-   ($find_tool_res --version </dev/null) >/dev/null 2>&1 || {
-     echo >&2 "$me: ${find_tool_error_prefix}cannot run $find_tool_res --version"
-     exit 1
-   }
+   test x"$find_tool_res" != x \
+     || die "one of these is required: $find_tool_names"
+   ($find_tool_res --version </dev/null) >/dev/null 2>&1 \
+     || die "${find_tool_error_prefix}cannot run $find_tool_res --version"
    eval "$find_tool_envvar=\$find_tool_res"
    eval "export $find_tool_envvar"
  }
    --no-git)
      use_git=false;;
    *)
-     echo >&2 "$0: $option: unknown option"
-     exit 1;;
+     die "$option: unknown option";;
    esac
  done
  
- if $use_git || test -d "$GNULIB_SRCDIR"; then
-   :
- else
-   echo "$0: Error: --no-git requires --gnulib-srcdir" >&2
-   exit 1
- fi
+ $use_git || test -d "$GNULIB_SRCDIR" \
+   || die "Error: --no-git requires --gnulib-srcdir"
  
  if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
-   echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
-   exit 1
+   die "Bootstrapping from a non-checked-out distribution is risky."
  fi
  
  # Ensure that lines starting with ! sort last, per gitignore conventions
@@@ -309,7 -327,7 +329,7 @@@ insert_sorted_if_absent() 
    echo "$str" | sort_patterns - $file | cmp -s - $file > /dev/null \
      || { echo "$str" | sort_patterns - $file > $file.bak \
        && mv $file.bak $file; } \
-     || exit 1
+     || die "insert_sorted_if_absent $file $str: failed"
  }
  
  # Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
@@@ -333,11 -351,8 +353,8 @@@ grep '^[   ]*AC_CONFIG_AUX_DIR(\['"$buil
      >/dev/null && found_aux_dir=yes
  grep '^[       ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
      >/dev/null && found_aux_dir=yes
- if test $found_aux_dir = no; then
-   echo "$0: expected line not found in configure.ac. Add the following:" >&2
-   echo "  AC_CONFIG_AUX_DIR([$build_aux])" >&2
-   exit 1
- fi
+ test $found_aux_dir = yes \
+   || die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it"
  
  # If $build_aux doesn't exist, create it now, otherwise some bits
  # below will malfunction.  If creating it, also mark it as ignored.
@@@ -443,7 -458,7 +460,7 @@@ check_versions() 
        automake-ng|aclocal-ng)
          app=${app%-ng}
          ($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || {
-           echo "$me: Error: '$app' not found or not from Automake-NG" >&2
+           warn_ "Error: '$app' not found or not from Automake-NG"
            ret=1
            continue
          } ;;
        # so we have to rely on $? rather than get_version.
        $app --version >/dev/null 2>&1
        if [ 126 -le $? ]; then
-         echo "$me: Error: '$app' not found" >&2
+         warn_ "Error: '$app' not found"
          ret=1
        fi
      else
        # Require app to produce a new enough version string.
        inst_ver=$(get_version $app)
        if [ ! "$inst_ver" ]; then
-         echo "$me: Error: '$app' not found" >&2
+         warn_ "Error: '$app' not found"
          ret=1
        else
          latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
          if [ ! "$latest_ver" = "$inst_ver" ]; then
-           echo "$me: Error: '$app' version == $inst_ver is too old" >&2
-           echo "       '$app' version >= $req_ver is required" >&2
+           warnf_ '%s\n'                                        \
+               "Error: '$app' version == $inst_ver is too old"  \
+               "       '$app' version >= $req_ver is required"
            ret=1
          fi
        fi
  if ! printf "$buildreq" | check_versions; then
    echo >&2
    if test -f README-prereq; then
-     echo "$0: See README-prereq for how to get the prerequisite programs" >&2
+     die "See README-prereq for how to get the prerequisite programs"
    else
-     echo "$0: Please install the prerequisite programs" >&2
+     die "Please install the prerequisite programs"
    fi
-   exit 1
  fi
  
  echo "$0: Bootstrapping from checked-out $package sources..."
@@@ -738,11 -753,10 +755,10 @@@ symlink_to_dir(
          *)
            case /$dst/ in
            *//* | */../* | */./* | /*/*/*/*/*/)
-              echo >&2 "$me: invalid symlink calculation: $src -> $dst"
-              exit 1;;
-           /*/*/*/*/)  dot_dots=../../../;;
-           /*/*/*/)    dot_dots=../../;;
-           /*/*/)      dot_dots=../;;
+              die "invalid symlink calculation: $src -> $dst";;
+           /*/*/*/*/)    dot_dots=../../../;;
+           /*/*/*/)      dot_dots=../../;;
+           /*/*/)        dot_dots=../;;
            esac;;
          esac
  
@@@ -764,7 -778,7 +780,7 @@@ version_controlled_file() 
      grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null |
               grep '^/[^/]*/[0-9]' > /dev/null
    else
-     echo "$me: no version control for $file?" >&2
+     warn_ "no version control for $file?"
      false
    fi
  }
@@@ -855,11 -869,11 +871,11 @@@ $gnulib_tool $gnulib_tool_options --imp
  
  for file in $gnulib_files; do
    symlink_to_dir "$GNULIB_SRCDIR" $file \
-     || { echo "$0: failed to symlink $file" 1>&2; exit 1; }
+     || die "failed to symlink $file"
  done
  
  bootstrap_post_import_hook \
-   || { echo >&2 "$me: bootstrap_post_import_hook failed"; exit 1; }
+   || die "bootstrap_post_import_hook failed"
  
  # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
  # gnulib-populated directories.  Such .m4 files would cause aclocal to fail.
@@@ -887,7 -901,7 +903,7 @@@ echo "running: AUTOPOINT=true LIBTOOLIZ
      "$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS"
  AUTOPOINT=true LIBTOOLIZE=true \
      $AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS \
-   || exit 1
+   || die "autoreconf failed"
  
  # Get some extra files from gnulib, overriding existing files.
  for file in $gnulib_extra_files; do
    *) dst=$file;;
    esac
    symlink_to_dir "$GNULIB_SRCDIR" $file $dst \
-     || { echo "$0: failed to symlink $file" 1>&2; exit 1; }
+     || die "failed to symlink $file"
  done
  
  if test $with_gettext = yes; then
        a\
            '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
      }
-   ' po/Makevars.template >po/Makevars || exit 1
+   ' po/Makevars.template >po/Makevars \
+     || die 'cannot generate po/Makevars'
  
    # If the 'gettext' module is in use, grab the latest Makefile.in.in.
    # If only the 'gettext-h' module is in use, assume autopoint already
    case $gnulib_modules in
    *gettext-h*) ;;
    *gettext*)
-     cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in || exit 1
+     cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in \
+       || die "cannot create po/Makefile.in.in"
      ;;
    esac
  
          a\
              '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
        }
-     ' po/Makevars.template >runtime-po/Makevars || exit 1
+     ' po/Makevars.template >runtime-po/Makevars \
+     || die 'cannot generate runtime-po/Makevars'
  
      # Copy identical files from po to runtime-po.
      (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
diff --combined build-aux/local.mk
index 29c907a437fd5c45147c132ede1dd58c6c8c205b,0000000000000000000000000000000000000000..7daf6cf7764ef46c7cf0556148885188f5746b53
mode 100644,000000..100644
--- /dev/null
@@@ -1,5 -1,0 +1,23 @@@
++## Makefile for Bison testsuite.
++
++# Copyright (C) 2000-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
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program.  If not, see <http://www.gnu.org/licenses/>.
++
 +EXTRA_DIST +=                                   \
 +  build-aux/cross-options.pl                    \
++  build-aux/darwin11.4.0.valgrind               \
 +  build-aux/move-if-change                      \
 +  build-aux/prev-version.txt                    \
 +  build-aux/update-b4-copyright
diff --combined cfg.mk
index 9e9f8065724ceb334bdaf3de5995da5a3ef7781d,2f1a9e94248f26b46d74bb9f30f7de38a6b9f3f0..f1caf313e85f360c41d0ccfdfe874746dcc7a31c
--- 1/cfg.mk
--- 2/cfg.mk
+++ b/cfg.mk
@@@ -36,9 -36,15 +36,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.
@@@ -54,7 -60,8 +54,8 @@@ update-copyright: update-b4-copyright u
  update-copyright-env = \
    UPDATE_COPYRIGHT_FORCE=1 UPDATE_COPYRIGHT_USE_INTERVALS=1
  
- exclude = $(foreach a,$(1),$(eval exclude_file_name_regexp--sc_$(a)))
+ exclude = \
+   $(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
  $(call exclude,                                                               \
    bindtextdomain=^lib/main.c$$                                                \
    program_name=^lib/main.c$$                                          \
    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_defined_have_decl_tests=?|^lib/timevar.c$$                 \
 +  prohibit_empty_lines_at_EOF=^src/parse-gram.h$$                     \
 +  prohibit_strcmp=^doc/bison\.texi$$                                  \
    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/|doc/bison.texi$$)                     \
  )
diff --combined configure.ac
index 0facd4ab25d54eaef4f56228697b906a9848ed5b,2773167a78f2cc92b79fcaa05bb5252d9a85fef2..cf42d2c67a297de499bcb2b93060ff9b06298cd4
@@@ -45,9 -45,7 +45,9 @@@ 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])
@@@ -73,7 -71,6 +73,7 @@@ if test "$enable_gcc_warnings" = yes; t
    warn_c='-Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes
      -Wshadow -Wstrict-prototypes'
    warn_cxx='-Wnoexcept'
 +
    AC_LANG_PUSH([C])
    for i in $warn_common $warn_c;
    do
@@@ -90,7 -87,7 +90,7 @@@
    do
      gl_WARN_ADD([$i], [WARN_CXXFLAGS])
    done
 -  gl_WARN_ADD([ -Wzero-as-null-pointer-constant], [WARN_CXXFLAGS],
 +  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.
@@@ -108,8 -105,8 +108,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=;;
@@@ -126,10 -123,6 +126,10 @@@ AC_PROG_GNU_M
  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])
@@@ -167,30 -160,34 +167,40 @@@ 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])
+ case $VALGRIND:$host_os in
+   '':*) ;;
+   *:darwin*)
+     # See README-hacking.
+     # VALGRIND+=' --suppressions=$(abs_top_srcdir)/build-aux/darwin11.4.0.valgrind'
+     VALGRIND=;;
+   *:*)
+     AC_SUBST([VALGRIND_PREBISON], [$VALGRIND -q]);;
+ esac
  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 doc/bison.texi
index d4ac6e40630a9c2005ffd306f81afdfb3f5f23c1,6346bf0388b7cdb5e3e0c1e701bb65b8954f13c8..2d06fec95a378c52dceeee152f76b29ab7b661a8
@@@ -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.
  
 -Also, see @ref{Location Default Action, ,Default Action for Locations}, which
 -describes a special usage of @code{YYLLOC_DEFAULT} in GLR parsers.
 +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
 +
 +@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,8 -5074,10 +5156,8 @@@ default location or at the location spe
  @end deffn
  
  @deffn {Directive} %debug
 -In the parser implementation file, define the macro @code{YYDEBUG} (or
 -@code{@var{prefix}DEBUG} with @samp{%define api.prefix @var{prefix}}), see
 -@ref{Multiple Parsers, ,Multiple Parsers in the Same Program}) to 1 if it is
 -not already defined, so that the debugging facilities are compiled.
 +Instrument the parser for traces.  Obsoleted by @samp{%define
 +parse.trace}.
  @xref{Tracing, ,Tracing Your Parser}.
  @end deffn
  
@@@ -5236,22 -5156,6 +5236,22 @@@ grammar does not use it, using @samp{%l
  accurate syntax error messages.
  @end deffn
  
 +@deffn {Directive} %name-prefix "@var{prefix}"
 +Rename the external symbols used in the parser so that they start with
 +@var{prefix} instead of @samp{yy}.  The precise list of symbols renamed
 +in C parsers
 +is @code{yyparse}, @code{yylex}, @code{yyerror}, @code{yynerrs},
 +@code{yylval}, @code{yychar}, @code{yydebug}, and
 +(if locations are used) @code{yylloc}.  If you use a push parser,
 +@code{yypush_parse}, @code{yypull_parse}, @code{yypstate},
 +@code{yypstate_new} and @code{yypstate_delete} will
 +also be renamed.  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 @samp{%define api.namespace} documentation in this
 +section.
 +@xref{Multiple Parsers, ,Multiple Parsers in the Same Program}.
 +@end deffn
 +
  @ifset defaultprec
  @deffn {Directive} %no-default-prec
  Do not assign a precedence to rules lacking an explicit @code{%prec}
@@@ -5275,7 -5179,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,62 -5302,9 +5398,62 @@@ 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.prefix
 -@item @code{api.prefix}
 +@item api.prefix
  @findex %define api.prefix
  
  @itemize @bullet
  @end itemize
  
  @c ================================================== api.pure
 -@item @code{api.pure}
 +@item api.pure
  @findex %define api.pure
  
  @itemize @bullet
  
  @item Default Value: @code{false}
  @end itemize
 +@c api.pure
 +
  
 -@c ================================================== api.push-pull
  
 -@item @code{api.push-pull}
 +@c ================================================== api.push-pull
 +@item api.push-pull
  @findex %define api.push-pull
  
  @itemize @bullet
@@@ -5503,73 -5352,10 +5503,73 @@@ 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
  
 -@item @code{lr.default-reductions}
 +@item lr.default-reductions
  @findex %define lr.default-reductions
  
  @itemize @bullet
@@@ -5590,7 -5376,7 +5590,7 @@@ feedback will help to stabilize it.
  
  @c ============================================ lr.keep-unreachable-states
  
 -@item @code{lr.keep-unreachable-states}
 +@item lr.keep-unreachable-states
  @findex %define lr.keep-unreachable-states
  
  @itemize @bullet
@@@ -5600,11 -5386,10 +5600,11 @@@ 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
  
 -@item @code{lr.type}
 +@item lr.type
  @findex %define lr.type
  
  @itemize @bullet
@@@ -5619,62 -5404,62 +5619,62 @@@ More user feedback will help to stabili
  @item Default Value: @code{lalr}
  @end itemize
  
 -@c ================================================== namespace
  
 -@item @code{namespace}
 +@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 @code{parse.lac}
 +@item parse.lac
  @findex %define parse.lac
  
  @itemize
@@@ -5685,50 -5470,7 +5685,50 @@@ 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++, Java
 +
 +@item Purpose: Require parser instrumentation for tracing.
 +@xref{Tracing, ,Tracing Your Parser}.
 +
 +In C/C++, define the macro @code{YYDEBUG} (or @code{@var{prefix}DEBUG} with
 +@samp{%define api.prefix @var{prefix}}), see @ref{Multiple Parsers,
 +,Multiple Parsers in the Same Program}) to 1 in the parser implementation
 +file if it is not already defined, so that the debugging facilities are
 +compiled.
 +
 +@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
@@@ -5774,7 -5516,7 +5774,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
  
@@@ -5838,7 -5580,7 +5838,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
@@@ -6000,10 -5742,10 +6000,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
@@@ -6042,8 -5785,8 +6042,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)
@@@ -6060,7 -5803,7 +6060,7 @@@ required to finish parsing the grammar
  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}.
  
@@@ -6076,8 -5819,8 +6076,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)
@@@ -6095,8 -5838,8 +6095,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)
@@@ -6285,7 -6028,7 +6285,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
@@@ -6309,57 -6052,46 +6309,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 signatures:
  
  @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
@@@ -6381,8 -6113,8 +6381,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
@@@ -6440,7 -6172,7 +6440,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
@@@ -6962,8 -6694,7 +6962,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
@@@ -7019,9 -6750,8 +7019,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
@@@ -7031,63 -6761,13 +7031,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
  
@@@ -7149,8 -6829,8 +7149,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.
@@@ -7495,9 -7175,9 +7495,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
@@@ -8021,14 -7701,12 +8021,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
@@@ -8820,7 -8498,7 +8820,7 @@@ parser.  This is compliant with POSIX Y
  YYDEBUG 1} in the prologue of the grammar file (@pxref{Prologue, , The
  Prologue}).
  
- If the @code{%define} variable @code{api.prefix} is used (@xref{Multiple
+ If the @code{%define} variable @code{api.prefix} is used (@pxref{Multiple
  Parsers, ,Multiple Parsers in the Same Program}), for instance @samp{%define
  api.prefix x}, then if @code{CDEBUG} is defined, its value controls the
  tracing feature (enabled iff nonzero); otherwise tracing is enabled iff
@@@ -8835,19 -8513,12 +8835,19 @@@ otherwise it defines @code{YYDEBUG} to 
  @item the directive @samp{%debug}
  @findex %debug
  Add the @code{%debug} directive (@pxref{Decl Summary, ,Bison Declaration
 -Summary}).  This is a Bison extension, especially useful for languages that
 -don't use a preprocessor.  Unless POSIX and Yacc portability matter to you,
 -this is the preferred solution.
 +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
@@@ -9499,16 -9170,16 +9499,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.
@@@ -9534,22 -9205,11 +9534,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
@@@ -9566,98 -9226,6 +9566,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
@@@ -9801,7 -9369,7 +9801,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}
@@@ -9812,27 -9380,11 +9812,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
@@@ -9850,11 -9402,9 +9850,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
@@@ -10066,8 -9498,11 +10066,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
@@@ -10091,8 -9526,8 +10091,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
@@@ -10107,13 -9542,9 +10107,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
  
@@@ -10195,35 -9626,19 +10195,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;
  @}
@@@ -10237,14 -9652,15 +10237,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
@@@ -10274,8 -9704,7 +10274,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
 +%define api.tokens.prefix "TOK_"
 +%token
 +  END  0  "end of file"
 +  ASSIGN  ":="
 +  MINUS   "-"
 +  PLUS    "+"
 +  STAR    "*"
 +  SLASH   "/"
 +  LPAREN  "("
 +  RPAREN  ")"
 +;
 +@end example
 +
 +@noindent
 +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.
  
  @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
 +%token <std::string> IDENTIFIER "identifier"
 +%token <int> NUMBER "number"
 +%type  <int> exp
  @end example
  
  @noindent
 -To enable memory deallocation during error recovery, use
 -@code{%destructor}.
 +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<<}.
  
  @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"
 -
 -%printer    @{ yyoutput << $$; @} <ival>
 +%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
@@@ -10342,18 -9753,17 +10342,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
  
@@@ -10364,7 -9774,7 +10364,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);
@@@ -10380,22 -9790,24 +10380,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
@@@ -10423,8 -9835,8 +10423,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
@@@ -10520,7 -9927,6 +10520,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
@@@ -10576,7 -9979,7 +10576,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
@@@ -10589,23 -9992,15 +10589,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.
@@@ -10624,7 -10019,7 +10624,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
@@@ -10663,11 -10058,11 +10663,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.
  
  
@@@ -10702,22 -10097,20 +10702,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
@@@ -10726,33 -10119,30 +10726,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 ()
@@@ -10760,21 -10150,6 +10760,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.
@@@ -10793,11 -10168,6 +10793,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
@@@ -10829,7 -10197,7 +10829,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 ()
@@@ -10837,7 -10205,7 +10837,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
  
@@@ -10847,14 -10215,14 +10847,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}
@@@ -10882,7 -10250,7 +10882,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}.
@@@ -10929,12 -10297,11 +10929,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
  
  
@@@ -10978,7 -10345,7 +10978,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.
@@@ -11019,7 -10386,7 +11019,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
  
@@@ -11050,11 -10417,6 +11050,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}.
@@@ -11067,7 -10429,7 +11067,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
  
@@@ -11076,11 -10438,6 +11076,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}.
@@@ -11097,12 -10454,6 +11097,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}.
@@@ -11620,19 -10971,6 +11620,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
@@@ -11742,8 -11080,8 +11742,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}"
@@@ -11766,12 -11104,12 +11766,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
@@@ -11816,7 -11154,7 +11816,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
  
@@@ -11825,15 -11163,10 +11825,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
@@@ -11841,13 -11174,8 +11841,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
@@@ -11858,7 -11186,7 +11858,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
  
@@@ -11963,16 -11291,17 +11963,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.
 -Supported by the C skeletons only; 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 e157f19c3debb5105ef5e957dc5378519dc7db1c,8a24eb00f3cc03331f4732084a2375c72203e993..875400a9839458282f1096ab5648644fb3437050
@@@ -34,6 -34,7 +34,7 @@@
  /fprintf-posix.m4
  /frexp.m4
  /frexpl.m4
+ /fseterr.m4
  /fstat.m4
  /getdtablesize.m4
  /getopt.m4
@@@ -50,7 -51,6 +51,7 @@@
  /inline.m4
  /intdiv0.m4
  /intl.m4
 +/intl.m4~
  /intldir.m4
  /intlmacosx.m4
  /intmax.m4
  /perror.m4
  /pipe2.m4
  /po.m4
 +/po.m4~
  /posix_spawn.m4
  /printf-frexp.m4
  /printf-frexpl.m4
  /xalloc.m4
  /xsize.m4
  /xstrndup.m4
- /off_t.m4
- /sys_types_h.m4
- /fseterr.m4
diff --combined tests/atlocal.in
index 315e98ed1b4cd7a803b835b340f0231475c8d8b4,d059d630bf744ae1d83d6a5324257238740fa73c..8adb3933f7347e708f17f5c0fdda29479f238a37
@@@ -1,4 -1,4 +1,4 @@@
 -# @configure_input@                                   -*- shell-script -*-
 +# @configure_input@                                     -*- shell-script -*-
  # Configurable variable values for Bison test suite.
  
  # Copyright (C) 2000-2012 Free Software Foundation, Inc.
@@@ -49,10 -49,13 +49,13 @@@ BISON_CXX_WORKS='@BISON_CXX_WORKS@
  
  # Handle --compile-c-with-cxx here, once CXX and CXXFLAGS are known.
  if "$at_arg_compile_c_with_cxx"; then
+   CC_IS_CXX=1
    CC=$CXX
    O0CFLAGS=$O0CXXFLAGS
    NO_WERROR_CFLAGS=$NO_WERROR_CXXFLAGS
    CFLAGS=$CXXFLAGS
+ else
+   CC_IS_CXX=0
  fi
  
  
@@@ -75,17 -78,9 +78,17 @@@ CONF_JAVA='@CONF_JAVA@
  # Empty if no xsltproc was found
  : ${XSLTPROC='@XSLTPROC@'}
  
 -# We need egrep.
 +# We need egrep and perl.
  : ${EGREP='@EGREP@'}
 +: ${PERL='@PERL@'}
  
  # Use simple quotes (lib/quote.c).
  LC_CTYPE=C
  export LC_CTYPE
 +
 +
 +# Handle --compile-c-with-cxx here, once CXX and CXXFLAGS are known.
 +if "$at_arg_compile_c_with_cxx"; then
 +  CC=$CXX
 +  CFLAGS=$CXXFLAGS
 +fi
diff --combined tests/headers.at
index 8475a0903c8122c08ed0dec1946a8ad065e4a855,cac7fe5fc6ff6fc847ff0b434884507719b463ce..421dd7d849adf2771b622674609b3a7a41e41368
@@@ -169,9 -169,8 +169,9 @@@ AT_SKEL_CC_IF([]
  # YYPUSH_MORE(_DEFINED)? (whose definition is constant).
  #
  # YYDEBUG (not renamed) can be read, but not changed.
 -AT_CHECK([[sed -ne 's,/\*[^*]*\*/,,g;s,//.*,,' \
 -                -e '/YY/p' ]$1.AT_SKEL_CC_IF([hh], [h])[ |
 +AT_CHECK([[$PERL -0777 -e 's{/\*.*?\*/}{}sg;s,//.*,,;' \
 +            ]$1.AT_SKEL_CC_IF([hh], [h])[ |
 +         grep 'YY' |
       $EGREP -wv 'YY(PARSE_PARAM|PUSH_MORE(_DEFINED)?)|(defined|if) YYDEBUG']],
           [1])
  AT_LANG_COMPILE([$1.o])
@@@ -183,8 -182,12 +183,12 @@@ AT_BISON_OPTION_POPDEF
  
  AT_DATA([main.cc],
  [AT_DATA_SOURCE_PROLOGUE
- [extern "C"
+ [// If we are compiling with CC=$CXX, then do not load the C headers
+ // inside extern "C", since they were _not_ compiled this way.
+ #if ! CC_IS_CXX
+ extern "C"
  {
+ #endif
    #include "x1.h"
    #include "x2.h"
    #include "x3.h"
    #include "x6.h"
    #include "x7.h"
    #include "x8.h"
+ #if ! CC_IS_CXX
  }
+ #endif
  #include "x5.hh"
  //#include "x6.hh"
  
@@@ -231,7 -236,7 +237,7 @@@ AT_TEST([x7], [%define api.push-pull bo
  AT_TEST([x8], [%define api.pure %define api.push-pull both])
  #AT_TEST([x5], [%locations %language "c++" %glr-parser])
  
- AT_COMPILE_CXX([parser], [[x[1-8].o main.cc]])
+ AT_COMPILE_CXX([parser], [[x[1-8].o -DCC_IS_CXX=$CC_IS_CXX main.cc]])
  AT_CHECK([./parser], [0], [[expout]])
  
  m4_popdef([AT_TEST])
diff --combined tests/local.at
index 5d318ba79d4b22c1ff6112e0c73b5c75f9e881d3,2dbbfc712fdce9cae6008df1e9c668b0c0cdfc24..c79fc08e2c4fba35d00c3c6452cfbe14b22b718f
  m4_version_prereq([2.58])
  
  
+ # m4_null_if(VAL, IF-TRUE, IF-FALSE)
+ # ----------------------------------
+ # If VAL evaluates to empty or 0, run IF-TRUE, otherwise IF-FALSE.
+ m4_define([m4_null_if],
+ [m4_case(m4_quote($1),
+          [0], [$2],
+          [],  [$2],
+          [$3])])
  ## ------------- ##
  ## Basic tests.  ##
  ## ------------- ##
@@@ -44,6 -53,8 +53,8 @@@ m4_divert_text([PREPARE_TESTS]
  {
    for at_save_file in stderr experr expout
    do
+     test ! -f at-bison-check-$at_save_file.bak ||
+       as_fn_error 1 "fatal error: back-up on top of a back-up"
      test ! -f $at_save_file || mv $at_save_file at-bison-check-$at_save_file.bak
    done
  }
@@@ -98,7 -109,7 +109,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
@@@ -141,9 -152,6 +152,9 @@@ m4_pushdef([AT_NAME_PREFIX]
  [m4_bmatch([$3], [\(%define api\.prefix\|%name-prefix\) ".*"],
             [m4_bregexp([$3], [\(%define api\.prefix\|%name-prefix\) "\([^""]*\)"], [\2])],
             [yy])])
 +m4_pushdef([AT_TOKEN_PREFIX],
 +[m4_bmatch([$3], [%define api.tokens.prefix ".*"],
 +           [m4_bregexp([$3], [%define api.tokens.prefix "\(.*\)"], [\1])])])
  m4_pushdef([AT_API_prefix],
  [m4_bmatch([$3], [%define api\.prefix ".*"],
             [m4_bregexp([$3], [%define api\.prefix "\([^""]*\)"], [\1])],
@@@ -153,20 -161,20 +164,20 @@@ m4_pushdef([AT_API_PREFIX]
  # 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])])])
  
  m4_pushdef([AT_YYSTYPE],
  [AT_SKEL_CC_IF([AT_NAME_PREFIX[::parser::semantic_type]],
@@@ -180,15 -188,15 +191,15 @@@ AT_PURE_LEX_IF
  [m4_pushdef([AT_LOC], [(*llocp)])
   m4_pushdef([AT_VAL], [(*lvalp)])
   m4_pushdef([AT_YYLEX_FORMALS],
 -          [AT_YYSTYPE *lvalp[]AT_LOCATION_IF([, AT_YYLTYPE *llocp])])
 +            [AT_YYSTYPE *lvalp[]AT_LOCATION_IF([, AT_YYLTYPE *llocp])])
   m4_pushdef([AT_YYLEX_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_YYLEX_PRE_FORMALS],
 -          [AT_YYLEX_FORMALS, ])
 +            [AT_YYLEX_FORMALS, ])
   m4_pushdef([AT_YYLEX_PRE_ARGS],
 -          [AT_YYLEX_ARGS, ])
 +            [AT_YYLEX_ARGS, ])
  ],
  [m4_pushdef([AT_LOC], [[(]AT_NAME_PREFIX[lloc)]])
   m4_pushdef([AT_VAL], [[(]AT_NAME_PREFIX[lval)]])
@@@ -207,8 -215,6 +218,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
  
  
@@@ -383,11 -389,13 +394,11 @@@ stati
  }]],
  [c++], [[/* A C++ error reporting function.  */
  void
 -]AT_NAME_PREFIX[::parser::error (const location_type& l, const std::string& m)
 -{
 -  (void) l;
 -  std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << std::endl;
 +]AT_NAME_PREFIX[::parser::error (]AT_LOCATION_IF([[const location_type& l, ]])[const std::string& m)
 +{  std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << std::endl;
  }]],
  [java], [AT_LOCATION_IF([[public void yyerror (Calc.Location l, String s)
 -  {
 +{
      if (l == null)
        System.err.println (s);
      else
    public void yyerror (String s)
    {
      System.err.println (s);
 -  }]])])dnl
 +}]])])dnl
  ])
  
  
  
  # AT_BISON_CHECK(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
  # -------------------------------------------------
+ # High-level routine that may call bison several times, under different
+ # conditions.
+ #
  # Check Bison by invoking `bison BISON_ARGS'.  BISON_ARGS should not contain
  # shell constructs (such as redirection or pipes) that would prevent
  # appending additional command-line arguments for bison. OTHER_AT_CHECK_ARGS
  #
  #   4. If stderr contains a warning, -Wnone and --warnings=none suppress it.
  m4_define([AT_BISON_CHECK],
- [m4_if(m4_quote($2), [0], [AT_BISON_CHECK_XML($@)],
-        m4_quote($2), [], [AT_BISON_CHECK_XML($@)])
+ [m4_null_if([$2], [AT_BISON_CHECK_XML($@)])
  AT_BISON_CHECK_NO_XML($@)])
  
  m4_define([AT_BISON_WERROR_MSG],
            [[bison: warnings being treated as errors]])
  
- # AT_BISON_CHECK_NO_XML(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
- # --------------------------------------------------------
- # Same as AT_BISON_CHECK except don't perform XML/XSLT checks.  This is useful
- # when a tortured grammar's XML is known to be too large for xsltproc to
- # handle.
- m4_define([AT_BISON_CHECK_NO_XML],
- [AT_CHECK(m4_if(m4_quote($2), [0], [], m4_quote($2), [], [],
-                 [AT_QUELL_VALGRIND ])[[bison ]]$@)
- m4_if(m4_bregexp([$4], [: warning: ]), [-1], [],
-       m4_quote(m4_if(m4_quote($2), [], [0], [$2])), [0], [[
-         # Defining POSIXLY_CORRECT causes bison to complain if options
+ # AT_BISON_CHECK_(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
+ # --------------------------------------------------
+ # Low-level macro to run bison once.
+ m4_define([AT_BISON_CHECK_],
+ [AT_CHECK(AT_QUELL_VALGRIND[[ bison ]]$@)])
+ # AT_BISON_CHECK_WARNINGS(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
+ # ----------------------------------------------------------
+ # Check that warnings (if some are expected) are correctly
+ # turned into errors with -Werror, etc.
+ m4_define([AT_BISON_CHECK_WARNINGS],
+ [m4_if(m4_bregexp([$4], [: warning: ]), [-1], [],
+       [m4_null_if([$2], [AT_BISON_CHECK_WARNINGS_($@)])])])
+ m4_define([AT_BISON_CHECK_WARNINGS_],
+ [[# Defining POSIXLY_CORRECT causes bison to complain if options
 -# are added after the grammar file name, so skip these checks
 -# in that case.
 -if test -z "${POSIXLY_CORRECT+set}"; then
 -  ]AT_SAVE_SPECIAL_FILES[
 +        # are added after the grammar file name, so skip these checks
 +        # in that case.
 +        if test -z "${POSIXLY_CORRECT+set}"; then
 +          ]AT_SAVE_SPECIAL_FILES[
  
 -  # To avoid expanding it repeatedly, store specified stdout.
 -  ]AT_DATA([expout], [$3])[
 +          # To avoid expanding it repeatedly, store specified stdout.
 +          ]AT_DATA([expout], [$3])[
  
 -  # Run with -Werror.
 +          # Run with -Werror.
-           ]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ -Werror]],
-                     [[1]], [expout], [stderr])[
+   ]AT_BISON_CHECK_([$1[ -Werror]], [[1]], [expout], [stderr])[
  
 -  # Build expected stderr up to and including the "warnings being
 -  # treated as errors" message.
 -  ]AT_DATA([[at-bison-check-warnings]], [$4])[
 -  at_bison_check_first=`sed -n \
 -    '/: warning: /{=;q;}' at-bison-check-warnings`
 -  : ${at_bison_check_first:=1}
 -  at_bison_check_first_tmp=`sed -n \
 -    '/conflicts: [0-9].*reduce$/{=;q;}' at-bison-check-warnings`
 -  : ${at_bison_check_first_tmp:=1}
 -  if test $at_bison_check_first_tmp -lt $at_bison_check_first; then
 -    at_bison_check_first=$at_bison_check_first_tmp
 -  fi
 -  if test $at_bison_check_first -gt 1; then
 -    sed -n "1,`expr $at_bison_check_first - 1`"p \
 -      at-bison-check-warnings > experr
 -  fi
 -  echo ']AT_BISON_WERROR_MSG[' >> experr
 -
 -  # Finish building expected stderr and check.  Unlike warnings,
 -  # complaints cause bison to exit early.  Thus, with -Werror, bison
 -  # does not necessarily report all warnings that it does without
 -  # -Werror, but it at least reports one.
 -  at_bison_check_last=`sed -n '$=' stderr`
 -  : ${at_bison_check_last:=1}
 -  at_bison_check_last=`expr $at_bison_check_last - 1`
 -  sed -n "$at_bison_check_first,$at_bison_check_last"p \
 -    at-bison-check-warnings >> experr
 -  ]AT_CHECK([[sed 's,.*/\(]AT_BISON_WERROR_MSG[\)$,\1,' \
 -              stderr 1>&2]], [[0]], [[]], [experr])[
 -
 -  # Now check --warnings=error.
 -  cp stderr experr
 +          # Build expected stderr up to and including the "warnings being
 +          # treated as errors" message.
 +          ]AT_DATA([[at-bison-check-warnings]], [$4])[
 +          at_bison_check_first=`sed -n \
 +            '/: warning: /{=;q;}' at-bison-check-warnings`
 +          : ${at_bison_check_first:=1}
 +          at_bison_check_first_tmp=`sed -n \
 +            '/conflicts: [0-9].*reduce$/{=;q;}' at-bison-check-warnings`
 +          : ${at_bison_check_first_tmp:=1}
 +          if test $at_bison_check_first_tmp -lt $at_bison_check_first; then
 +            at_bison_check_first=$at_bison_check_first_tmp
 +          fi
 +          if test $at_bison_check_first -gt 1; then
 +            sed -n "1,`expr $at_bison_check_first - 1`"p \
 +              at-bison-check-warnings > experr
 +          fi
 +          echo ']AT_BISON_WERROR_MSG[' >> experr
 +
 +          # Finish building expected stderr and check.  Unlike warnings,
 +          # complaints cause bison to exit early.  Thus, with -Werror, bison
 +          # does not necessarily report all warnings that it does without
 +          # -Werror, but it at least reports one.
 +          at_bison_check_last=`sed -n '$=' stderr`
 +          : ${at_bison_check_last:=1}
 +          at_bison_check_last=`expr $at_bison_check_last - 1`
 +          sed -n "$at_bison_check_first,$at_bison_check_last"p \
 +            at-bison-check-warnings >> experr
 +          ]AT_CHECK([[sed 's,.*/\(]AT_BISON_WERROR_MSG[\)$,\1,' \
 +                      stderr 1>&2]], [[0]], [[]], [experr])[
 +
 +          # Now check --warnings=error.
 +          cp stderr experr
-           ]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ --warnings=error]],
-                     [[1]], [expout], [experr])[
+   ]AT_BISON_CHECK_([$1[ --warnings=error]], [[1]], [expout], [experr])[
  
 -  # Now check -Wnone and --warnings=none by making sure that
 -  # -Werror doesn't change the exit status when -Wnone or
 -  # --warnings=none is specified.
 +          # Now check -Wnone and --warnings=none by making sure that
 +          # -Werror doesn't change the exit status when -Wnone or
 +          # --warnings=none is specified.
-           ]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ -Wnone -Werror]],
-                     [[0]], [expout])[
-           ]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ --warnings=none \
-                     -Werror]], [[0]], [expout])[
+   ]AT_BISON_CHECK_([$1[ -Wnone -Werror]], [[0]], [expout])[
+   ]AT_BISON_CHECK_([$1[ --warnings=none -Werror]], [[0]], [expout])[
  
 -  ]AT_RESTORE_SPECIAL_FILES[
 +          ]AT_RESTORE_SPECIAL_FILES[
-         fi
-       ]])
+ fi]dnl
  ])
  
+ # AT_BISON_CHECK_NO_XML(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
+ # --------------------------------------------------------
+ # Same as AT_BISON_CHECK except don't perform XML/XSLT checks.  This is useful
+ # when a tortured grammar's XML is known to be too large for xsltproc to
+ # handle.
+ m4_define([AT_BISON_CHECK_NO_XML],
+ [AT_CHECK(m4_null_if([$2], [], [AT_QUELL_VALGRIND ])[[bison ]]$@)
+ AT_BISON_CHECK_WARNINGS($@)])
  # AT_BISON_CHECK_XML(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
  # -----------------------------------------------------
  # Run AT_BISON_CHECK's XML/XSLT checks if $BISON_TEST_XML=1 and $XSLTPROC is
@@@ -521,11 -542,11 +545,11 @@@ m4_define([AT_BISON_CHECK_XML]
                              [--xml=[^][ ]*], [])])dnl
    # Don't combine these Bison invocations since we want to be sure that
    # --report=all isn't required to get the full XML file.
-   AT_CHECK([[bison --report=all --report-file=xml-tests/test.output \
+   AT_BISON_CHECK_([[--report=all --report-file=xml-tests/test.output \
 -                  --graph=xml-tests/test.dot ]]AT_BISON_ARGS,
 -                  [[0]], [ignore], [ignore])
 +             --graph=xml-tests/test.dot ]]AT_BISON_ARGS,
 +           [[0]], [ignore], [ignore])
-   AT_CHECK([[bison --xml=xml-tests/test.xml ]]AT_BISON_ARGS,
+   AT_BISON_CHECK_([[--xml=xml-tests/test.xml ]]AT_BISON_ARGS,
 -                 [[0]], [ignore], [ignore])
 +           [[0]], [ignore], [ignore])
    m4_popdef([AT_BISON_ARGS])dnl
    [cp xml-tests/test.output expout]
    AT_CHECK([[$XSLTPROC \
  m4_define([AT_QUELL_VALGRIND],
  [[[VALGRIND_OPTS="$VALGRIND_OPTS --leak-check=summary --show-reachable=no"; export VALGRIND_OPTS;]]])
  
  ## ------------------------ ##
  ## Compiling C, C++ Files.  ##
  ## ------------------------ ##
@@@ -572,7 -595,7 +598,7 @@@ m4_define([AT_COMPILE]
                    [-o $1],
                    [m4_default([$2], [m4_bpatsubst([$1], [\.o$]).c])],
                    [m4_bmatch([$1], [[.]], [], [$LIBS])]),
 -         0, [ignore], [ignore])])
 +           0, [ignore], [ignore])])
  
  # AT_COMPILE_CXX(OUTPUT, [SOURCES = OUTPUT.cc])
  # ---------------------------------------------
@@@ -591,7 -614,7 +617,7 @@@ AT_CHECK(m4_join([ ]
                   [-o $1],
                   [m4_default([$2], [m4_bpatsubst([$1], [\.o$]).cc])],
                   [m4_bmatch([$1], [[.]], [], [$LIBS])]),
 -       0, [ignore], [ignore])])
 +         0, [ignore], [ignore])])
  
  # AT_JAVA_COMPILE(SOURCES)
  # ------------------------
@@@ -631,23 -654,23 +657,23 @@@ m4_define([AT_FULL_COMPILE]
  [java],
    [AT_BISON_CHECK([-o $1.java $1.y])
     AT_LANG_COMPILE([$1],
 -                   m4_join([ ],
 -                           [$1.java],
 -                           m4_ifval($2, [[$1-$2.java]]),
 +                    m4_join([ ],
 +                            [$1.java],
 +                            m4_ifval($2, [[$1-$2.java]]),
                             m4_ifval($3, [[$1-$3.java]])))],
  [c++],
    [AT_BISON_CHECK([-o $1.cc $1.y])
     AT_LANG_COMPILE([$1],
 -                   m4_join([ ],
 -                           [$1.cc],
 -                           m4_ifval($2, [[$1-$2.cc]]),
 +                     m4_join([ ],
 +                             [$1.cc],
 +                             m4_ifval($2, [[$1-$2.cc]]),
                             m4_ifval($3, [[$1-$3.cc]])))],
  [c],
    [AT_BISON_CHECK([-o $1.c $1.y])
     AT_LANG_COMPILE([$1],
 -                   m4_join([ ],
 -                           [$1.c],
 -                           m4_ifval($2, [[$1-$2.c]]),
 +                  m4_join([ ],
 +                          [$1.c],
 +                          m4_ifval($2, [[$1-$2.c]]),
                             m4_ifval($3, [[$1-$3.c]])))])
  ])
  
diff --combined tests/local.mk
index 4f2ee52d350de2c2b3c8dd350505460c2836660a,0000000000000000000000000000000000000000..dc5b6c482ffeac99b029f8580086694c6e3a71d2
mode 100644,000000..100644
--- /dev/null
@@@ -1,125 -1,0 +1,125 @@@
-           PREBISON='$(VALGRIND) -q' PREPARSER='$(VALGRIND) -q'        \
 +## Makefile for Bison testsuite.
 +
 +# Copyright (C) 2000-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
 +# (at your option) any later version.
 +#
 +# This program is distributed in the hope that it will be useful,
 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +# GNU General Public License for more details.
 +#
 +# You should have received a copy of the GNU General Public License
 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +
 +EXTRA_DIST += $(TESTSUITE_AT) tests/testsuite
 +
 +DISTCLEANFILES       += tests/atconfig $(check_SCRIPTS)
 +MAINTAINERCLEANFILES += $(TESTSUITE)
 +
 +## ------------ ##
 +## package.m4.  ##
 +## ------------ ##
 +
 +$(top_srcdir)/tests/package.m4: $(top_srcdir)/configure
 +      $(AM_V_GEN)rm -f $@ $@.tmp
 +      $(AM_V_at){ \
 +        echo '# Signature of the current package.'; \
 +        echo 'm4_define([AT_PACKAGE_NAME],      [$(PACKAGE_NAME)])'; \
 +        echo 'm4_define([AT_PACKAGE_TARNAME],   [$(PACKAGE_TARNAME)])'; \
 +        echo 'm4_define([AT_PACKAGE_VERSION],   [$(PACKAGE_VERSION)])'; \
 +        echo 'm4_define([AT_PACKAGE_STRING],    [$(PACKAGE_STRING)])'; \
 +        echo 'm4_define([AT_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])'; \
 +      } >$@.tmp
 +      $(AM_V_at)mv $@.tmp $@
 +
 +## ------------------------- ##
 +## Generate the test suite.  ##
 +## ------------------------- ##
 +
 +TESTSUITE_AT =                                  \
 +  tests/testsuite.at                            \
 +                                                \
 +  tests/actions.at                              \
 +  tests/c++.at                                  \
 +  tests/calc.at                                 \
 +  tests/conflicts.at                            \
 +  tests/cxx-type.at                             \
 +  tests/existing.at                             \
 +  tests/glr-regression.at                       \
 +  tests/headers.at                              \
 +  tests/input.at                                \
 +  tests/java.at                                 \
 +  tests/local.at                                \
 +  tests/named-refs.at                           \
 +  tests/output.at                               \
 +  tests/package.m4                              \
 +  tests/push.at                                 \
 +  tests/reduce.at                               \
 +  tests/regression.at                           \
 +  tests/sets.at                                 \
 +  tests/skeletons.at                            \
 +  tests/synclines.at                            \
 +  tests/torture.at
 +
 +TESTSUITE = $(top_srcdir)/tests/testsuite
 +
 +AUTOTEST = $(AUTOM4TE) --language=autotest
 +AUTOTESTFLAGS = -I $(top_srcdir)/tests
 +$(TESTSUITE): $(TESTSUITE_AT)
 +      $(AM_V_GEN) \
 +        $(AUTOTEST) $(AUTOTESTFLAGS) $(srcdir)/tests/testsuite.at -o $@.tmp
 +      $(AM_V_at)mv $@.tmp $@
 +
 +
 +## -------------------- ##
 +## Run the test suite.  ##
 +## -------------------- ##
 +
 +# Move into tests/ so that testsuite.dir etc. be created there.
 +RUN_TESTSUITE = $(TESTSUITE) -C tests $(TESTSUITEFLAGS)
 +check_SCRIPTS = $(BISON) tests/atconfig tests/atlocal
 +RUN_TESTSUITE_deps = $(TESTSUITE) $(check_SCRIPTS)
 +
 +clean-local: clean-local-tests
 +clean-local-tests:
 +      test ! -f $(TESTSUITE) || $(TESTSUITE) -C tests --clean
 +
 +check-local: $(RUN_TESTSUITE_deps)
 +      $(RUN_TESTSUITE)
 +
 +# Run the test suite on the *installed* tree.
 +installcheck-local: $(RUN_TESTSUITE_deps)
 +      $(RUN_TESTSUITE) AUTOTEST_PATH='$(bindir)'
 +
 +# Be real mean with it.
 +.PHONY: maintainer-check-g++
 +maintainer-check-g++: $(RUN_TESTSUITE_deps)
 +      $(RUN_TESTSUITE) --compile-c-with-cxx
 +
 +.PHONY: maintainer-check-posix
 +maintainer-check-posix: $(RUN_TESTSUITE_deps)
 +      $(RUN_TESTSUITE) POSIXLY_CORRECT=1 _POSIX2_VERSION=200112
 +
 +.PHONY: maintainer-check-valgrind
 +maintainer-check-valgrind: $(RUN_TESTSUITE_deps)
 +      test -z '$(VALGRIND)' ||                                        \
 +        $(RUN_TESTSUITE)                                              \
++          PREBISON='$(VALGRIND_PREBISON)' PREPARSER='$(VALGRIND) -q'  \
 +          VALGRIND_OPTS='--leak-check=full --show-reachable=yes'
 +
 +.PHONY: maintainer-check
 +maintainer-check: maintainer-check-posix maintainer-check-valgrind maintainer-check-g++
 +
 +.PHONY: maintainer-push-check
 +maintainer-push-check:
 +      $(MAKE) $(AM_MAKEFLAGS) maintainer-check                        \
 +        TESTSUITEFLAGS='BISON_USE_PUSH_FOR_PULL=1 $(TESTSUITEFLAGS)'
 +
 +.PHONY: maintainer-xml-check
 +maintainer-xml-check:
 +      $(MAKE) $(AM_MAKEFLAGS) maintainer-check                \
 +        TESTSUITEFLAGS='BISON_TEST_XML=1 $(TESTSUITEFLAGS)'