I have pushed the following commit, which corresponds to merging upstream/maint into upstream/master. The diff looks a bit weird: I tried to get rid of the tons of changes due to copyright years.
commit f462a08572ef5ff8d43513c6b866895d20cf018b (HEAD -> master) Merge: d6445ec1 0ac08d2d Author: Akim Demaille <[email protected]> Date: Sun Jun 17 18:43:59 2018 +0200 Merge maint into master * upstream/maint: (48 commits) THANKS: update an address tests: adjust syncline tests to GCC 7 glr: fix improperly placed synclines bison: be git grep friendly Replace ftp with https maint: post-release administrivia version 3.0.5 bison: style: indentation fixes regen bison: please address sanitizer C++: style: fix indentation NEWS: update C++: style: prefer `unsigned` to `unsigned int` C++: style: space before paren C++: fix -Wdeprecated warnings tests: fix -Wdeprecated warning maint: update syntax-check exclusions autoconf: update regen Update copyright years … --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//mnJMUa_.prev-version 2018-06-17 19:12:29.000000000 +0200 +++ .prev-version 2018-06-17 18:43:59.000000000 +0200 @@ -1 +1 @@ -3.0.4 +3.0.5 --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//zkWrTb_NEWS 2018-06-17 19:12:30.000000000 +0200 +++ NEWS 2018-06-17 18:43:59.000000000 +0200 @@ -45,6 +45,36 @@ input: '0' | exp ^^^ +* Noteworthy changes in release 3.0.5 (2018-05-27) [stable] + +** Bug fixes + +*** C++: Fix support of 'syntax_error' + + One incorrect 'inline' resulted in linking errors about the constructor of + the syntax_error exception. + +*** C++: Fix warnings + + GCC 7.3 (with -O1 or -O2 but not -O0 or -O3) issued null-dereference + warnings about yyformat being possibly null. It also warned about the + deprecated implicit definition of copy constructors when there's a + user-defined (copy) assignment operator. + +*** Location of errors + + In C++ parsers, out-of-bounds errors can happen when a rule with an empty + ride-hand side raises a syntax error. The behavior of the default parser + (yacc.c) in such a condition was undefined. + + Now all the parsers match the behavior of glr.c: @$ is used as the + location of the error. This handles gracefully rules with and without + rhs. + +*** Portability fixes in the test suite + + On some platforms, some Java and/or C++ tests were failing. + * Noteworthy changes in release 3.0.4 (2015-01-23) [stable] ** Bug fixes @@ -106,7 +136,7 @@ extracted from the documentation: - rpcalc - Reverse polish calculator, a simple introductory example. + Reverse Polish Calculator, a simple introductory example. - mfcalc Multi-function Calc, a calculator with memory and functions and located error messages. --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//96j4Ka_README 2018-06-17 19:12:30.000000000 +0200 +++ README 2018-06-17 18:43:59.000000000 +0200 @@ -7,7 +7,7 @@ Bison requires GNU m4 1.4.6 or later. See: - ftp://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz + https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz ** Internationalization Bison supports two catalogues: one for Bison itself (i.e., for the --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//FTgIab_README-hacking 2018-06-17 19:12:30.000000000 +0200 +++ README-hacking 2018-06-17 18:43:59.000000000 +0200 @@ -9,19 +9,19 @@ * Administrivia ** If you incorporate a change from somebody on the net: -First, if it is a large change, you must make sure they have signed -the appropriate paperwork. Second, be sure to add their name and -email address to THANKS. +First, if it is a large change, you must make sure they have signed the +appropriate paperwork. Second, be sure to add their name and email address +to THANKS. ** If a change fixes a test, mention the test in the commit message. ** Bug reports -If somebody reports a new bug, mention his name in the commit message -and in the test case you write. Put him into THANKS. +If somebody reports a new bug, mention his name in the commit message and in +the test case you write. Put him into THANKS. -The correct response to most actual bugs is to write a new test case -which demonstrates the bug. Then fix the bug, re-run the test suite, -and check everything in. +The correct response to most actual bugs is to write a new test case which +demonstrates the bug. Then fix the bug, re-run the test suite, and check +everything in. * Hacking @@ -30,17 +30,17 @@ Which include serious bug fixes, must be mentioned in NEWS. ** Translations -Only user visible strings are to be translated: error messages, bits -of the .output file etc. This excludes impossible error messages -(comparable to assert/abort), and all the --trace output which is -meant for the maintainers only. +Only user visible strings are to be translated: error messages, bits of the +.output file etc. This excludes impossible error messages (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. +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 @@ -103,14 +103,16 @@ $ git submodule update --init -Git submodule support is weak before versions 1.6 and later, upgrade Git if -your version is older. - The next step is to get other files needed to build, which are extracted from other source packages: $ ./bootstrap +Bootstrapping updates the submodules to the versions registered in the +top-level directory. To change gnulib, first check out the version you want +in `gnulib`, then commit this change in Bison's repository, and finally run +bootstrap. + If it fails with missing symbols (e.g., "error: possibly undefined macro: AC_PROG_GNU_M4"), you are likely to have forgotten the submodule initialization part. Otherwise, there you are! Just @@ -137,13 +139,12 @@ *** Updating Bison If you pull a newer version of a branch, say via "git pull", you might -import requests for updated submodules. A simple "git diff" will -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 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". +import requests for updated submodules. A simple "git diff" will 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 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". $ git pull $ git submodule update @@ -167,8 +168,8 @@ $ git checkin ... -For a suggestion of what gnulib commit might be stable enough for a -formal release, see the ChangeLog in the latest gnulib snapshot at: +For a suggestion of what gnulib commit might be stable enough for a formal +release, see the ChangeLog in the latest gnulib snapshot at: http://erislabs.net/ianb/projects/gnulib/ @@ -178,9 +179,9 @@ lib/m4sugar/m4sugar.m4 lib/m4sugar/foreach.m4 -These files don't change very often in Autoconf, so it should be -relatively straight-forward to examine the differences in order to -decide whether to update. +These files don't change very often in Autoconf, so it should be relatively +straight-forward to examine the differences in order to decide whether to +update. * Test suite @@ -243,102 +244,99 @@ Try to run the test suite with more severe conditions before a release: -- Configure the package with --enable-gcc-warnings, so that one checks - that 1. Bison compiles cleanly, 2. the parsers it produces compile - cleanly too. - -- Maybe build with -DGNULIB_POSIXCHECK, which suggests gnulib modules - that can fix portability issues. See if you really want to pay - attention to its warnings; there's no need to obey blindly to it +- Configure the package with --enable-gcc-warnings, so that one checks that + 1. Bison compiles cleanly, 2. the parsers it produces compile cleanly too. + +- Maybe build with -DGNULIB_POSIXCHECK, which suggests gnulib modules that + can fix portability issues. See if you really want to pay attention to + its warnings; there's no need to obey blindly to it (<http://lists.gnu.org/archive/html/bison-patches/2012-05/msg00057.html>). -- Check with "make syntax-check" if there are issues diagnosed by - gnulib. +- Check with "make syntax-check" if there are issues diagnosed by gnulib. - run "make maintainer-check" which: - runs "valgrind -q bison" to run Bison under Valgrind. - runs the parsers under Valgrind. - runs the test suite with G++ as C compiler... -- run "make maintainer-push-check", which runs "make maintainer-check" - while activating the push implementation and its pull interface wrappers - in many test cases that were originally written to exercise only the - pull implementation. This makes certain the push implementation can - perform every task the pull implementation can. - -- run "make maintainer-xml-check", which runs "make maintainer-check" - while checking Bison's XML automaton report for every working grammar - passed to Bison in the test suite. The check just diffs the output of - Bison's included XSLT style sheets with the output of --report=all and - --graph. +- run "make maintainer-push-check", which runs "make maintainer-check" while + activating the push implementation and its pull interface wrappers in many + test cases that were originally written to exercise only the pull + implementation. This makes certain the push implementation can perform + every task the pull implementation can. + +- run "make maintainer-xml-check", which runs "make maintainer-check" while + checking Bison's XML automaton report for every working grammar passed to + Bison in the test suite. The check just diffs the output of Bison's + included XSLT style sheets with the output of --report=all and --graph. - running "make maintainer-release-check" takes care of running maintainer-check, maintainer-push-check and maintainer-xml-check. -- Change tests/atlocal/CFLAGS to add your preferred options. For - instance, "-traditional" to check that the parsers are K&R. Note - that it does not make sense for glr.c, which should be ANSI, but - currently is actually GNU C, nor for lalr1.cc. +- Change tests/atlocal/CFLAGS to add your preferred options. For instance, + "-traditional" to check that the parsers are K&R. Note that it does not + make sense for glr.c, which should be ANSI, but currently is actually GNU + C, nor for lalr1.cc. -- Test with a very recent version of GCC for both C and C++. Testing - with older versions that are still in use is nice too. +- 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 -gnulib. In particular, be sure to read README-release. +This section needs to be updated to take into account features from gnulib. +In particular, be sure to read README-release. ** Update the submodules. See above. ** Update maintainer tools, such as Autoconf. See above. ** Try to get the *.pot files to the Translation Project at least one -week before a stable release, to give them time to translate them. -Before generating the *.pot files, make sure that po/POTFILES.in and -runtime-po/POTFILES.in list all files with translatable strings. -This helps: grep -l '\<_(' * +week before a stable release, to give them time to translate them. Before +generating the *.pot files, make sure that po/POTFILES.in and +runtime-po/POTFILES.in list all files with translatable strings. This +helps: grep -l '\<_(' * ** Tests See above. ** Update the foreign files -Running "./bootstrap" in the top level should update them all for you. -This covers PO files too. Sometimes a PO file contains problems that -causes it to be rejected by recent Gettext releases; please report -these to the Translation Project. +Running "./bootstrap" in the top level should update them all for you. This +covers PO files too. Sometimes a PO file contains problems that causes it +to be rejected by recent Gettext releases; please report these to the +Translation Project. ** Update README -Make sure the information in README is current. Most notably, make sure -it recommends a version of GNU M4 that is compatible with the latest -Bison sources. +Make sure the information in README is current. Most notably, make sure it +recommends a version of GNU M4 that is compatible with the latest Bison +sources. ** Check copyright years. -We update years in copyright statements throughout Bison once at the -start of every year by running "make update-copyright". However, before -a release, it's good to verify that it's actually been run. Besides the -copyright statement for each Bison file, check the copyright statements -that the skeletons insert into generated parsers, and check all -occurrences of PACKAGE_COPYRIGHT_YEAR in configure.ac. +We update years in copyright statements throughout Bison once at the start +of every year by running "make update-copyright". However, before a +release, it's good to verify that it's actually been run. Besides the +copyright statement for each Bison file, check the copyright statements that +the skeletons insert into generated parsers, and check all occurrences of +PACKAGE_COPYRIGHT_YEAR in configure.ac. ** Update NEWS, commit and tag. -See do-release-commit-and-tag in README-release. For a while, we used -beta names such as "2.6_rc1". Now that we use gnulib in the release -procedure, we must use "2.5.90", which has the additional benefit of -being properly sorted in "git tag -l". +See do-release-commit-and-tag in README-release. For a while, we used beta +names such as "2.6_rc1". Now that we use gnulib in the release procedure, +we must use "2.5.90", which has the additional benefit of being properly +sorted in "git tag -l". ** make alpha, beta, or stable See README-release. ** Upload -There are two ways to upload the tarballs to the GNU servers: using -gnupload (from gnulib), or by hand. Obviously prefer the former. But -in either case, be sure to read the following paragraph. +There are two ways to upload the tarballs to the GNU servers: using gnupload +(from gnulib), or by hand. Obviously prefer the former. But in either +case, be sure to read the following paragraph. *** Setup You need "gnupg". -Make sure your public key has been uploaded at least to -keys.gnupg.net. You can upload it with: +Make sure your public key has been uploaded at least to keys.gnupg.net. You +can upload it with: gpg --keyserver keys.gnupg.net --send-keys F125BDF3 @@ -347,8 +345,8 @@ *** Using gnupload You need "ncftp". -At the end "make stable" (or alpha/beta) will display the procedure to -run. Just copy and paste it in your shell. +At the end "make stable" (or alpha/beta) will display the procedure to run. +Just copy and paste it in your shell. *** By hand @@ -410,9 +408,9 @@ $ ls -lt Remove these files and commit their removal to CVS. For each of these -files, add a line to the file .symlinks. This will ensure that -hyperlinks to the removed files will redirect to the entire manual; this -is better than a 404 error. +files, add a line to the file .symlinks. This will ensure that hyperlinks +to the removed files will redirect to the entire manual; this is better than +a 404 error. There is a problem with 'index.html' being written twice (once for POSIX function 'index', once for the table of contents); you can ignore this @@ -431,19 +429,18 @@ ([email protected], [email protected], [email protected], [email protected], and [email protected]) is appropriate for a stable release or a "serious beta". For any other -release, drop at least [email protected]. For an example of how to -fill out the rest of the template, search the mailing list archives -for the most recent release announcement. +release, drop at least [email protected]. For an example of how to fill out +the rest of the template, search the mailing list archives for the most +recent release announcement. For a stable release, send the same announcement on the comp.compilers -newsgroup by sending email to [email protected]. Do not make any Cc as -the moderator will throw away anything cross-posted or Cc'ed. It really -needs to be a separate message. +newsgroup by sending email to [email protected]. Do not make any Cc as the +moderator will throw away anything cross-posted or Cc'ed. It really needs +to be a separate message. ** Prepare NEWS -So that developers don't accidentally add new items to the old NEWS -entry, create a new empty entry in line 3 (without the two leading -spaces): +So that developers don't accidentally add new items to the old NEWS entry, +create a new empty entry in line 3 (without the two leading spaces): * Noteworthy changes in release ?.? (????-??-??) [?] --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//Zfppwb_THANKS 2018-06-17 19:12:30.000000000 +0200 +++ THANKS 2018-06-17 18:43:59.000000000 +0200 @@ -15,6 +15,7 @@ Antonio Silva Correia [email protected] Arnold Robbins [email protected] Art Haas [email protected] +Askar Safin [email protected] Baron Schwartz [email protected] Ben Pfaff [email protected] Benoit Perrot [email protected] @@ -39,6 +40,7 @@ David J. MacKenzie [email protected] David Kastrup [email protected] Dennis Clarke [email protected] +Derek Clegg [email protected] Derek M. Jones [email protected] Di-an Jan [email protected] Dick Streefland [email protected] @@ -48,6 +50,7 @@ Eric Blake [email protected] Evgeny Stambulchik [email protected] Fabrice Bauzac [email protected] +Ferdinand Thiessen [email protected] Florian Krohm [email protected] Frank Heckenbach [email protected] Frans Englich [email protected] @@ -58,7 +61,7 @@ Goran Uddeborg [email protected] Guido Trentalancia [email protected] H. Merijn Brand [email protected] -Hans Aberg [email protected] +Hans Åberg [email protected] Jan Nieuwenhuizen [email protected] Jerry Quinn [email protected] Jesse Thilo [email protected] @@ -93,6 +96,7 @@ Mickael Labau [email protected] Mike Castle [email protected] Mike Sullivan [email protected] +Nate Guerin [email protected] Neil Booth [email protected] Nelson H. F. Beebe [email protected] Nick Bowler [email protected] --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//tDJbpb_bootstrap 2018-06-17 19:12:30.000000000 +0200 +++ bootstrap 2018-06-17 18:43:59.000000000 +0200 @@ -1,6 +1,6 @@ #! /bin/sh # Print a version string. -scriptversion=2014-12-08.12; # UTC +scriptversion=2018-04-28.14; # UTC # Bootstrap this package from checked-out sources. @@ -17,7 +17,7 @@ # 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/>. +# along with this program. If not, see <https://www.gnu.org/licenses/>. # Originally written by Paul Eggert. The canonical version of this # script is maintained as build-aux/bootstrap in gnulib, however, to @@ -42,7 +42,7 @@ local_gl_dir=gl -# Honour $PERL, but work even if there is none +# Honor $PERL, but work even if there is none. PERL="${PERL-perl}" me=$0 @@ -109,9 +109,6 @@ # Configuration. -# Name of the Makefile.am -gnulib_mk=gnulib.mk - # List of gnulib modules needed. gnulib_modules= @@ -141,7 +138,7 @@ # Fallback for downloading .po files (if rsync fails). po_download_command_format2=\ "wget --mirror -nd -q -np -A.po -P '%s' \ - http://translationproject.org/latest/%s/" + https://translationproject.org/latest/%s/" # Prefer a non-empty tarname (4th argument of AC_INIT if given), else # fall back to the package name (1st argument with munging) @@ -170,7 +167,15 @@ m4_base=m4 doc_base=doc tests_base=tests -gnulib_extra_files='' +gnulib_extra_files=" + build-aux/install-sh + build-aux/mdate-sh + build-aux/texinfo.tex + build-aux/depcomp + build-aux/config.guess + build-aux/config.sub + doc/INSTALL +" # Additional gnulib-tool options to use. Use "\newline" to break lines. gnulib_tool_option_extras= @@ -264,24 +269,18 @@ *) test -r "$0.conf" && . ./"$0.conf" ;; esac -# Extra files from gnulib, which override files from other sources. -test -z "${gnulib_extra_files}" && \ - gnulib_extra_files=" - build-aux/install-sh - build-aux/mdate-sh - build-aux/texinfo.tex - build-aux/depcomp - build-aux/config.guess - build-aux/config.sub - doc/INSTALL -" - if test "$vc_ignore" = auto; then vc_ignore= test -d .git && vc_ignore=.gitignore test -d CVS && vc_ignore="$vc_ignore .cvsignore" fi +if test x"$gnulib_modules$gnulib_files$gnulib_extra_files" = x; then + use_gnulib=false +else + use_gnulib=true +fi + # Translate configuration into internal form. # Parse options. @@ -418,28 +417,30 @@ done } +get_version_sed=' +# Move version to start of line. +s/.*[v ]\([0-9]\)/\1/ + +# Skip lines that do not start with version. +/^[0-9]/!d + +# Remove characters after the version. +s/[^.a-z0-9-].*// + +# The first component must be digits only. +s/^\([0-9]*\)[a-z-].*/\1/ + +#the following essentially does s/5.005/5.5/ +s/\.0*\([1-9]\)/.\1/g +p +q' + get_version() { app=$1 $app --version >/dev/null 2>&1 || { $app --version; return 1; } - $app --version 2>&1 | - sed -n '# Move version to start of line. - s/.*[v ]\([0-9]\)/\1/ - - # Skip lines that do not start with version. - /^[0-9]/!d - - # Remove characters after the version. - s/[^.a-z0-9-].*// - - # The first component must be digits only. - s/^\([0-9]*\)[a-z-].*/\1/ - - #the following essentially does s/5.005/5.5/ - s/\.0*\([1-9]\)/.\1/g - p - q' + $app --version 2>&1 | sed -n "$get_version_sed" } check_versions() { @@ -610,84 +611,86 @@ test -f .gitmodules && git config --file .gitmodules "$@" } -if $use_git; then - gnulib_path=$(git_modules_config submodule.gnulib.path) - test -z "$gnulib_path" && gnulib_path=gnulib -fi +if $use_gnulib; then + if $use_git; then + gnulib_path=$(git_modules_config submodule.gnulib.path) + test -z "$gnulib_path" && gnulib_path=gnulib + fi -# Get gnulib files. Populate $GNULIB_SRCDIR, possibly updating a -# submodule, for use in the rest of the script. + # Get gnulib files. Populate $GNULIB_SRCDIR, possibly updating a + # submodule, for use in the rest of the script. -case ${GNULIB_SRCDIR--} in --) - # Note that $use_git is necessarily true in this case. - if git_modules_config submodule.gnulib.url >/dev/null; then - echo "$0: getting gnulib files..." - git submodule init -- "$gnulib_path" || exit $? - git submodule update -- "$gnulib_path" || exit $? - - elif [ ! -d "$gnulib_path" ]; then - echo "$0: getting gnulib files..." - - trap cleanup_gnulib 1 2 13 15 - - shallow= - git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2' - git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" || - cleanup_gnulib + case ${GNULIB_SRCDIR--} in + -) + # Note that $use_git is necessarily true in this case. + if git_modules_config submodule.gnulib.url >/dev/null; then + echo "$0: getting gnulib files..." + git submodule init -- "$gnulib_path" || exit $? + git submodule update -- "$gnulib_path" || exit $? + + elif [ ! -d "$gnulib_path" ]; then + echo "$0: getting gnulib files..." + + trap cleanup_gnulib 1 2 13 15 + + shallow= + git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2' + git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" || + cleanup_gnulib - trap - 1 2 13 15 - fi - GNULIB_SRCDIR=$gnulib_path - ;; -*) - # Use GNULIB_SRCDIR directly or as a reference. - if $use_git && test -d "$GNULIB_SRCDIR"/.git && \ - git_modules_config submodule.gnulib.url >/dev/null; then - echo "$0: getting gnulib files..." - if git submodule -h|grep -- --reference > /dev/null; then - # Prefer the one-liner available in git 1.6.4 or newer. - git submodule update --init --reference "$GNULIB_SRCDIR" \ - "$gnulib_path" || exit $? - else - # This fallback allows at least git 1.5.5. - if test -f "$gnulib_path"/gnulib-tool; then - # Since file already exists, assume submodule init already complete. - git submodule update -- "$gnulib_path" || exit $? + trap - 1 2 13 15 + fi + GNULIB_SRCDIR=$gnulib_path + ;; + *) + # Use GNULIB_SRCDIR directly or as a reference. + if $use_git && test -d "$GNULIB_SRCDIR"/.git && \ + git_modules_config submodule.gnulib.url >/dev/null; then + echo "$0: getting gnulib files..." + if git submodule -h|grep -- --reference > /dev/null; then + # Prefer the one-liner available in git 1.6.4 or newer. + git submodule update --init --reference "$GNULIB_SRCDIR" \ + "$gnulib_path" || exit $? else - # Older git can't clone into an empty directory. - rmdir "$gnulib_path" 2>/dev/null - git clone --reference "$GNULIB_SRCDIR" \ - "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \ - && git submodule init -- "$gnulib_path" \ - && git submodule update -- "$gnulib_path" \ - || exit $? + # This fallback allows at least git 1.5.5. + if test -f "$gnulib_path"/gnulib-tool; then + # Since file already exists, assume submodule init already complete. + git submodule update -- "$gnulib_path" || exit $? + else + # Older git can't clone into an empty directory. + rmdir "$gnulib_path" 2>/dev/null + git clone --reference "$GNULIB_SRCDIR" \ + "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \ + && git submodule init -- "$gnulib_path" \ + && git submodule update -- "$gnulib_path" \ + || exit $? + fi fi + GNULIB_SRCDIR=$gnulib_path fi - GNULIB_SRCDIR=$gnulib_path - fi - ;; -esac + ;; + esac -# $GNULIB_SRCDIR now points to the version of gnulib to use, and -# we no longer need to use git or $gnulib_path below here. + # $GNULIB_SRCDIR now points to the version of gnulib to use, and + # we no longer need to use git or $gnulib_path below here. -if $bootstrap_sync; then - cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || { - echo "$0: updating bootstrap and restarting..." - case $(sh -c 'echo "$1"' -- a) in - a) ignored=--;; - *) ignored=ignored;; - esac - exec sh -c \ - 'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \ - $ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \ - "$0" "$@" --no-bootstrap-sync - } -fi + if $bootstrap_sync; then + cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || { + echo "$0: updating bootstrap and restarting..." + case $(sh -c 'echo "$1"' -- a) in + a) ignored=--;; + *) ignored=ignored;; + esac + exec sh -c \ + 'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \ + $ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \ + "$0" "$@" --no-bootstrap-sync + } + fi -gnulib_tool=$GNULIB_SRCDIR/gnulib-tool -<$gnulib_tool || exit $? + gnulib_tool=$GNULIB_SRCDIR/gnulib-tool + <$gnulib_tool || exit $? +fi # Get translations. @@ -697,7 +700,7 @@ echo "$me: getting translations into $subdir for $domain..." cmd=$(printf "$po_download_command_format" "$domain" "$subdir") eval "$cmd" && return - # Fallback to HTTP. + # Fallback to HTTPS. cmd=$(printf "$po_download_command_format2" "$subdir" "$domain") eval "$cmd" } @@ -788,9 +791,9 @@ # Leave any existing symlink alone, if it already points to the source, # so that broken build tools that care about symlink times # aren't confused into doing unnecessary builds. Conversely, if the - # existing symlink's time stamp is older than the source, make it afresh, + # existing symlink's timestamp is older than the source, make it afresh, # so that broken tools aren't confused into skipping needed builds. See - # <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00326.html>. + # <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00326.html>. test -h "$dst" && src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 && dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 && @@ -896,31 +899,33 @@ # Import from gnulib. -gnulib_tool_options="\ - --import\ - --no-changelog\ - --aux-dir $build_aux\ - --doc-base $doc_base\ - --lib $gnulib_name\ - --m4-base $m4_base/\ - --source-base $source_base/\ - --tests-base $tests_base\ - --local-dir $local_gl_dir\ - $gnulib_tool_option_extras\ -" -if test $use_libtool = 1; then - case "$gnulib_tool_options " in - *' --libtool '*) ;; - *) gnulib_tool_options="$gnulib_tool_options --libtool" ;; - esac +if $use_gnulib; then + gnulib_tool_options="\ + --no-changelog\ + --aux-dir $build_aux\ + --doc-base $doc_base\ + --lib $gnulib_name\ + --m4-base $m4_base/\ + --source-base $source_base/\ + --tests-base $tests_base\ + --local-dir $local_gl_dir\ + $gnulib_tool_option_extras\ + " + if test $use_libtool = 1; then + case "$gnulib_tool_options " in + *' --libtool '*) ;; + *) gnulib_tool_options="$gnulib_tool_options --libtool" ;; + esac + fi + echo "$0: $gnulib_tool $gnulib_tool_options --import ..." + $gnulib_tool $gnulib_tool_options --import $gnulib_modules \ + || die "gnulib-tool failed" + + for file in $gnulib_files; do + symlink_to_dir "$GNULIB_SRCDIR" $file \ + || die "failed to symlink $file" + done fi -echo "$0: $gnulib_tool $gnulib_tool_options --import ..." -$gnulib_tool $gnulib_tool_options --import $gnulib_modules && - -for file in $gnulib_files; do - symlink_to_dir "$GNULIB_SRCDIR" $file \ - || die "failed to symlink $file" -done bootstrap_post_import_hook \ || die "bootstrap_post_import_hook failed" @@ -1017,9 +1022,9 @@ echo "$0: done. Now you can run './configure'." # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//pzqufb_bootstrap.conf 2018-06-17 19:12:30.000000000 +0200 +++ bootstrap.conf 2018-06-17 18:43:59.000000000 +0200 @@ -81,7 +81,7 @@ bootstrap_post_import_hook() { # Massage lib/gnulib.mk before using it later in the bootstrapping process. - build-aux/prefix-gnulib-mk --lib-name=$gnulib_name lib/$gnulib_mk + build-aux/prefix-gnulib-mk --lib-name=$gnulib_name lib/gnulib.mk # Ensure that ChangeLog exists, for automake. test -f ChangeLog || touch ChangeLog --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//ZFootc_.gitignore 2018-06-17 19:12:30.000000000 +0200 +++ build-aux/.gitignore 2018-06-17 18:43:59.000000000 +0200 @@ -1,6 +1,4 @@ /announce-gen -/arg-nonnull.h -/c++defs.h /compile /config.guess /config.rpath @@ -16,14 +14,12 @@ /install-sh /javacomp.sh.in /javaexec.sh.in -/link-warning.h /mdate-sh /missing +/prefix-gnulib-mk /test-driver /texinfo.tex /update-copyright /useless-if-before-free /vc-list-files -/warn-on-use.h /ylwrap -/prefix-gnulib-mk --- /dev/null 2018-06-17 19:12:07.000000000 +0200 +++ build-aux/Linux.valgrind 2018-06-17 18:43:59.000000000 +0200 @@ -0,0 +1,48 @@ +# Copyright (C) 2012-2015, 2018 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/>. + +# Valgrind suppression file for Bison. + +# Linux prague 4.1.2-2-ARCH #1 SMP PREEMPT Wed Jul 15 08:30:32 UTC 2015 +# x86_64 GNU/Linux +{ + Probably exception handling from G++ 5.1. + Memcheck:Leak + match-leak-kinds: reachable + fun:malloc + fun:pool + fun:__static_initialization_and_destruction_0 + fun:_GLOBAL__sub_I_eh_alloc.cc + fun:call_init.part.0 + fun:_dl_init + obj:/usr/lib/ld-2.21.so +} + +# Linux seattle 2.6.32-5-amd64 #1 SMP Thu Mar 22 17:26:33 UTC 2012 +# x86_64 GNU/Linux +{ + index + Memcheck:Cond + fun:index + fun:expand_dynamic_string_token + fun:_dl_map_object + fun:map_doit + fun:_dl_catch_error + fun:do_preload + fun:dl_main + fun:_dl_sysdep_start + fun:_dl_start + obj:/lib/ld-2.11.3.so +} --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//zs0lOa_linux-gnu.valgrind 2018-06-17 19:12:30.000000000 +0200 +++ /dev/null 2018-06-17 19:12:07.000000000 +0200 @@ -1,16 +0,0 @@ -# Linux seattle 2.6.32-5-amd64 #1 SMP Thu Mar 22 17:26:33 UTC 2012 -# x86_64 GNU/Linux -{ - index - Memcheck:Cond - fun:index - fun:expand_dynamic_string_token - fun:_dl_map_object - fun:map_doit - fun:_dl_catch_error - fun:do_preload - fun:dl_main - fun:_dl_sysdep_start - fun:_dl_start - obj:/lib/ld-2.11.3.so -} --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//NHMiZ8_local.mk 2018-06-17 19:12:30.000000000 +0200 +++ build-aux/local.mk 2018-06-17 18:43:59.000000000 +0200 @@ -13,10 +13,10 @@ # 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/linux-gnu.valgrind \ - build-aux/move-if-change \ - build-aux/prev-version.txt \ +EXTRA_DIST += \ + build-aux/Darwin.valgrind \ + build-aux/Linux.valgrind \ + build-aux/cross-options.pl \ + build-aux/move-if-change \ + build-aux/prev-version.txt \ build-aux/update-b4-copyright --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//Lwdr5b_.gitignore 2018-06-17 19:12:30.000000000 +0200 +++ /dev/null 2018-06-17 19:12:07.000000000 +0200 @@ -1,4 +0,0 @@ -/_Noreturn.h -/arg-nonnull.h -/c++defs.h -/warn-on-use.h --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//3dPp3b_cfg.mk 2018-06-17 19:12:30.000000000 +0200 +++ cfg.mk 2018-06-17 18:43:59.000000000 +0200 @@ -34,7 +34,7 @@ $(filter maintainer-% dist% alpha beta major,$(MAKECMDGOALS))) url_dir_list = \ - ftp://$(gnu_rel_host)/gnu/bison + https://$(gnu_rel_host)/gnu/bison # Tests not to run as part of "make distcheck". local-checks-to-skip = \ @@ -158,23 +158,24 @@ exclude = \ $(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a)))) -$(call exclude, \ - bindtextdomain=^lib/main.c$$ \ - preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \ - program_name=^lib/main.c$$ \ - prohibit_always-defined_macros=^data/yacc.c$$|^djgpp/ \ - prohibit_always-defined_macros+=?|^lib/timevar.c$$ \ - prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \ - prohibit_always-defined_macros+=?|^tests/regression.at$$ \ - prohibit_always_true_header_tests=^djgpp/subpipe.h$$|^lib/timevar.c$$ \ - prohibit_always_true_header_tests+=?|^m4/timevar.m4$$ \ - prohibit_defined_have_decl_tests=?|^lib/timevar.c$$ \ +$(call exclude, \ + bindtextdomain=^lib/main.c$$ \ + preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \ + program_name=^lib/main.c$$ \ + prohibit_always-defined_macros=^data/yacc.c$$|^djgpp/ \ + prohibit_always-defined_macros+=?|^lib/timevar.c$$ \ + prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \ + prohibit_always-defined_macros+=?|^tests/regression.at$$ \ + prohibit_always_true_header_tests=^djgpp/subpipe.h$$|^lib/timevar.c$$ \ + prohibit_always_true_header_tests+=?|^m4/timevar.m4$$ \ + prohibit_defined_have_decl_tests=?|^lib/timevar.c$$ \ prohibit_doubled_word=^tests/named-refs.at$$ \ - prohibit_magic_number_exit=^doc/bison.texi$$ \ - prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \ - prohibit_strcmp=^doc/bison\.texi|tests/local\.at$$ \ - prohibit_tab_based_indentation=\.(am|mk)$$|^djgpp/|^\.git \ - require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \ + prohibit_magic_number_exit=^doc/bison.texi$$ \ + prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \ + prohibit_strcmp=^doc/bison\.texi|tests/local\.at$$ \ + prohibit_tab_based_indentation=\.(am|mk)$$|^djgpp/|^\.git \ + require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \ space_before_open_paren=^(data/|djgpp/) \ - unmarked_diagnostics=^(djgpp/|doc/bison.texi$$|tests/c\+\+\.at$$) \ + two_space_separator_in_usage=^(bootstrap) \ + unmarked_diagnostics=^(djgpp/|doc/bison.texi$$|tests/c\+\+\.at$$) \ ) --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//ljhHka_configure.ac 2018-06-17 19:12:30.000000000 +0200 +++ configure.ac 2018-06-17 18:43:59.000000000 +0200 @@ -26,7 +26,7 @@ AC_INIT([GNU Bison], m4_esyscmd([build-aux/git-version-gen .tarball-version]), [[email protected]]) -AC_SUBST([PACKAGE_COPYRIGHT_YEAR], [2015]) +AC_SUBST([PACKAGE_COPYRIGHT_YEAR], [2018]) AC_DEFINE_UNQUOTED([PACKAGE_COPYRIGHT_YEAR], [$PACKAGE_COPYRIGHT_YEAR], [The copyright year for this package]) @@ -82,7 +82,7 @@ AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test "$enable_gcc_warnings" = yes]) if test "$enable_gcc_warnings" = yes; then warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align -Wdocumentation - -Wformat -Wpointer-arith -Wwrite-strings' + -Wformat -Wnull-dereference -Wpointer-arith -Wwrite-strings' warn_c='-Wbad-function-cast -Wshadow -Wstrict-prototypes' warn_cxx='-Wnoexcept' # Warnings for the test suite only. @@ -90,7 +90,12 @@ # -fno-color-diagnostics: Clang's use of colors in the error # messages is confusing the tests looking at the compiler's output # (e.g., synclines.at). - warn_tests='-Wundef -pedantic -Wsign-compare -fno-color-diagnostics' + # + # -Wno-keyword-macro: We use the "#define private public" dirty + # trick in the test suite to check some private implementation + # details for lalr1.cc. + warn_tests='-Wundef -pedantic -Wdeprecated -Wsign-compare -fno-color-diagnostics + -Wno-keyword-macro' AC_LANG_PUSH([C]) # Clang supports many of GCC's -W options, but only issues warnings @@ -220,20 +225,21 @@ AC_CONFIG_TESTDIR(tests) AC_CONFIG_FILES([tests/atlocal]) AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison]) + AC_CHECK_PROGS([VALGRIND], [valgrind]) -case $VALGRIND:$host_os in +# Use something simpler that $host_os to select our suppression file. +uname=`uname` +case $VALGRIND:$uname in '':*) ;; - *:darwin*) + *:Darwin) # See README-hacking. - # VALGRIND+='-q --suppressions=$(abs_top_srcdir)/build-aux/darwin11.4.0.valgrind' VALGRIND=;; *:*) - suppfile=build-aux/$host_os.valgrind + suppfile=build-aux/$uname.valgrind if test -f "$srcdir/$suppfile"; then - VALGRIND="$VALGRIND --gen-suppressions=all" - VALGRIND="$VALGRIND --suppressions=\$(abs_top_srcdir)/$suppfile" + AC_SUBST([VALGRIND_OPTS_SUPPRESSION], + ["--suppressions=\$(abs_top_srcdir)/$suppfile"]) fi - AC_SUBST([VALGRIND_PREBISON], ["$VALGRIND -q"]) ;; esac --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//XWjPac_c++.m4 2018-06-17 19:12:30.000000000 +0200 +++ data/c++.m4 2018-06-17 18:43:59.000000000 +0200 @@ -30,6 +30,16 @@ m4_define([b4_comment], [b4_comment_([$1], [$2// ], [$2// ])]) +# b4_inline(hh|cc) +# ---------------- +# Expand to `inline\n ` if $1 is hh. +m4_define([b4_inline], +[m4_case([$1], + [cc], [], + [hh], [[inline + ]], + [m4_fatal([$0: invalid argument: $1])])]) + ## -------- ## ## Checks. ## ## -------- ## @@ -275,25 +285,22 @@ ]b4_symbol_constructor_declare]) -# b4_public_types_define -# ---------------------- +# b4_public_types_define(hh|cc) +# ----------------------------- # Provide the implementation needed by the public types. m4_define([b4_public_types_define], -[[ inline - ]b4_parser_class_name[::syntax_error::syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m) +[ b4_inline([$1])b4_parser_class_name[::syntax_error::syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m) : std::runtime_error (m)]b4_locations_if([ , location (l)])[ {} // basic_symbol. template <typename Base> - inline ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol () : value () {} template <typename Base> - inline ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const basic_symbol& other) : Base (other) , value ()]b4_locations_if([ @@ -304,9 +311,7 @@ [value = other.value;])[ } - template <typename Base> - inline ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join( [typename Base::kind_type t], [const semantic_type& v], @@ -323,7 +328,6 @@ ]b4_type_foreach([b4_basic_symbol_constructor_define])], [[ /// Constructor for valueless symbols. template <typename Base> - inline ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join( [typename Base::kind_type t], b4_locations_if([const location_type& l]))[) @@ -333,14 +337,12 @@ {}]])[ template <typename Base> - inline ]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol () { clear (); } template <typename Base> - inline void ]b4_parser_class_name[::basic_symbol<Base>::clear () {]b4_variant_if([[ @@ -361,7 +363,6 @@ } template <typename Base> - inline bool ]b4_parser_class_name[::basic_symbol<Base>::empty () const { @@ -369,11 +370,10 @@ } template <typename Base> - inline void ]b4_parser_class_name[::basic_symbol<Base>::move (basic_symbol& s) { - super_type::move(s); + super_type::move (s); ]b4_variant_if([b4_symbol_variant([this->type_get ()], [value], [move], [s.value])], [value = s.value;])[]b4_locations_if([ @@ -381,45 +381,38 @@ } // by_type. - inline - ]b4_parser_class_name[::by_type::by_type () + ]b4_inline([$1])b4_parser_class_name[::by_type::by_type () : type (empty_symbol) {} - inline - ]b4_parser_class_name[::by_type::by_type (const by_type& other) + ]b4_inline([$1])b4_parser_class_name[::by_type::by_type (const by_type& other) : type (other.type) {} - inline - ]b4_parser_class_name[::by_type::by_type (token_type t) + ]b4_inline([$1])b4_parser_class_name[::by_type::by_type (token_type t) : type (yytranslate_ (t)) {} - inline - void + ]b4_inline([$1])[void ]b4_parser_class_name[::by_type::clear () { type = empty_symbol; } - inline - void + ]b4_inline([$1])[void ]b4_parser_class_name[::by_type::move (by_type& that) { type = that.type; that.clear (); } - inline - int + ]b4_inline([$1])[int ]b4_parser_class_name[::by_type::type_get () const { return type; } ]b4_token_ctor_if([[ - inline - ]b4_parser_class_name[::token_type + ]b4_inline([$1])b4_parser_class_name[::token_type ]b4_parser_class_name[::by_type::token () const { // YYTOKNUM[NUM] -- (External) token number corresponding to the @@ -445,14 +438,13 @@ m4_define([b4_symbol_constructor_define], []) -# b4_yytranslate_define -# --------------------- -# Define yytranslate_. Sometimes used in the header file, +# b4_yytranslate_define(cc|hh) +# ---------------------------- +# Define yytranslate_. Sometimes used in the header file ($1=hh), # sometimes in the cc file. m4_define([b4_yytranslate_define], [[ // Symbol number corresponding to token number t. - inline - ]b4_parser_class_name[::token_number_type + ]b4_inline([$1])b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yytranslate_ (]b4_token_ctor_if([token_type], [int])[ t) { @@ -462,12 +454,12 @@ { ]b4_translate[ }; - const unsigned int user_token_number_max_ = ]b4_user_token_number_max[; + const unsigned user_token_number_max_ = ]b4_user_token_number_max[; const token_number_type undef_token_ = ]b4_undef_token_number[; - if (static_cast<int>(t) <= yyeof_) + if (static_cast<int> (t) <= yyeof_) return yyeof_; - else if (static_cast<unsigned int> (t) <= user_token_number_max_) + else if (static_cast<unsigned> (t) <= user_token_number_max_) return translate_table[t]; else return undef_token_; --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//tJwBwa_c.m4 2018-06-17 19:12:30.000000000 +0200 +++ data/c.m4 2018-06-17 18:43:59.000000000 +0200 @@ -459,7 +459,8 @@ # ------------------------------------ m4_define([b4_predicate_case], [ case $1: - if (! ($2)) YYERROR; + if (! ( +$2)) YYERROR; b4_syncline([@oline@], [@ofile@]) break;]) --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//LiuVcb_glr.c 2018-06-17 19:12:30.000000000 +0200 +++ data/glr.c 2018-06-17 18:43:59.000000000 +0200 @@ -198,7 +198,7 @@ [b4_defines_if( [b4_output_begin([b4_spec_defines_file]) b4_copyright([Skeleton interface for Bison GLR parsers in C], - [2002-2015])[ + [2002-2015, 2018])[ ]b4_cpp_guard_open([b4_spec_defines_file])[ ]b4_shared_declarations[ @@ -213,7 +213,7 @@ b4_output_begin([b4_parser_file_name]) b4_copyright([Skeleton implementation for Bison GLR parsers in C], - [2002-2015])[ + [2002-2015, 2018])[ /* C GLR parser skeleton written by Paul Hilfinger. */ @@ -808,6 +808,7 @@ *yyvalp = yyval_default; else *yyvalp = yyvsp[YYFILL (1-yyrhslen)].yystate.yysemantics.yysval;]b4_locations_if([[ + /* Default location. */ YYLLOC_DEFAULT ((*yylocp), (yyvsp - yyrhslen), yyrhslen); yystackp->yyerror_range[1].yystate.yyloc = *yylocp; ]])[ @@ -2074,6 +2075,7 @@ case N: \ yyformat = S; \ break + default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); @@ -2294,8 +2296,8 @@ { yyrule = yydefaultAction (yystate); if (yyrule == 0) - { -]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ + {]b4_locations_if([[ + yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ yyreportSyntaxError (&yystack]b4_user_args[); goto yyuser_error; } @@ -2334,8 +2336,8 @@ yystack.yyerrState -= 1; } else if (yyisErrorAction (yyaction)) - { -]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ + {]b4_locations_if([[ + yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ yyreportSyntaxError (&yystack]b4_user_args[); goto yyuser_error; } @@ -2380,8 +2382,8 @@ if (yystack.yytops.yysize == 0) yyFail (&yystack][]b4_lpure_args[, YY_("syntax error")); YYCHK1 (yyresolveStack (&yystack]b4_user_args[)); - YYDPRINTF ((stderr, "Returning to deterministic operation.\n")); -]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ + YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));]b4_locations_if([[ + yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ yyreportSyntaxError (&yystack]b4_user_args[); goto yyuser_error; } @@ -2462,9 +2464,9 @@ { while (yystates[yyk]) { - yyGLRState *yys = yystates[yyk]; -]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]] -)[ if (yys->yypred != YY_NULLPTR) + yyGLRState *yys = yystates[yyk];]b4_locations_if([[ + yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]])[ + if (yys->yypred != YY_NULLPTR) yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[); yystates[yyk] = yys->yypred; yystack.yynextFree -= 1; --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//5culUb_glr.cc 2018-06-17 19:12:30.000000000 +0200 +++ data/glr.cc 2018-06-17 18:43:59.000000000 +0200 @@ -177,7 +177,7 @@ | Print this symbol. | `--------------------*/ - inline void + void ]b4_parser_class_name[::yy_symbol_value_print_ (int yytype, const semantic_type* yyvaluep]b4_locations_if([[, const location_type* yylocationp]])[) @@ -329,7 +329,7 @@ b4_defines_if( [b4_output_begin([b4_spec_defines_file]) b4_copyright([Skeleton interface for Bison GLR parsers in C++], - [2002-2015])[ + [2002-2015, 2018])[ // C++ GLR parser skeleton written by Akim Demaille. --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//VJJlBb_lalr1.cc 2018-06-17 19:12:30.000000000 +0200 +++ data/lalr1.cc 2018-06-17 18:43:59.000000000 +0200 @@ -131,7 +131,7 @@ m4_pushdef([b4_copyright_years], - [2002-2015]) + [2002-2015, 2018]) m4_define([b4_parser_class_name], [b4_percent_define_get([[parser_class_name]])]) @@ -142,9 +142,9 @@ m4_include(b4_pkgdatadir/[stack.hh]) b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])]) -# b4_shared_declarations -# ---------------------- -# Declaration that might either go into the header (if --defines) +# b4_shared_declarations(hh|cc) +# ----------------------------- +# Declaration that might either go into the header (if --defines, $1 = hh) # or open coded in the parser body. m4_define([b4_shared_declarations], [b4_percent_code_get([[requires]])[ @@ -314,6 +314,8 @@ typedef basic_symbol<by_state> super_type; /// Construct an empty symbol. stack_symbol_type (); + /// Copy construct. + stack_symbol_type (const stack_symbol_type& that); /// Steal the contents from \a sym to build this. stack_symbol_type (state_type s, symbol_type& sym); /// Assignment, needed by push_back. @@ -342,7 +344,7 @@ void yypush_ (const char* m, state_type s, symbol_type& sym); /// Pop \a n symbols the three stacks. - void yypop_ (unsigned int n = 1); + void yypop_ (unsigned n = 1); /// Constants. enum @@ -359,8 +361,8 @@ ]b4_parse_param_vars[ }; -]b4_token_ctor_if([b4_yytranslate_define -b4_public_types_define])[ +]b4_token_ctor_if([b4_yytranslate_define([$1])[ +]b4_public_types_define([$1])])[ ]b4_namespace_close[ ]b4_percent_define_flag_if([[global_tokens_and_yystype]], @@ -386,7 +388,7 @@ // C++ LALR(1) parser skeleton written by Akim Demaille. ]b4_cpp_guard_open([b4_spec_defines_file])[ -]b4_shared_declarations[ +]b4_shared_declarations(hh)[ ]b4_cpp_guard_close([b4_spec_defines_file]) b4_output_end() ]) @@ -406,7 +408,7 @@ ]b4_null_define[ ]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]], - [b4_shared_declarations])[ + [b4_shared_declarations([cc])])[ // User implementation prologue. ]b4_user_post_prologue[ @@ -443,7 +445,7 @@ { \ *yycdebug_ << Title << ' '; \ yy_print_ (*yycdebug_, Symbol); \ - *yycdebug_ << std::endl; \ + *yycdebug_ << '\n'; \ } \ } while (false) @@ -462,9 +464,9 @@ #else // !]b4_api_PREFIX[DEBUG # define YYCDEBUG if (false) std::cerr -# define YY_SYMBOL_PRINT(Title, Symbol) YYUSE(Symbol) -# define YY_REDUCE_PRINT(Rule) static_cast<void>(0) -# define YY_STACK_PRINT() static_cast<void>(0) +# define YY_SYMBOL_PRINT(Title, Symbol) YYUSE (Symbol) +# define YY_REDUCE_PRINT(Rule) static_cast<void> (0) +# define YY_STACK_PRINT() static_cast<void> (0) #endif // !]b4_api_PREFIX[DEBUG @@ -533,27 +535,23 @@ | Symbol types. | `---------------*/ -]b4_token_ctor_if([], [b4_public_types_define])[ +]b4_token_ctor_if([], [b4_public_types_define([cc])])[ // by_state. - inline ]b4_parser_class_name[::by_state::by_state () : state (empty_state) {} - inline ]b4_parser_class_name[::by_state::by_state (const by_state& other) : state (other.state) {} - inline void ]b4_parser_class_name[::by_state::clear () { state = empty_state; } - inline void ]b4_parser_class_name[::by_state::move (by_state& that) { @@ -561,12 +559,10 @@ that.clear (); } - inline ]b4_parser_class_name[::by_state::by_state (state_type s) : state (s) {} - inline ]b4_parser_class_name[::symbol_number_type ]b4_parser_class_name[::by_state::type_get () const { @@ -576,12 +572,17 @@ return yystos_[state]; } - inline ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type () {} + ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (const stack_symbol_type& that) + : super_type (that.state]b4_locations_if([, that.location])[) + { + ]b4_variant_if([b4_symbol_variant([that.type_get ()], + [value], [copy], [that.value])], + [[value = that.value;]])[ + } - inline ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that) : super_type (s]b4_locations_if([, that.location])[) { @@ -592,7 +593,6 @@ that.type = empty_symbol; } - inline ]b4_parser_class_name[::stack_symbol_type& ]b4_parser_class_name[::stack_symbol_type::operator= (const stack_symbol_type& that) { @@ -606,7 +606,6 @@ template <typename Base> - inline void ]b4_parser_class_name[::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const { @@ -638,7 +637,6 @@ } #endif - inline void ]b4_parser_class_name[::yypush_ (const char* m, state_type s, symbol_type& sym) { @@ -646,7 +644,6 @@ yypush_ (m, t); } - inline void ]b4_parser_class_name[::yypush_ (const char* m, stack_symbol_type& s) { @@ -655,9 +652,8 @@ yystack_.push (s); } - inline void - ]b4_parser_class_name[::yypop_ (unsigned int n) + ]b4_parser_class_name[::yypop_ (unsigned n) { yystack_.pop (n); } @@ -689,7 +685,7 @@ } #endif // ]b4_api_PREFIX[DEBUG - inline ]b4_parser_class_name[::state_type + ]b4_parser_class_name[::state_type ]b4_parser_class_name[::yy_lr_goto_state_ (state_type yystate, int yysym) { int yyr = yypgoto_[yysym - yyntokens_] + yystate; @@ -699,13 +695,13 @@ return yydefgoto_[yysym - yyntokens_]; } - inline bool + bool ]b4_parser_class_name[::yy_pact_value_is_default_ (int yyvalue) { return yyvalue == yypact_ninf_; } - inline bool + bool ]b4_parser_class_name[::yy_table_value_is_error_ (int yyvalue) { return yyvalue == yytable_ninf_; @@ -736,7 +732,7 @@ // avoid gratuitous conflicts when merging into the master branch. try { - YYCDEBUG << "Starting parse" << std::endl; + YYCDEBUG << "Starting parse\n"; ]m4_ifdef([b4_initial_action], [ b4_dollar_pushdef([yyla.value], [], [yyla.location])dnl @@ -753,7 +749,7 @@ // A new symbol was pushed on the stack. yynewstate: - YYCDEBUG << "Entering state " << yystack_[0].state << std::endl; + YYCDEBUG << "Entering state " << yystack_[0].state << '\n'; // Accept? if (yystack_[0].state == yyfinal_) @@ -827,7 +823,7 @@ yylen = yyr2_[yyn]; { stack_symbol_type yylhs; - yylhs.state = yy_lr_goto_state_(yystack_[yylen].state, yyr1_[yyn]);]b4_variant_if([ + yylhs.state = yy_lr_goto_state_ (yystack_[yylen].state, yyr1_[yyn]);]b4_variant_if([ /* Variants are always initialized to an empty instance of the correct type. The default '$$ = $1' action is NOT applied when using variants. */ @@ -844,10 +840,11 @@ yylhs.value = yystack_@{0@}.value;])[ ]b4_locations_if([dnl [ - // Compute the default @@$. + // Default location. { slice<stack_symbol_type, stack_type> slice (yystack_, yylen); YYLLOC_DEFAULT (yylhs.location, slice, yylen); + yyerror_range[1].location = yylhs.location; }]])[ // Perform the reduction. @@ -918,8 +915,7 @@ YYERROR and the label yyerrorlab therefore never appears in user code. */ if (false) - goto yyerrorlab;]b4_locations_if([[ - yyerror_range[1].location = yystack_[yylen - 1].location;]])[ + goto yyerrorlab; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ yypop_ (yylen); @@ -993,8 +989,7 @@ } catch (...) { - YYCDEBUG << "Exception caught: cleaning lookahead and stack" - << std::endl; + YYCDEBUG << "Exception caught: cleaning lookahead and stack\n"; // Do not try to display the values of the reclaimed symbols, // as their printer might throw an exception. if (!yyla.empty ()) @@ -1013,7 +1008,7 @@ ]b4_parser_class_name[::error (const syntax_error& yyexc) { error (]b4_join(b4_locations_if([yyexc.location]), - [[yyexc.what()]])[); + [[yyexc.what ()]])[); } // Generate an error message. @@ -1091,12 +1086,13 @@ case N: \ yyformat = S; \ break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); + default: // Avoid compiler warnings. + YYCASE_ (0, YY_("syntax error")); + YYCASE_ (1, YY_("syntax error, unexpected %s")); + YYCASE_ (2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_ (3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_ (4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_ (5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); #undef YYCASE_ } @@ -1144,18 +1140,18 @@ i_end = yystack_.end (); i != i_end; ++i) *yycdebug_ << ' ' << i->state; - *yycdebug_ << std::endl; + *yycdebug_ << '\n'; } // Report on the debug stream that the rule \a yyrule is going to be reduced. void ]b4_parser_class_name[::yy_reduce_print_ (int yyrule) { - unsigned int yylno = yyrline_[yyrule]; + unsigned yylno = yyrline_[yyrule]; int yynrhs = yyr2_[yyrule]; // Print the symbols being reduced, and their result. *yycdebug_ << "Reducing stack by rule " << yyrule - 1 - << " (line " << yylno << "):" << std::endl; + << " (line " << yylno << "):\n"; // The symbols being reduced. for (int yyi = 0; yyi < yynrhs; yyi++) YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", @@ -1163,7 +1159,7 @@ } #endif // ]b4_api_PREFIX[DEBUG -]b4_token_ctor_if([], [b4_yytranslate_define])[ +]b4_token_ctor_if([], [b4_yytranslate_define([cc])])[ ]b4_namespace_close[ ]b4_epilogue[]dnl b4_output_end() --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//DsFFbb_lalr1.java 2018-06-17 19:12:30.000000000 +0200 +++ data/lalr1.java 2018-06-17 18:43:59.000000000 +0200 @@ -84,7 +84,7 @@ b4_output_begin([b4_parser_file_name]) b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java], - [2007-2015]) + [2007-2015, 2018]) b4_percent_define_ifdef([package], [package b4_percent_define_get([package]); ])[/* First part of user declarations. */ --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//ZdOy6a_location.cc 2018-06-17 19:12:30.000000000 +0200 +++ data/location.cc 2018-06-17 18:43:59.000000000 +0200 @@ -16,7 +16,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. m4_pushdef([b4_copyright_years], - [2002-2015]) + [2002-2015, 2018]) # b4_position_define # ------------------ @@ -28,19 +28,18 @@ public:]m4_ifdef([b4_location_constructors], [[ /// Construct a position. explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR, - unsigned int l = ]b4_location_initial_line[u, - unsigned int c = ]b4_location_initial_column[u) + unsigned l = ]b4_location_initial_line[u, + unsigned c = ]b4_location_initial_column[u) : filename (f) , line (l) , column (c) - { - } + {} ]])[ /// Initialization. void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULLPTR, - unsigned int l = ]b4_location_initial_line[u, - unsigned int c = ]b4_location_initial_column[u) + unsigned l = ]b4_location_initial_line[u, + unsigned c = ]b4_location_initial_column[u) { filename = fn; line = l; @@ -69,15 +68,15 @@ /// File name to which this position refers. ]b4_percent_define_get([[filename_type]])[* filename; /// Current line number. - unsigned int line; + unsigned line; /// Current column number. - unsigned int column; + unsigned column; private: /// Compute max(min, lhs+rhs) (provided min <= lhs). - static unsigned int add_ (unsigned int lhs, int rhs, unsigned int min) + static unsigned add_ (unsigned lhs, int rhs, unsigned min) { - return (0 < rhs || -static_cast<unsigned int>(rhs) < lhs + return (0 < rhs || -static_cast<unsigned>(rhs) < lhs ? rhs + lhs : min); } @@ -157,30 +156,27 @@ location (const position& b, const position& e) : begin (b) , end (e) - { - } + {} /// Construct a 0-width location in \a p. explicit location (const position& p = position ()) : begin (p) , end (p) - { - } + {} /// Construct a 0-width location in \a f, \a l, \a c. explicit location (]b4_percent_define_get([[filename_type]])[* f, - unsigned int l = ]b4_location_initial_line[u, - unsigned int c = ]b4_location_initial_column[u) + unsigned l = ]b4_location_initial_line[u, + unsigned c = ]b4_location_initial_column[u) : begin (f, l, c) , end (f, l, c) - { - } + {} ])[ /// Initialization. void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR, - unsigned int l = ]b4_location_initial_line[u, - unsigned int c = ]b4_location_initial_column[u) + unsigned l = ]b4_location_initial_line[u, + unsigned c = ]b4_location_initial_column[u) { begin.initialize (f, l, c); end = begin; @@ -278,7 +274,7 @@ inline std::basic_ostream<YYChar>& operator<< (std::basic_ostream<YYChar>& ostr, const location& loc) { - unsigned int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0; + unsigned end_col = 0 < loc.end.column ? loc.end.column - 1 : 0; ostr << loc.begin; if (loc.end.filename && (!loc.begin.filename --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//lVkZn9_stack.hh 2018-06-17 19:12:30.000000000 +0200 +++ data/stack.hh 2018-06-17 18:43:59.000000000 +0200 @@ -16,12 +16,13 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. m4_pushdef([b4_copyright_years], - [2002-2015]) + [2002-2015, 2018]) # b4_stack_define # --------------- m4_define([b4_stack_define], -[[ template <class T, class S = std::vector<T> > +[[ /// A stack with random access from its top. + template <class T, class S = std::vector<T> > class stack { public: @@ -35,20 +36,24 @@ seq_.reserve (200); } - stack (unsigned int n) + stack (unsigned n) : seq_ (n) {} - inline + /// Random access. + /// + /// Index 0 returns the topmost element. T& - operator[] (unsigned int i) + operator[] (unsigned i) { return seq_[seq_.size () - 1 - i]; } - inline + /// Random access. + /// + /// Index 0 returns the topmost element. const T& - operator[] (unsigned int i) const + operator[] (unsigned i) const { return seq_[seq_.size () - 1 - i]; } @@ -56,7 +61,6 @@ /// Steal the contents of \a t. /// /// Close to move-semantics. - inline void push (T& t) { @@ -64,9 +68,8 @@ operator[](0).move (t); } - inline void - pop (unsigned int n = 1) + pop (unsigned n = 1) { for (; n; --n) seq_.pop_back (); @@ -78,21 +81,18 @@ seq_.clear (); } - inline typename S::size_type size () const { return seq_.size (); } - inline const_iterator begin () const { return seq_.rbegin (); } - inline const_iterator end () const { @@ -111,21 +111,20 @@ class slice { public: - slice (const S& stack, unsigned int range) + slice (const S& stack, unsigned range) : stack_ (stack) , range_ (range) {} - inline const T& - operator [] (unsigned int i) const + operator [] (unsigned i) const { return stack_[range_ - i]; } private: const S& stack_; - unsigned int range_; + unsigned range_; }; ]]) --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//z85dsb_variant.hh 2018-06-17 19:12:30.000000000 +0200 +++ data/variant.hh 2018-06-17 18:43:59.000000000 +0200 @@ -27,7 +27,7 @@ m4_define([b4_symbol_variant], [m4_pushdef([b4_dollar_dollar], [$2.$3< $][3 > (m4_shift3($@))])dnl - switch ($1) +switch ($1) { b4_type_foreach([b4_type_action_])[]dnl default: --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//ojM18a_yacc.c 2018-06-17 19:12:31.000000000 +0200 +++ data/yacc.c 2018-06-17 18:43:59.000000000 +0200 @@ -1,11 +1,11 @@ -*- C -*- # Yacc compatible skeleton for Bison -# Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, -# Inc. +# Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software +# Foundation, Inc. m4_pushdef([b4_copyright_years], - [1984, 1989-1990, 2000-2015]) + [1984, 1989-1990, 2000-2015, 2018]) # 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 @@ -1207,6 +1207,7 @@ case N: \ yyformat = S; \ break + default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); @@ -1641,8 +1642,9 @@ yyval = yyvsp[1-yylen]; ]b4_locations_if( -[[ /* Default location. */ - YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);]])[ +[[ /* Default location. */ + YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); + yyerror_range[1] = yyloc;]])[ YY_REDUCE_PRINT (yyn);]b4_lac_if([[ { int yychar_backup = yychar; @@ -1782,8 +1784,7 @@ if (/*CONSTCOND*/ 0) goto yyerrorlab; -]b4_locations_if([[ yyerror_range[1] = yylsp[1-yylen]; -]])[ /* Do not reclaim the symbols of the rule whose action triggered + /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//OaTina_bison.texi 2018-06-17 19:12:31.000000000 +0200 +++ doc/bison.texi 2018-06-17 18:43:59.000000000 +0200 @@ -143,7 +143,7 @@ Examples -* RPN Calc:: Reverse polish notation calculator; +* RPN Calc:: Reverse Polish Notation Calculator; a first example with no operator precedence. * Infix Calc:: Infix (algebraic) notation calculator. Operator precedence is introduced. @@ -1493,7 +1493,7 @@ @cindex examples, simple Now we show and explain several sample programs written using Bison: a -reverse polish notation calculator, an algebraic (infix) notation +Reverse Polish Notation calculator, an algebraic (infix) notation calculator --- later extended to track ``locations'' --- and a multi-function calculator. All produce usable, though limited, interactive desk-top calculators. @@ -1503,7 +1503,7 @@ source file to try them. @menu -* RPN Calc:: Reverse polish notation calculator; +* RPN Calc:: Reverse Polish Notation Calculator; a first example with no operator precedence. * Infix Calc:: Infix (algebraic) notation calculator. Operator precedence is introduced. @@ -1516,13 +1516,12 @@ @node RPN Calc @section Reverse Polish Notation Calculator -@cindex reverse polish notation -@cindex polish notation calculator +@cindex Reverse Polish Notation @cindex @code{rpcalc} @cindex calculator, simple -The first example is that of a simple double-precision @dfn{reverse polish -notation} calculator (a calculator using postfix operators). This example +The first example is that of a simple double-precision @dfn{Reverse Polish +Notation} calculator (a calculator using postfix operators). This example provides a good starting point, since operator precedence is not an issue. The second example will illustrate how operator precedence is handled. @@ -1542,12 +1541,12 @@ @node Rpcalc Declarations @subsection Declarations for @code{rpcalc} -Here are the C and Bison declarations for the reverse polish notation +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. */ +/* Reverse Polish Notation calculator. */ @group %@{ @@ -1598,7 +1597,7 @@ @node Rpcalc Rules @subsection Grammar Rules for @code{rpcalc} -Here are the grammar rules for the reverse polish notation calculator. +Here are the grammar rules for the Reverse Polish Notation calculator. @comment file: rpcalc.y @example @@ -8933,7 +8932,7 @@ Developing a parser can be a challenge, especially if you don't understand the algorithm (@pxref{Algorithm, ,The Bison Parser Algorithm}). This -chapter explains how understand and debug a parser. +chapter explains how to understand and debug a parser. The first sections focus on the static part of the parser: its structure. They explain how to generate and read the detailed description of the @@ -10901,12 +10900,12 @@ @example [0-9]+ @{ - yylval.ival = text_to_int (yytext); - return yy::parser::INTEGER; + yylval->ival = text_to_int (yytext); + return yy::parser::token::INTEGER; @} [a-z]+ @{ - yylval.sval = new std::string (yytext); - return yy::parser::IDENTIFIER; + yylval->sval = new std::string (yytext); + return yy::parser::token::IDENTIFIER; @} @end example @@ -10915,12 +10914,12 @@ @example [0-9]+ @{ - yylval.build<int>() = text_to_int (yytext); - return yy::parser::INTEGER; + yylval->build<int> () = text_to_int (yytext); + return yy::parser::token::INTEGER; @} [a-z]+ @{ - yylval.build<std::string> = yytext; - return yy::parser::IDENTIFIER; + yylval->build<std::string> () = yytext; + return yy::parser::token::IDENTIFIER; @} @end example @@ -10929,12 +10928,12 @@ @example [0-9]+ @{ - yylval.build(text_to_int (yytext)); - return yy::parser::INTEGER; + yylval->build (text_to_int (yytext)); + return yy::parser::token::INTEGER; @} [a-z]+ @{ - yylval.build(yytext); - return yy::parser::IDENTIFIER; + yylval->build (yytext); + return yy::parser::token::IDENTIFIER; @} @end example @@ -10962,8 +10961,8 @@ 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}) +@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.token.prefix}) whose possible semantic value is @var{value} of adequate @var{value_type}. If location tracking is enabled, @@ -10983,20 +10982,18 @@ 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); +symbol_type make_IDENTIFIER (const std::string&, const location_type&); +symbol_type make_INTEGER (const int&, const location_type&); +symbol_type make_COLON (const location_type&); @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); +[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 @@ -11177,13 +11174,13 @@ void calcxx_driver::error (const yy::location& l, const std::string& m) @{ - std::cerr << l << ": " << m << std::endl; + std::cerr << l << ": " << m << '\n'; @} void calcxx_driver::error (const std::string& m) @{ - std::cerr << m << std::endl; + std::cerr << m << '\n'; @} @end example @@ -11461,13 +11458,13 @@ @comment file: calc++-scanner.ll @example -"-" 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); +"-" 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@} @{ @@ -11475,12 +11472,12 @@ long n = strtol (yytext, NULL, 10); if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE)) driver.error (loc, "integer is out of range"); - return yy::calcxx_parser::make_NUMBER(n, loc); + return yy::calcxx_parser::make_NUMBER (n, loc); @} @end group -@{id@} return yy::calcxx_parser::make_IDENTIFIER(yytext, loc); +@{id@} return yy::calcxx_parser::make_IDENTIFIER (yytext, loc); . driver.error (loc, "invalid character"); -<<EOF>> return yy::calcxx_parser::make_END(loc); +<<EOF>> return yy::calcxx_parser::make_END (loc); %% @end example @@ -11536,7 +11533,7 @@ else if (argv[i] == std::string ("-s")) driver.trace_scanning = true; else if (!driver.parse (argv[i])) - std::cout << driver.result << std::endl; + std::cout << driver.result << '\n'; else res = 1; return res; @@ -12543,7 +12540,7 @@ subdirectory, it indicates that your system's internationalization support is lacking. You can re-configure Bison with @option{--disable-nls} to turn off this support, or you can install GNU -gettext from @url{ftp://ftp.gnu.org/gnu/gettext/} and re-configure +gettext from @url{https://ftp.gnu.org/gnu/gettext/} and re-configure Bison. See the file @file{ABOUT-NLS} for more information. @@ -12572,7 +12569,7 @@ @end quotation Before you send a bug report, make sure you are using the latest -version. Check @url{ftp://ftp.gnu.org/pub/gnu/bison/} or one of its +version. Check @url{https://ftp.gnu.org/pub/gnu/bison/} or one of its mirrors. Be sure to include the version number in your bug report. If the bug is present in the latest version but not in a previous version, try to determine the most recent version which did not contain the bug. @@ -13348,7 +13345,7 @@ number of times in parallel, without interference between the various invocations. @xref{Pure Decl, ,A Pure (Reentrant) Parser}. -@item Reverse polish notation +@item Reverse Polish Notation A language in which all operators are postfix operators. @item Right recursion --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//gdBue9_bench.pl.in 2018-06-17 19:12:31.000000000 +0200 +++ etc/bench.pl.in 2018-06-17 18:43:59.000000000 +0200 @@ -738,7 +738,7 @@ void yy::parser::error(const yy::parser::location_type& loc, const std::string& msg) { - std::cerr << loc << ": " << msg << std::endl; + std::cerr << loc << ": " << msg << '\n'; } int main(int argc, char *argv[]) --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//m8Oj88_variant.yy 2018-06-17 19:12:31.000000000 +0200 +++ examples/variant.yy 2018-06-17 18:43:59.000000000 +0200 @@ -25,9 +25,9 @@ %code requires // *.hh { -#include <list> #include <string> -typedef std::list<std::string> strings_type; +#include <vector> +typedef std::vector<std::string> strings_type; } %code // *.cc @@ -43,14 +43,14 @@ static parser::symbol_type yylex (); } - // Printing a list of strings. - // Koening look up will look into std, since that's an std::list. + // Printing a vector of strings. + // Koening look up will look into std, since that's an std::vector. namespace std { std::ostream& operator<< (std::ostream& o, const strings_type& ss) { - o << "(" << &ss << ") {"; + o << '(' << &ss << ") {"; const char *sep = ""; for (strings_type::const_iterator i = ss.begin(), end = ss.end(); i != end; ++i) @@ -58,13 +58,12 @@ o << sep << *i; sep = ", "; } - return o << "}"; + return o << '}'; } } // Conversion to string. template <typename T> - inline std::string string_cast (const T& t) { @@ -80,12 +79,12 @@ %token END_OF_FILE 0; %type <::std::string> item; -%type <::std::list<std::string>> list; +%type <::std::vector<std::string>> list; %% result: - list { std::cout << $1 << std::endl; } + list { std::cout << $1 << '\n'; } ; list: @@ -135,7 +134,7 @@ void parser::error (const parser::location_type& loc, const std::string& msg) { - std::cerr << loc << ": " << msg << std::endl; + std::cerr << loc << ": " << msg << '\n'; } } --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//meSngc_gnulib 2018-06-17 19:12:31.000000000 +0200 +++ /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//ekXzec_gnulib 2018-06-17 19:12:31.000000000 +0200 @@ -1 +1 @@ -Subproject commit ea6cb044ca0ab57045900a494a0e4ae39ed5372c +Subproject commit 0d10473be6fb40c42c0d10c3417a818b0ebfcce1 --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//6vblpa_.gitignore 2018-06-17 19:12:31.000000000 +0200 +++ lib/.gitignore 2018-06-17 18:43:59.000000000 +0200 @@ -4,8 +4,7 @@ /*~ /.deps /.dirstamp -/Makefile -/Makefile.in +/_Noreturn.h /alignof.h /alloca.h /alloca.in.h @@ -15,7 +14,9 @@ /asnprintf.c /basename-lgpl.c /basename.c +/binary-io.c /binary-io.h +/bitrotate.c /bitrotate.h /c++defs.h /c-ctype.c @@ -28,8 +29,6 @@ /charset.alias /cloexec.c /cloexec.h -/close-hook.c -/close-hook.h /close-stream.c /close-stream.h /close.c @@ -56,7 +55,6 @@ /exitfail.h /fatal-signal.c /fatal-signal.h -/fclose.c /fcntl.c /fcntl.h /fcntl.in.h @@ -81,19 +79,27 @@ /fseterr.h /fstat.c /getdtablesize.c +/getopt-cdefs.in.h +/getopt-core.h +/getopt-ext.h +/getopt-pfx-core.h +/getopt-pfx-ext.h /getopt.c /getopt.h /getopt.in.h /getopt1.c /getopt_int.h +/getprogname.c +/getprogname.h /gettext.h /gnulib.mk +/hard-locale.c +/hard-locale.h /hash.c /hash.h /intprops.h /inttypes.h /inttypes.in.h -/ioctl.c /isnan.c /isnand-nolibm.h /isnand.c @@ -103,9 +109,15 @@ /isnanl.c /itold.c /ldexpl.c +/limits.h +/limits.in.h /localcharset.c /localcharset.h +/lstat.c /malloc.c +/malloca.c +/malloca.h +/math.c /math.h /math.in.h /mbrtowc.c @@ -114,12 +126,11 @@ /mbswidth.h /memchr.c /memchr.valgrind +/minmax.h /msvc-inval.c /msvc-inval.h /msvc-nothrow.c /msvc-nothrow.h -/nonblocking.c -/nonblocking.h /obstack.c /obstack.h /obstack_printf.c @@ -140,7 +151,6 @@ /printf.c /progname.c /progname.h -/quote.c /quote.h /quotearg.c /quotearg.h @@ -154,6 +164,7 @@ /ref-del.sin /sched.h /sched.in.h +/sig-handler.c /sig-handler.h /sigaction.c /signal.h @@ -182,6 +193,8 @@ /spawnp.c /sprintf.c /stamp-h1 +/stat-w32.c +/stat-w32.h /stat.c /stdbool.h /stdbool.in.h @@ -192,7 +205,6 @@ /stdio--.h /stdio-impl.h /stdio-safer.h -/stdio-write.c /stdio.h /stdio.in.h /stdlib.h @@ -213,20 +225,17 @@ /strnlen.c /strverscmp.c /sys -/sys_ioctl.h /sys_ioctl.in.h -/sys_socket.h /sys_socket.in.h -/sys_stat.h /sys_stat.in.h /sys_types.in.h -/sys_wait.h /sys_wait.in.h /sysexits.in.h /time.h /time.in.h /unistd--.h /unistd-safer.h +/unistd.c /unistd.h /unistd.in.h /unitypes.h @@ -234,6 +243,7 @@ /uniwidth /uniwidth.h /uniwidth.in.h +/unlink.c /unlocked-io.h /unsetenv.c /vasnprintf.c @@ -242,7 +252,6 @@ /vfprintf.c /vsnprintf.c /vsprintf.c -/w32sock.h /w32spawn.h /wait-process.c /wait-process.h @@ -250,6 +259,7 @@ /warn-on-use.h /wchar.h /wchar.in.h +/wctype-h.c /wctype.h /wctype.in.h /wcwidth.c @@ -260,17 +270,9 @@ /xmalloc.c /xmemdup0.c /xmemdup0.h +/xsize.c /xsize.h /xstrndup.c /xstrndup.h -/binary-io.c -/xsize.c -/bitrotate.c -/math.c -/sig-handler.c -/unistd.c -/wctype-h.c -/lstat.c -/unlink.c -/gettimeofday.c -/sys_time.in.h +/stat-time.c +/stat-time.h --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//rVgLRa_.gitignore 2018-06-17 19:12:32.000000000 +0200 +++ m4/.gitignore 2018-06-17 18:43:59.000000000 +0200 @@ -1,10 +1,10 @@ +/*~ /00gnulib.m4 +/absolute-header.m4 /alloca.m4 -/argmatch.m4 /asm-underscore.m4 /assert.m4 /calloc.m4 -/cloexec.m4 /close-stream.m4 /close.m4 /closeout.m4 @@ -12,9 +12,9 @@ /config-h.m4 /configmake.m4 /dirname.m4 -/dos.m4 /double-slash-root.m4 /dup2.m4 +/eealloc.m4 /environ.m4 /errno_h.m4 /error.m4 @@ -22,8 +22,8 @@ /exponentf.m4 /exponentl.m4 /extensions.m4 +/extern-inline.m4 /fatal-signal.m4 -/fclose.m4 /fcntl-o.m4 /fcntl.m4 /fcntl_h.m4 @@ -38,6 +38,7 @@ /fstat.m4 /getdtablesize.m4 /getopt.m4 +/getprogname.m4 /gettext.m4 /glibc2.m4 /glibc21.m4 @@ -45,12 +46,11 @@ /gnulib-common.m4 /gnulib-comp.m4 /gnulib-tool.m4 -/hash.m4 +/hard-locale.m4 /iconv.m4 /include_next.m4 /intdiv0.m4 /intl.m4 -/intl.m4~ /intldir.m4 /intlmacosx.m4 /intmax.m4 @@ -58,7 +58,6 @@ /inttypes-pri.m4 /inttypes.m4 /inttypes_h.m4 -/ioctl.m4 /isnan.m4 /isnand.m4 /isnanf.m4 @@ -73,19 +72,23 @@ /lib-link.m4 /lib-prefix.m4 /libunistring-base.m4 +/limits-h.m4 /localcharset.m4 /locale-fr.m4 /locale-ja.m4 /locale-zh.m4 /lock.m4 /longlong.m4 +/lstat.m4 /malloc.m4 +/malloca.m4 /math_h.m4 /mbrtowc.m4 /mbsinit.m4 /mbstate_t.m4 /mbswidth.m4 /memchr.m4 +/minmax.m4 /mmap-anon.m4 /mode_t.m4 /msvc-inval.m4 @@ -93,13 +96,16 @@ /multiarch.m4 /nls.m4 /nocrash.m4 +/non-recursive-gnulib-prefix-hack.m4 +/obstack-printf.m4 +/obstack.m4 /off_t.m4 +/open-cloexec.m4 /open.m4 /pathmax.m4 /perror.m4 /pipe2.m4 /po.m4 -/po.m4~ /posix_spawn.m4 /printf-frexp.m4 /printf-frexpl.m4 @@ -107,6 +113,7 @@ /printf-posix.m4 /printf.m4 /progtest.m4 +/pthread_rwlock_rdlock.m4 /quote.m4 /quotearg.m4 /raise.m4 @@ -122,8 +129,6 @@ /size_max.m4 /snprintf-posix.m4 /snprintf.m4 -/socklen.m4 -/sockpfaf.m4 /spawn-pipe.m4 /spawn_h.m4 /sprintf-posix.m4 @@ -133,7 +138,6 @@ /stddef_h.m4 /stdint.m4 /stdint_h.m4 -/stdio-safer.m4 /stdio_h.m4 /stdlib_h.m4 /stpcpy.m4 @@ -145,17 +149,16 @@ /strndup.m4 /strnlen.m4 /strverscmp.m4 -/sys_ioctl_h.m4 /sys_socket_h.m4 /sys_stat_h.m4 /sys_types_h.m4 /sys_wait_h.m4 -/sysexits.m4 /threadlib.m4 /time_h.m4 /uintmax_t.m4 /unistd-safer.m4 /unistd_h.m4 +/unlink.m4 /unlocked-io.m4 /vasnprintf.m4 /vfprintf-posix.m4 @@ -175,12 +178,5 @@ /xalloc.m4 /xsize.m4 /xstrndup.m4 -/obstack-printf.m4 -/extern-inline.m4 -/non-recursive-gnulib-prefix-hack.m4 -/absolute-header.m4 -/lstat.m4 -/unlink.m4 -/gettimeofday.m4 -/obstack.m4 -/sys_time_h.m4 +/host-cpu-c-abi.m4 +/stat-time.m4 --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//t2hUY9_.gitignore 2018-06-17 19:12:32.000000000 +0200 +++ po/.gitignore 2018-06-17 18:43:59.000000000 +0200 @@ -1,12 +1,11 @@ +/*~ /*.gmo /*.po -/*.po~ /.reference /LINGUAS /Makefile /Makefile.in /Makefile.in.in -/Makefile.in.in~ /Makevars /Makevars.template /POTFILES @@ -15,7 +14,6 @@ /boldquot.sed /[email protected] /[email protected] -/insert-header.sed /insert-header.sin /quot.sed /remove-potcdate.sed --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//lUNdWb_.gitignore 2018-06-17 19:12:32.000000000 +0200 +++ runtime-po/.gitignore 2018-06-17 18:43:59.000000000 +0200 @@ -1,12 +1,11 @@ +/*~ /*.gmo /*.po -/*.po~ /.reference /LINGUAS /Makefile /Makefile.in /Makefile.in.in -/Makefile.in.in~ /Makevars /Makevars.template /POTFILES @@ -15,7 +14,6 @@ /boldquot.sed /[email protected] /[email protected] -/insert-header.sed /insert-header.sin /quot.sed /remove-potcdate.sed --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//cALmZb_getargs.c 2018-06-17 19:12:33.000000000 +0200 +++ src/getargs.c 2018-06-17 18:43:59.000000000 +0200 @@ -64,7 +64,7 @@ /** Decode an option's key. * - * \param option option being decoded. + * \param opt option being decoded. * \param keys array of valid subarguments. * \param values array of corresponding (int) values. * \param all the all value. @@ -79,11 +79,11 @@ * flags from \c all. Thus no-none = all and no-all = none. */ static void -flag_argmatch (const char *option, - const char * const keys[], const int values[], +flag_argmatch (const char *opt, + const char *const keys[], const int values[], int all, int *flags, char *arg, size_t no) { - int value = XARGMATCH (option, arg + no, keys, values); + int value = XARGMATCH (opt, arg + no, keys, values); /* -rnone == -rno-all, and -rno-none == -rall. */ if (!value) @@ -100,7 +100,7 @@ /** Decode an option's set of keys. * - * \param option option being decoded. + * \param opt option being decoded (e.g., --report). * \param keys array of valid subarguments. * \param values array of corresponding (int) values. * \param all the all value. @@ -109,7 +109,7 @@ * If 0, then activate all the flags. */ static void -flags_argmatch (const char *option, +flags_argmatch (const char *opt, const char * const keys[], const int values[], int all, int *flags, char *args) { @@ -117,7 +117,7 @@ for (args = strtok (args, ","); args; args = strtok (NULL, ",")) { size_t no = STRPREFIX_LIT ("no-", args) ? 3 : 0; - flag_argmatch (option, keys, + flag_argmatch (opt, keys, values, all, flags, args, no); } else --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//GnPJCa_output.c 2018-06-17 19:12:33.000000000 +0200 +++ src/output.c 2018-06-17 18:43:59.000000000 +0200 @@ -358,8 +358,8 @@ for (r = 0; r < nrules; ++r) if (rules[r].action) { - fprintf (out, "b4_%scase(%d, [b4_syncline(%d, ", - rules[r].is_predicate ? "predicate_" : "", + fprintf (out, "%s(%d, [b4_syncline(%d, ", + rules[r].is_predicate ? "b4_predicate_case" : "b4_case", r + 1, rules[r].action_location.start.line); string_output (out, rules[r].action_location.start.file); fprintf (out, ")\n[ %s]])\n\n", rules[r].action); --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//Q4oS08_parse-gram.y 2018-06-17 19:12:33.000000000 +0200 +++ src/parse-gram.y 2018-06-17 18:43:59.000000000 +0200 @@ -780,7 +780,7 @@ static void add_param (param_type type, char *decl, location loc) { - static char const alphanum[26 + 26 + 1 + 10] = + static char const alphanum[26 + 26 + 1 + 10 + 1] = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "_" @@ -792,18 +792,18 @@ /* Stop on last actual character. */ for (p = decl; p[1]; p++) if ((p == decl - || ! memchr (alphanum, p[-1], sizeof alphanum)) - && memchr (alphanum, p[0], sizeof alphanum - 10)) + || ! memchr (alphanum, p[-1], sizeof alphanum - 1)) + && memchr (alphanum, p[0], sizeof alphanum - 10 - 1)) name_start = p; /* Strip the surrounding '{' and '}', and any blanks just inside the braces. */ --p; - while (c_isspace ((unsigned char) *p)) + while (c_isspace ((unsigned char) *p)) --p; p[1] = '\0'; ++decl; - while (c_isspace ((unsigned char) *decl)) + while (c_isspace ((unsigned char) *decl)) ++decl; } --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//xRSGOb_autoconf 2018-06-17 19:12:34.000000000 +0200 +++ /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//RHUuNb_autoconf 2018-06-17 19:12:34.000000000 +0200 @@ -1 +1 @@ -Subproject commit 9e087dd343b67ac58a7f54e08335ac62fc33ed53 +Subproject commit 487d6aaaa4fe45001d30c439ea6240fc74f1b5d7 --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//roJ20a_actions.at 2018-06-17 19:12:34.000000000 +0200 +++ tests/actions.at 2018-06-17 18:43:59.000000000 +0200 @@ -203,7 +203,7 @@ ]AT_YYLEX_DECLARE[ } %% -exp: { ]AT_SKEL_CC_IF([[std::cerr << @$ << std::endl]], +exp: { ]AT_SKEL_CC_IF([[std::cerr << @$ << '\n']], [[LOCATION_PRINT(stderr, @$); fputc ('\n', stderr)]])[; } %% ]AT_YYERROR_DEFINE[ @@ -475,7 +475,7 @@ /* Display the symbol type Symbol. */ #define V(Symbol, Value, Location, Sep) \ - fprintf (stderr, #Symbol " (%d@%d-%d)" Sep, Value, RANGE(Location)) + fprintf (stderr, #Symbol " (%d@%d-%d)%s", Value, RANGE(Location), Sep) } $5 @@ -490,15 +490,17 @@ ]AT_LALR1_CC_IF([], [AT_YYERROR_DECLARE]) [} -]m4_ifval([$6], [%type <ival> '(' 'x' 'y' ')' ';' thing line input END])[ +]m4_ifval([$6], +[%type <ival> '(' 'x' 'y' ')' ';' thing line input + '!' raise check-spontaneous-errors END])[ /* FIXME: This %printer isn't actually tested. */ %printer { - ]AT_LALR1_CC_IF([debug_stream () << $$;], - [fprintf (yyoutput, "%d", $$)])[; + ]AT_LALR1_CC_IF([yyo << $$;], + [fprintf (yyo, "%d", $$)])[; } - input line thing 'x' 'y' + '(' 'x' 'y' ')' ';' thing line input '!' raise check-spontaneous-errors END %destructor { fprintf (stderr, "Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); } @@ -513,6 +515,14 @@ thing %destructor + { fprintf (stderr, "Freeing raise thing (%d@%d-%d)\n", $$, RANGE (@$)); } + raise + +%destructor + { fprintf (stderr, "Freeing check-spontaneous-errors thing (%d@%d-%d)\n", $$, RANGE (@$)); } + check-spontaneous-errors + +%destructor { fprintf (stderr, "Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); } 'x' @@ -534,7 +544,7 @@ */ input: - /* Nothing. */ + %empty { $$ = 0; V(input, $$, @$, ": /* Nothing */\n"); @@ -547,6 +557,38 @@ V(line, $1, @1, " "); V(input, $2, @2, "\n"); } +| '!' check-spontaneous-errors + { + $$ = $2; + } +; + +check-spontaneous-errors: + raise { abort(); $$ = $1; } +| '(' raise ')' { abort(); $$ = $2; } +| error + { + $$ = 5; + V(check-spontaneous-errors, $$, @$, ": "); + fprintf (stderr, "error (@%d-%d)\n", RANGE(@1)); + } +; + +raise: + %empty + { + $$ = 4; + V(raise, $$, @$, ": %empty\n"); + YYERROR; + } +| '!' '!' + { + $$ = 5; + V(raise, $$, @$, ": "); + V(!, $1, @2, " "); + V(!, $2, @2, "\n"); + YYERROR; + } ; line: @@ -668,6 +710,38 @@ Successful parse. ]]) +# Check the location of empty reductions raising an error +# ------------------------------------------------------- +# Here, the error is after token "!@0-9", so the error is raised from +# @9-9, and the error recovery detects that it starts from @9-9 and +# ends where starts the next token: END@10-19. +# +# So error recovery reports error@9-19. +AT_PARSER_CHECK([./input '!'], 0, [], +[[sending: '!' (0@0-9) +sending: END (1@10-19) +raise (4@9-9): %empty +check-spontaneous-errors (5@9-19): error (@9-19) +Freeing token END (1@10-19) +Freeing nterm input (5@0-19) +Successful parse. +]]) + +# Check the location of not empty reductions raising an error +# ----------------------------------------------------------- +# This time the error is raised from a rule with 2 rhs symbols: @10-29. +# It is recovered @10-29. +AT_PARSER_CHECK([[./input '!!!']], 0, [], +[[sending: '!' (0@0-9) +sending: '!' (1@10-19) +sending: '!' (2@20-29) +raise (5@10-29): ! (1@20-29) ! (2@20-29) +check-spontaneous-errors (5@10-29): error (@10-29) +sending: END (3@30-39) +Freeing token END (3@30-39) +Freeing nterm input (5@0-29) +Successful parse. +]]) # Check locations in error recovery # --------------------------------- --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//niZBG9_atlocal.in 2018-06-17 19:12:34.000000000 +0200 +++ tests/atlocal.in 2018-06-17 18:43:59.000000000 +0200 @@ -16,8 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -# We need 'config.h'. -CPPFLAGS="-I$abs_top_builddir/lib @CPPFLAGS@" +# We need 'config.h' (builddir/lib), and the gnulib headers (srcdir/lib). +CPPFLAGS="-I$abs_top_srcdir/lib -I$abs_top_builddir/lib @CPPFLAGS@" # Don't just check if $POSIXLY_CORRECT is set, as Bash, when launched # as /bin/sh, sets the shell variable POSIXLY_CORRECT to y, but not @@ -69,7 +69,7 @@ int main () { - std::cout << "Works" << std::endl; + std::cout << "Works\n"; } EOF $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS $LIBS -o conftest conftest.cc --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//nIgUYa_c++.at 2018-06-17 19:12:34.000000000 +0200 +++ tests/c++.at 2018-06-17 18:43:59.000000000 +0200 @@ -49,7 +50,7 @@ os << in; if (os.str () != s) { - std::cerr << "fail: " << os.str () << ", expected: " << s << std::endl; + std::cerr << "fail: " << os.str () << ", expected: " << s << '\n'; return false; } return true; @@ -96,7 +97,7 @@ AT_KEYWORDS([variant]) AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc" %debug $1]) -# Store strings and integers in a list of strings. +# Store strings and integers in a vector of strings. AT_DATA_GRAMMAR([list.y], [[%skeleton "lalr1.cc" %define api.value.type variant @@ -114,20 +115,20 @@ } %token <int> INT "int" -%type < std::list<int> > exp +%type < std::vector<int> > exp %printer { yyo << $$; } <int> %printer { - for (std::list<int>::const_iterator i = $$.begin (); i != $$.end (); ++i) + for (std::vector<int>::const_iterator i = $$.begin (); i != $$.end (); ++i) { if (i != $$.begin ()) yyo << ", "; yyo << *i; } - } < std::list<int> > + } < std::vector<int> > -%code requires { #include <list> } +%code requires { #include <vector> } %code { int yylex (yy::parser::semantic_type* yylval); } %% @@ -140,13 +141,13 @@ { { yy::parser::symbol_type s = yy::parser::make_INT(12); - std::cerr << s.value.as<int>() << std::endl; + std::cerr << s.value.as<int>() << '\n'; } { yy::parser::symbol_type s = yy::parser::make_INT(123); yy::parser::stack_symbol_type ss(1, s); - std::cerr << ss.value.as<int>() << std::endl; + std::cerr << ss.value.as<int>() << '\n'; } { @@ -185,7 +186,7 @@ [AT_SETUP([Variants $1]) AT_BISON_OPTION_PUSHDEFS([%debug $1]) -# Store strings and integers in a list of strings. +# Store strings and integers in a vector of strings. AT_DATA_GRAMMAR([list.y], [[%debug %define api.value.type variant @@ -194,29 +195,25 @@ %code requires // code for the .hh file { -#include <list> +#include <vector> #include <string> -typedef std::list<std::string> strings_type; +typedef std::vector<std::string> strings_type; } -%code // code for the .cc file +%code top // code for the .cc file. { #include <cstdlib> // abort, getenv #include <iostream> +#include <vector> #include <sstream> +#include <string> - namespace yy - { - static]AT_TOKEN_CTOR_IF([[ - parser::symbol_type yylex ()]], [[ - parser::token_type yylex (parser::semantic_type* yylval]AT_LOCATION_IF([, - parser::location_type* yylloc])[)]])[; - } - // Printing a list of strings (for %printer). - // Koening look up will look into std, since that's an std::list. - namespace std + typedef std::vector<std::string> strings_type; + + namespace yy { + // Must be available early, as is used in %destructor. std::ostream& operator<<(std::ostream& o, const strings_type& s) { @@ -230,16 +227,27 @@ return o << ')'; } } +} - // Conversion to string. - template <typename T> - inline - std::string - to_string (const T& t) +%code // code for the .cc file. +{ + namespace yy { - std::ostringstream o; - o << t; - return o.str (); + static]AT_TOKEN_CTOR_IF([[ + parser::symbol_type yylex ()]], [[ + parser::token_type yylex (parser::semantic_type* yylval]AT_LOCATION_IF([, + parser::location_type* yylloc])[)]])[; + + // Conversion to string. + template <typename T> + inline + std::string + to_string (const T& t) + { + std::ostringstream o; + o << t; + return o.str (); + } } } @@ -252,16 +260,16 @@ // Using the template type to exercize its parsing. // Starting with :: to ensure we don't output "<::" which starts by the // digraph for the left square bracket. -%type <::std::list<std::string>> list; +%type <::std::vector<std::string>> list; %printer { yyo << $$; } - <int> <::std::string> <::std::list<std::string>>; + <int> <::std::string> <::std::vector<std::string>>; %destructor { std::cerr << "Destroy: " << $$ << '\n'; } <*>; %destructor { std::cerr << "Destroy: \"" << $$ << "\"\n"; } <::std::string>; %% result: - list { std::cout << $][1 << std::endl; } + list { std::cout << $][1 << '\n'; } ; list: @@ -497,7 +505,7 @@ ]$1[::parser::error (const ]$1[::parser::location_type &loc, const std::string &msg) { - std::cerr << "At " << loc << ": " << msg << std::endl; + std::cerr << "At " << loc << ": " << msg << '\n'; } ]AT_MAIN_DEFINE[ @@ -565,7 +573,7 @@ %nonassoc 'a' ; %destructor { - std::cerr << "Discarding 'a'." << std::endl; + std::cerr << "Discarding 'a'.\n"; } 'a' %% @@ -574,7 +582,7 @@ error-reduce: 'a' 'a' consistent-error 'a' { USE (($1, $2, $4)); } -| 'a' error { std::cerr << "Reducing 'a'." << std::endl; USE ($1); } +| 'a' error { std::cerr << "Reducing 'a'.\n"; USE ($1); } ; consistent-error: @@ -598,7 +606,7 @@ void yy::parser::error (const std::string &m) { - std::cerr << m << std::endl; + std::cerr << m << '\n'; } ]AT_MAIN_DEFINE[ @@ -626,6 +634,7 @@ AT_DATA_GRAMMAR([[input.y]], [[%skeleton "lalr1.cc" +%defines %code { @@ -644,7 +653,7 @@ ; thing: - error { std::cerr << "caught error" << std::endl; } + error { std::cerr << "caught error\n"; } | item ; @@ -657,6 +666,17 @@ %% +void +yy::parser::error (const std::string &m) +{ + std::cerr << "error: " << m << '\n'; +} +]AT_MAIN_DEFINE[ +]]) + +AT_DATA_SOURCE([input-scan.cc], +[[#include "input.hh" + int yylex (yy::parser::semantic_type *) { @@ -670,16 +690,9 @@ return res; } } - -void -yy::parser::error (const std::string &m) -{ - std::cerr << "error: " << m << std::endl; -} -]AT_MAIN_DEFINE[ ]]) -AT_FULL_COMPILE([[input]]) +AT_FULL_COMPILE([[input]], [[scan]]) AT_PARSER_CHECK([[./input]], [[0]], [[]], [[error: invalid expression @@ -757,6 +770,12 @@ Object::instances.erase (i); } + Object& operator= (const Object& that) + { + val = that.val; + return *this; + } + Object& operator= (char v) { val = v; @@ -790,7 +809,7 @@ std::cerr << sep << *i; sep = ", "; } - std::cerr << " }" << std::endl; + std::cerr << " }\n"; } } }; @@ -922,11 +941,11 @@ } catch (const std::exception& e) { - std::cerr << "exception caught: " << e.what () << std::endl; + std::cerr << "exception caught: " << e.what () << '\n'; } catch (...) { - std::cerr << "unknown exception caught" << std::endl; + std::cerr << "unknown exception caught\n"; } Object::log (YY_NULLPTR, "end"); assert (Object::empty()); --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//TgSK2a_glr-regression.at 2018-06-17 19:12:34.000000000 +0200 +++ tests/glr-regression.at 2018-06-17 18:43:59.000000000 +0200 @@ -1759,23 +1760,55 @@ AT_SETUP([Predicates]) -# FIXME: We need genuine test cases with uses of %?. - AT_DATA_GRAMMAR([input.y], [[%glr-parser +%error-verbose %expect-rr 1 +%code requires +{ + #include <assert.h> + #include <stdbool.h> + bool new_syntax = false; + const char *input = YY_NULLPTR; + ]AT_YYERROR_DECLARE[ + ]AT_YYLEX_DECLARE[ +} %% -// Exercise "%?{...}" and "%? {...}". widget: - %? {new_syntax} "widget" id new_args { $$ = f($3, $4); } -| %?{!new_syntax} "widget" id old_args { $$ = f($3, $4); } + %? {new_syntax} 'w' id new_args { printf("new"); } +| %?{!new_syntax} 'w' id old_args { printf("old"); } ; -id:; -new_args:; -old_args:; +id: 'i'; +new_args: 'n'; +old_args: 'o'; %% +]AT_YYERROR_DEFINE[ + +int +yylex (void) +{ + return *input++; +} + +int +main (int argc, const char* argv[]) +{ + assert (argc == 2); (void) argc; + // First char decides whether new, or old syntax. + // Then the input. + new_syntax = argv[1][0] == 'N'; + input = argv[1] + 1; + return yyparse (); +} ]]) -AT_BISON_CHECK([[input.y]]) +AT_BISON_CHECK([[-o input.c input.y]]) +AT_COMPILE([input]) +AT_PARSER_CHECK([[./input Nwin]], [0], [new]) +AT_PARSER_CHECK([[./input Owin]], [1], [], [[syntax error, unexpected 'n', expecting 'o' +]]) +AT_PARSER_CHECK([[./input Owio]], [0], [old]) +AT_PARSER_CHECK([[./input Nwio]], [1], [], [[syntax error, unexpected 'o', expecting 'n' +]]) AT_CLEANUP --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//nCrjs9_headers.at 2018-06-17 19:12:34.000000000 +0200 +++ tests/headers.at 2018-06-17 18:43:59.000000000 +0200 @@ -181,7 +181,7 @@ do { \ int res = S; \ if (res) \ - std::cerr << #S": " << res << std::endl; \ + std::cerr << #S": " << res << '\n'; \ } while (false) int --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//XIFdW8_javapush.at 2018-06-17 19:12:34.000000000 +0200 +++ tests/javapush.at 2018-06-17 18:43:59.000000000 +0200 @@ -241,10 +241,13 @@ static StringReader getinput(String filename) throws IOException { - StringBuilder buf = new StringBuilder(); + // Yes, there are better alternatives to StringBuffer. But we + // don't really care about performances here, while portability + // to older Java matters. + StringBuffer buf = new StringBuffer(); FileReader file = new FileReader(filename); int c; - while ((c=file.read()) > 0) + while (0 < (c = file.read())) buf.append((char)c); file.close(); return new StringReader(buf.toString()); @@ -302,6 +305,13 @@ ; ]) + + +## ------------------------------------- ## +## Calc parser with api.push-pull both. ## +## ------------------------------------- ## + + # Test that the states transitioned by the push parser are the # same as for the pull parser. This test is assumed to work # if it produces the same partial trace of stack states as is @@ -577,8 +587,9 @@ ]]) AT_BISON_CHECK([PUSHPULLFLAG [-o Calc.java Calc.y]]) + AT_JAVA_COMPILE([[Calc.java]]) -#Verify that this is a push parser. +# Verify that this is a push parser. AT_CHECK_JAVA_GREP([[Calc.java]], [[.*public void push_parse_initialize().*]]) # Capture stderr output for comparison purposes. @@ -593,6 +604,13 @@ AT_BISON_OPTION_POPDEFS AT_CLEANUP + + +## ---------------------------------------------------------------- ## +## Calc parser with %locations %code lexer and api.push-pull both. ## +## ---------------------------------------------------------------- ## + + # This test looks for location reporting by looking # at the lexer output with locations enabled. # It defines a lexer that reports location info. --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//bQTiXb_local.at 2018-06-17 19:12:34.000000000 +0200 +++ tests/local.at 2018-06-17 18:43:59.000000000 +0200 @@ -539,7 +539,7 @@ void ]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; + std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << '\n'; }]]) @@ -892,7 +892,7 @@ } catch (...) { - std::cerr << "Inner caught" << std::endl; + std::cerr << "Inner caught\n"; throw; } } @@ -905,7 +905,7 @@ } catch (...) { - std::cerr << "Outer caught" << std::endl; + std::cerr << "Outer caught\n"; return 0; } return 1; --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//N17Z8a_local.mk 2018-06-17 19:12:34.000000000 +0200 +++ tests/local.mk 2018-06-17 18:43:59.000000000 +0200 @@ -108,11 +108,13 @@ $(RUN_TESTSUITE) POSIXLY_CORRECT=1 _POSIX2_VERSION=200112 .PHONY: maintainer-check-valgrind +VALGRIND_OPTS = --leak-check=full --show-reachable=yes --gen-suppressions=all \ + $(VALGRIND_OPTS_SUPPRESSION) maintainer-check-valgrind: $(RUN_TESTSUITE_deps) - test -z '$(VALGRIND)' || \ + test 'x$(VALGRIND)' != x || \ $(RUN_TESTSUITE) \ - PREBISON='$(VALGRIND_PREBISON)' PREPARSER='$(VALGRIND) -q' \ - VALGRIND_OPTS='--leak-check=full --show-reachable=yes' + PREBISON='$(VALGRIND) -q' PREPARSER='$(VALGRIND) -q' \ + VALGRIND_OPTS="$(VALGRIND_OPTS)" .PHONY: maintainer-check maintainer-check: maintainer-check-posix maintainer-check-valgrind maintainer-check-g++ --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//iMtN8a_synclines.at 2018-06-17 19:12:35.000000000 +0200 +++ tests/synclines.at 2018-06-17 18:43:59.000000000 +0200 @@ -81,7 +81,15 @@ # # "input.yy", line 80.21: 1540-0218 (S) The call does not match any parameter list for "operator<<". # "/usr/vacpp/include/iosfwd", line 32.6: 1506-205 (S) #error This file to be used only with IBM VisualAge C++ v4 and later compilers - +# +# Newer GCCs go further and if the function is declared static, complain +# that it's not used. +# +# GCC 7 also underlines the error. +# +# syncline.c:4:2: error: #error "4" +# #error "4" +# ^~~~~ AT_CHECK([[$PERL -p -0777 - stderr <<\EOF # 1. Remove useless lines. @@ -91,8 +99,8 @@ s/^clang: warning: treating 'c' input as 'c\+\+'.*\n//gm; # Function context. s/^[^:]*: In function '[^']+':\n//gm; - # Caret error. - s/^ *#error.*\n *\^\n//gm; + # Caret error (with possible '~' to underline). + s/^ *#error.*\n *\^~*\n//gm; # Number of errors. s/^1 error generated\.\n//gm; @@ -136,12 +144,15 @@ m4_define([AT_SYNCLINES_COMPILE], [# Check if we can trust location translation. AT_DATA([syncline.c], -[[#error "1" -int i; /* avoids -pedantic warning about an empty translation unit. */ +[[void foo (void); +void foo (void) +{ +#error "4" +} ]]) _AT_SYNCLINES_COMPILE([syncline.c]) -AT_CHECK([[test "`cat stdout`" = 'syncline.c:1: @%:@error "1"' || exit 77]]) +AT_CHECK([[test "`cat stdout`" = 'syncline.c:4: @%:@error "4"' || exit 77]]) # Then work for real. _AT_SYNCLINES_COMPILE([$1]) --- /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//maHuYa_types.at 2018-06-17 19:12:35.000000000 +0200 +++ tests/types.at 2018-06-17 18:43:59.000000000 +0200 @@ -243,7 +243,7 @@ %define api.value.type variant], [%token <int> '1'; %token <std::string> '2';], - ['1' '2' { std::cout << $1 << ", " << $2 << std::endl; }], + ['1' '2' { std::cout << $1 << ", " << $2 << '\n'; }], ["12"], [if (res == '1') AT_VAL.build(10);
