From: Akim Demaille Date: Fri, 26 Oct 2012 14:50:26 +0000 (+0200) Subject: Merge remote-tracking branch 'origin/maint' X-Git-Tag: v2.7.90~290 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/d0a304384f4207bdf7f8b1038c2226c312f5e954 Merge remote-tracking branch 'origin/maint' * origin/maint: (46 commits) doc: minor style change maint: use gendocs's new -I option regen yacc.c: do not define location support when not using locations maint: be compilable with GCC 4.0 tests: address a warning from GCC 4.4 tests: don't use options that Clang does not support tests: restore the tests on -Werror regen parse-gram: update the Bison interface fix comment maint: post-release administrivia version 2.6.4 regen 2.6.4: botched 2.6.3 maint: post-release administrivia version 2.6.3 gnulib: update tests: check %no-lines NEWS: warnings with clang ... Conflicts: NEWS TODO data/c.m4 data/java.m4 doc/Makefile.am src/getargs.c src/getargs.h src/output.c src/parse-gram.c src/parse-gram.h src/parse-gram.y src/reader.h --- d0a304384f4207bdf7f8b1038c2226c312f5e954 diff --cc NEWS index 346c4da4,cb845125..a2ea735e --- a/NEWS +++ b/NEWS @@@ -2,246 -2,61 +2,301 @@@ GNU Bison NEW * Noteworthy changes in release ?.? (????-??-??) [?] +** Incompatible changes + +*** Obsolete features + + Support for YYFAIL is removed (deprecated in Bison 2.4.2). + Support for yystype and yyltype (instead of YYSTYPE and YYLTYPE) + is removed (deprecated in Bison 1.875). + Support for YYPARSE_PARAM is removed (deprecated in Bison 1.875). + +** Warnings + +*** Enhancements of the -Werror option + + The -Werror=CATEGORY option is now recognized, and will treat specified + warnings as errors. The warnings need not have been explicitly activated + using the -W option, this is similar to what GCC 4.7 does. + + For example, given the following command line, Bison will treat both + warnings related to POSIX Yacc incompatibilities and S/R conflicts as + errors (and only those): + + $ bison -Werror=yacc,error=conflicts-sr input.y + + If no categories are specified, -Werror will make all active warnings into + errors. For example, the following line does the same the previous example: + + $ bison -Werror -Wnone -Wyacc -Wconflicts-sr input.y + + (By default -Wconflicts-sr,conflicts-rr,deprecated,other is enabled.) + + Note that the categories in this -Werror option may not be prefixed with + "no-". However, -Wno-error[=CATEGORY] is valid. + + Note that -y enables -Werror=yacc. Therefore it is now possible to require + Yacc-like behavior (e.g., always generate y.tab.c), but to report + incompatibilities as warnings: "-y -Wno-error=yacc". + +*** The display of warnings is now richer + + The option that controls a given warning is now displayed: + + foo.y:4.6: warning: type clash on default action: != [-Wother] + + In the case of warnings treated as errors, the prefix is changed from + "warning: " to "error: ", and the suffix is displayed, in a manner similar + to GCC, as [-Werror=CATEGORY]. + + For instance, where the previous version of Bison would report (and exit + with failure): + + bison: warnings being treated as errors + input.y:1.1: warning: stray ',' treated as white space + + it now reports: + + input.y:1.1: error: stray ',' treated as white space [-Werror=other] + +*** Deprecated constructs + + The new 'deprecated' warning category flags obsolete constructs whose + support will be discontinued. It is enabled by default. These warnings + used to be reported as 'other' warnings. + +*** Useless semantic types + + Bison now warns about useless (uninhabited) semantic types. Since + semantic types are not declared to Bison (they are defined in the opaque + %union structure), it is %printer/%destructor directives about useless + types that trigger the warning: + + %token term + %type nterm + %printer {} + %destructor {} + %% + nterm: term { $$ = $1; }; + + 3.28-34: warning: type is used, but is not associated to any symbol + 4.28-34: warning: type is used, but is not associated to any symbol + +*** Undefined but unused symbols + + Bison used to raise an error for undefined symbols that are not used in + the grammar. This is now only a warning. + + %printer {} symbol1 + %destructor {} symbol2 + %type symbol3 + %% + exp: "a"; + +*** Useless destructors or printers + + Bison now warns about useless destructors or printers. In the following + example, the printer for , and the destructor for are + useless: all symbols of (token1) already have a printer, and all + symbols of type (token2) already have a destructor. + + %token token1 + token2 + token3 + token4 + %printer {} token1 + %destructor {} token2 + +*** Conflicts + + The warnings and error messages about shift/reduce and reduce/reduce + conflicts have been normalized. For instance on the following foo.y file: + + %glr-parser + %% + exp: exp '+' exp | '0' | '0'; + + compare the previous version of bison: + + $ bison foo.y + foo.y: conflicts: 1 shift/reduce, 2 reduce/reduce + $ bison -Werror foo.y + bison: warnings being treated as errors + foo.y: conflicts: 1 shift/reduce, 2 reduce/reduce + + with the new behavior: + + $ bison foo.y + foo.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] + foo.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr] + $ bison -Werror foo.y + foo.y: error: 1 shift/reduce conflict [-Werror=conflicts-sr] + foo.y: error: 2 reduce/reduce conflicts [-Werror=conflicts-rr] + + When %expect or %expect-rr is used, such as with bar.y: + + %expect 0 + %glr-parser + %% + exp: exp '+' exp | '0' | '0'; + + Former behavior: + + $ bison bar.y + bar.y: conflicts: 1 shift/reduce, 2 reduce/reduce + bar.y: expected 0 shift/reduce conflicts + bar.y: expected 0 reduce/reduce conflicts + + New one: + + $ bison bar.y + bar.y: error: shift/reduce conflicts: 1 found, 0 expected + bar.y: error: reduce/reduce conflicts: 2 found, 0 expected + +** Additional yylex/yyparse arguments + + The new directive %param declares additional arguments to both yylex and + yyparse. The %lex-param, %parse-param, and %param directives support one + or more arguments. Instead of + + %lex-param {arg1_type *arg1} + %lex-param {arg2_type *arg2} + %parse-param {arg1_type *arg1} + %parse-param {arg2_type *arg2} + + one may now declare + + %param {arg1_type *arg1} {arg2_type *arg2} + +** Java skeleton improvements + + The constants for token names were moved to the Lexer interface. Also, it + is possible to add code to the parser's constructors using "%code init" + and "%define init_throws". + +** C++ skeletons improvements + +*** The parser header is no longer mandatory (lalr1.cc, glr.cc) + + Using %defines is now optional. Without it, the needed support classes + are defined in the generated parser, instead of additional files (such as + location.hh, position.hh and stack.hh). + +*** Locations are no longer mandatory (lalr1.cc, glr.cc) + + Both lalr1.cc and glr.cc no longer require %location. + +*** syntax_error exception (lalr1.cc) + + The C++ parser features a syntax_error exception, which can be + thrown from the scanner or from user rules to raise syntax errors. + This facilitates reporting errors caught in sub-functions (e.g., + rejecting too large integral literals from a conversion function + used by the scanner, or rejecting invalid combinations from a + factory invoked by the user actions). + +** Variable api.token.prefix + + The variable api.token.prefix changes the way tokens are identified in + the generated files. This is especially useful to avoid collisions + with identifiers in the target language. For instance + + %token FILE for ERROR + %define api.token.prefix "TOK_" + %% + start: FILE for ERROR; + + will generate the definition of the symbols TOK_FILE, TOK_for, and + TOK_ERROR in the generated sources. In particular, the scanner must + use these prefixed token names, although the grammar itself still + uses the short names (as in the sample rule given above). + +** Renamed %define variables + + The following variables have been renamed for consistency. Backward + compatibility is ensured, but upgrading is recommended. + + lr.default-reductions -> lr.default-reduction + lr.keep-unreachable-states -> lr.keep-unreachable-state + namespace -> api.namespace + +** Variable parse.error + + This variable controls the verbosity of error messages. The use of the + %error-verbose directive is deprecated in favor of "%define parse.error + verbose". + +** Semantic predicates + + The new, experimental, semantic-predicate feature allows actions of the + form "%?{ BOOLEAN-EXPRESSION }", which cause syntax errors (as for + YYERROR) if the expression evaluates to 0, and are evaluated immediately + in GLR parsers, rather than being deferred. The result is that they allow + the programmer to prune possible parses based on the values of run-time + expressions. + +** The directive %expect-rr is now an error in non GLR mode + + It used to be an error only if used in non GLR mode, _and_ if there are + reduce/reduce conflicts. + +* Noteworthy changes in release ?.? (????-??-??) [?] + + ** Changes in the format of error messages + + This used to be the format of many error reports: + + foo.y:5.10-24: result type clash on merge function 'merge': != + foo.y:4.13-27: previous declaration + + It is now: + + foo.y:5.10-25: result type clash on merge function 'merge': != + foo.y:4.13-27: previous declaration + + ** Exception safety (lalr1.cc) + + The parse function now catches exceptions, uses the %destructors to + release memory (the lookahead symbol and the symbols pushed on the stack) + before re-throwing the exception. + + This feature is somewhat experimental. User feedback would be + appreciated. + + ** New %define variable: api.location.type (glr.cc, lalr1.cc, lalr1.java) + + The %define variable api.location.type defines the name of the type to use + for locations. When defined, Bison no longer generates the position.hh + and location.hh files, nor does the parser will include them: the user is + then responsible to define her type. + + This can be used in programs with several parsers to factor their location + and position files: let one of them generate them, and the others just use + them. + + This feature was actually introduced, but not documented, in Bison 2.5, + under the name "location_type" (which is maintained for backward + compatibility). + + For consistency, lalr1.java's %define variables location_type and + position_type are deprecated in favor of api.location.type and + api.position.type. + + ** Graphviz improvements + + The graphical presentation of the states is more readable: their shape is + now rectangular, the state number is clearly displayed, and the items are + numbered and left-justified. + + The reductions are now explicitly represented as transitions to other + diamond shaped nodes. + + * Noteworthy changes in release 2.6.4 (2012-10-23) [stable] + + Bison 2.6.3's --version was incorrect. This release fixes this issue. + + * Noteworthy changes in release 2.6.3 (2012-10-22) [stable] + ** Bug fixes Bugs and portability issues in the test suite have been fixed. @@@ -380,7 -155,7 +395,7 @@@ * Noteworthy changes in release 2.6 (2012-07-19) [stable] - ** Future changes: -** Future Changes ++** Future changes The next major release of Bison will drop support for the following deprecated features. Please report disagreements to bug-bison@gnu.org. diff --cc TODO index 40127468,978b5c6f..e8509e3c --- a/TODO +++ b/TODO @@@ -1,45 -1,17 +1,57 @@@ * Short term + ** Graphviz display code thoughts + The code for the --graph option is over two files: print_graph, and + graphviz. I believe this is because Bison used to also produce VCG graphs, + but since this is no longer true, maybe we could consider these files for + fusion. + + Little effort factoring seems to have been given to factoring in these files, + and their print-xml and print counterpart. We would very much like to re-use + the pretty format of states from .output in the .dot + + Also, the underscore in print_graph.[ch] isn't very fitting considering + the dashes in the other filenames. +** push-parser +Check it too when checking the different kinds of parsers. And be +sure to check that the initial-action is performed once per parsing. + +** m4 names +b4_shared_declarations is no longer what it is. Make it +b4_parser_declaration for instance. + +** yychar in lalr1.cc +There is a large difference bw maint and master on the handling of +yychar (which was removed in lalr1.cc). See what needs to be +back-ported. + + + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action + invokes YYABORT, YYACCEPT, or YYERROR immediately after altering + yychar. In the case of YYABORT or YYACCEPT, an incorrect + destructor might then be invoked immediately. In the case of + YYERROR, subsequent parser actions might lead to an incorrect + destructor call or verbose syntax error message before the + lookahead is translated. */ + + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yytranslate_ (yychar); + + +** $ and others in epilogue +A stray $ is a warning in the actions, but an error in the epilogue. +IMHO, it should not even be a warning in the epilogue. + +** stack.hh +Get rid of it. The original idea is nice, but actually it makes +the code harder to follow, and uselessly different from the other +skeletons. + ** Variable names. What should we name `variant' and `lex_symbol'? diff --cc configure.ac index d6a86a73,955f56ef..8a297ff5 --- a/configure.ac +++ b/configure.ac @@@ -73,8 -71,19 +73,20 @@@ if test "$enable_gcc_warnings" = yes; t warn_c='-Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wshadow -Wstrict-prototypes' warn_cxx='-Wnoexcept' + AC_LANG_PUSH([C]) + # Clang supports many of GCC's -W options, but only issues warnings + # on the ones it does not recognize. In that case, gl_WARN_ADD + # thinks the option is supported, and unknown options are then added + # to CFLAGS. But then, when -Werror is added in the test suite for + # instance, the warning about the unknown option turns into an + # error. + # + # This should be addressed by gnulib's gl_WARN_ADD, but in the + # meanwhile, turn warnings about unknown options into errors in + # CFLAGS, and restore CFLAGS after the tests. + save_CFLAGS=$CFLAGS + gl_WARN_ADD([-Werror=unknown-warning-option], [CFLAGS]) for i in $warn_common $warn_c; do gl_WARN_ADD([$i], [WARN_CFLAGS]) diff --cc data/c.m4 index 179743c9,561900af..51ffbe3b --- a/data/c.m4 +++ b/data/c.m4 @@@ -556,8 -601,8 +556,8 @@@ m4_define([b4_YYDEBUG_define] # define ]b4_api_PREFIX[DEBUG 0 # endif # else /* ! defined YYDEBUG */ -# define ]b4_api_PREFIX[DEBUG ]b4_debug_flag[ +# define ]b4_api_PREFIX[DEBUG ]b4_parse_trace_if([1], [0])[ - # endif /* ! defined ]b4_api_PREFIX[DEBUG */ + # endif /* ! defined YYDEBUG */ #endif /* ! defined ]b4_api_PREFIX[DEBUG */]])[]dnl ]) diff --cc doc/local.mk index 54c03ebf,00000000..53c0142d mode 100644,000000..100644 --- a/doc/local.mk +++ b/doc/local.mk @@@ -1,141 -1,0 +1,171 @@@ +## Copyright (C) 2001-2003, 2005-2012 Free Software Foundation, Inc. + +## This program is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see . + +AM_MAKEINFOFLAGS = --no-split +info_TEXINFOS = doc/bison.texi +doc_bison_TEXINFOS = \ + $(CROSS_OPTIONS_TEXI) \ + doc/fdl.texi \ + doc/gpl-3.0.texi + +TEXI2DVI = texi2dvi --build-dir=doc/bison.t2d +CLEANDIRS = doc/bison.t2d +clean-local: + rm -rf $(CLEANDIRS) + +MOSTLYCLEANFILES += $(top_srcdir)/doc/*.t + +CROSS_OPTIONS_PL = $(top_srcdir)/build-aux/cross-options.pl +CROSS_OPTIONS_TEXI = $(top_srcdir)/doc/cross-options.texi +$(CROSS_OPTIONS_TEXI): doc/bison.help $(CROSS_OPTIONS_PL) +# Create $@~ which is the previous contents. Don't use `mv' here so +# that even if we are interrupted, the file is still available for +# diff in the next run. Note that $@ might not exist yet. + $(AM_V_GEN){ test ! -f $@ || cat $@; } >$@~ + $(AM_V_at)test ! -f $@.tmp || rm -f $@.tmp + $(AM_V_at)src/bison$(EXEEXT) --help | \ + $(PERL) $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l >$@.tmp + $(AM_V_at)diff -u $@~ $@.tmp || true + $(AM_V_at)mv $@.tmp $@ +MAINTAINERCLEANFILES = $(CROSS_OPTIONS_TEXI) + +## ---------- ## +## Ref card. ## +## ---------- ## + +EXTRA_DIST += doc/refcard.tex +CLEANFILES += doc/refcard.pdf + +doc/refcard.pdf: doc/refcard.tex + $(AM_V_GEN) cd doc && pdftex $(abs_top_srcdir)/doc/refcard.tex + + + +## ---------------- ## +## doc/bison.help. ## +## ---------------- ## + +# Some of our targets (cross-option.texi, bison.1) use "bison --help". +# Since we want to ship the generated file to avoid additional +# requirements over the user environment, we used not depend on +# src/bison itself, but on src/getargs.c and other files. Yet, we +# need "bison --help" to work to make help2man happy, so we used to +# include "make src/bison" in the commands. Then we may have a +# problem with concurrent builds, since one make might be aiming one +# of its jobs at compiling src/bison, and another job at generating +# the man page. If the latter is faster than the former, then we have +# two makes that concurrently try to compile src/bison. Doomed to +# failure. +# +# As a simple scheme to get our way out, make a stamp file, +# bison.help, which contains --version then --help. This file can +# depend on bison, which ensures its correctness. But update it +# *only* if needed (content changes). This way, we avoid useless +# compilations of cross-option.texi and bison.1. At the cost of +# repeated builds of bison.help. + +EXTRA_DIST += $(top_srcdir)/doc/bison.help +MAINTAINERCLEANFILES += $(top_srcdir)/doc/bison.help +$(top_srcdir)/doc/bison.help: src/bison$(EXEEXT) + $(AM_V_GEN)src/bison$(EXEEXT) --version >doc/bison.help.tmp + $(AM_V_at) src/bison$(EXEEXT) --help >>doc/bison.help.tmp + $(AM_V_at)$(top_srcdir)/build-aux/move-if-change doc/bison.help.tmp $@ + + +## ----------- ## +## Man Pages. ## +## ----------- ## + +dist_man_MANS = $(top_srcdir)/doc/bison.1 + +EXTRA_DIST += $(dist_man_MANS:.1=.x) +MAINTAINERCLEANFILES += $(dist_man_MANS) + +# Differences to ignore when comparing the man page (the date). +remove_time_stamp = \ + sed 's/^\(\.TH[^"]*"[^"]*"[^"]*\)"[^"]*"/\1/' + +# Depend on configure to get version number changes. +$(top_srcdir)/doc/bison.1: doc/bison.help doc/bison.x $(top_srcdir)/configure + $(AM_V_GEN)$(HELP2MAN) \ + --include=$(top_srcdir)/doc/bison.x \ + --output=$@.t src/bison$(EXEEXT) + $(AM_V_at)if $(remove_time_stamp) $@ >$@a.t 2>/dev/null && \ + $(remove_time_stamp) $@.t | cmp $@a.t - >/dev/null 2>&1; then \ + touch $@; \ + else \ + mv $@.t $@; \ + fi + $(AM_V_at)rm -f $@*.t + +nodist_man_MANS = doc/yacc.1 + ++## ----------------------------- ## ++## Graphviz examples generation. ## ++## ----------------------------- ## ++ ++CLEANDIRS += doc/figs ++FIGS_DOT = doc/figs/example-reduce.dot doc/figs/example-shift.dot ++EXTRA_DIST += \ ++ $(FIGS_DOT) \ ++ $(FIGS_DOT:.dot=.eps) $(FIGS_DOT:.dot=.pdf) $(FIGS_DOT:.dot=.png) ++SUFFIXES += .dot .eps .pdf .png ++ ++bison.dvi: $(FIGS_DOT:.dot=.eps) ++bison.html: $(FIGS_DOT:.dot=.png) ++bison.pdf: $(FIGS_DOT:.dot=.pdf) ++ ++.dot.eps: ++ $(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'` ++ $(AM_V_at) $(DOT) -Gmargin=0 -Teps $< >$@.tmp ++ $(AM_V_at) mv $@.tmp $@ ++ ++.dot.pdf: ++ $(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'` ++ $(AM_V_at) $(DOT) -Gmargin=0 -Tpdf $< >$@.tmp ++ $(AM_V_at) mv $@.tmp $@ ++ ++.dot.png: ++ $(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'` ++ $(AM_V_at) $(DOT) -Gmargin=0 -Tpng $< >$@.tmp ++ $(AM_V_at) mv $@.tmp $@ ++ +## -------------- ## +## Doxygenation. ## +## -------------- ## + +DOXYGEN = doxygen + +.PHONY: doc html + +doc: html + +html-local: doc/Doxyfile + $(AM_V_GEN) $(DOXYGEN) doc/Doxyfile + +edit = sed -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \ + -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \ + -e 's,@PERL\@,$(PERL),g' \ + -e 's,@top_builddir\@,$(top_builddir),g' \ + -e 's,@top_srcdir\@,$(top_srcdir),g' + +EXTRA_DIST += doc/Doxyfile.in +CLEANFILES += doc/Doxyfile +# Sed is used to generate Doxyfile from Doxyfile.in instead of +# configure, because the former is way faster than the latter. +doc/Doxyfile: $(top_srcdir)/doc/Doxyfile.in + $(AM_V_GEN) $(edit) $(top_srcdir)/doc/Doxyfile.in >doc/Doxyfile + +CLEANDIRS += doc/html diff --cc gnulib index dcf27bef,0e6a848c..60619793 --- a/gnulib +++ b/gnulib @@@ -1,1 -1,1 +1,1 @@@ - Subproject commit dcf27bef48c9800d5a2be8349226f73f1b8ff2e5 -Subproject commit 0e6a848c8cd1e9442e3794c7dcd2f535ea9797c6 ++Subproject commit 6061979365c067965ee376b3d0a65819779a89c5 diff --cc src/parse-gram.y index 1624dde5,5f77a5bd..6e58835a --- a/src/parse-gram.y +++ b/src/parse-gram.y @@@ -52,50 -51,57 +52,50 @@@ static void version_check (location con static void gram_error (location const *, char const *); static char const *char_name (char); +%} -/** Add a lex-param or a parse-param. - * - * \param type \a lex_param or \a parse_param - * \param decl the formal argument - * \param loc the location in the source. - */ -static void add_param (char const *type, char *decl, location loc); - - -static symbol_class current_class = unknown_sym; -static uniqstr current_type = NULL; -static symbol *current_lhs_symbol; -static location current_lhs_location; -static named_ref *current_lhs_named_ref; -static int current_prec = 0; - -/** Set the new current left-hand side symbol, possibly common - * to several right-hand side parts of rule. - */ -static -void -current_lhs(symbol *sym, location loc, named_ref *ref) +%code { - current_lhs_symbol = sym; - current_lhs_location = loc; - /* In order to simplify memory management, named references for lhs - are always assigned by deep copy into the current symbol_list - node. This is because a single named-ref in the grammar may - result in several uses when the user factors lhs between several - rules using "|". Therefore free the parser's original copy. */ - free (current_lhs_named_ref); - current_lhs_named_ref = ref; -} - + static int current_prec = 0; + static location current_lhs_location; + static named_ref *current_lhs_named_ref; + static symbol *current_lhs_symbol; + static symbol_class current_class = unknown_sym; + static uniqstr current_type = NULL; + + /** Set the new current left-hand side symbol, possibly common + * to several right-hand side parts of rule. + */ + static + void + current_lhs(symbol *sym, location loc, named_ref *ref) + { + current_lhs_symbol = sym; + current_lhs_location = loc; + /* In order to simplify memory management, named references for lhs + are always assigned by deep copy into the current symbol_list + node. This is because a single named-ref in the grammar may + result in several uses when the user factors lhs between several + rules using "|". Therefore free the parser's original copy. */ + free (current_lhs_named_ref); + current_lhs_named_ref = ref; + } -#define YYTYPE_INT16 int_fast16_t -#define YYTYPE_INT8 int_fast8_t -#define YYTYPE_UINT16 uint_fast16_t -#define YYTYPE_UINT8 uint_fast8_t -%} + #define YYTYPE_INT16 int_fast16_t + #define YYTYPE_INT8 int_fast8_t + #define YYTYPE_UINT16 uint_fast16_t + #define YYTYPE_UINT8 uint_fast8_t +} - %verbose - %defines - %define locations -%debug + %define api.prefix "gram_" %define api.pure ++%define locations +%define parse.error verbose %define parse.lac full +%define parse.trace - %name-prefix "gram_" + %defines -%error-verbose %expect 0 -%locations + %verbose %initial-action { diff --cc src/print_graph.c index ca1dc24e,d5ec5fb4..5aa3cc62 --- a/src/print_graph.c +++ b/src/print_graph.c @@@ -69,12 -91,14 +91,14 @@@ print_core (struct obstack *oout, stat r = item_number_as_rule_number (*sp); - obstack_printf (oout, "%d: %s -> ", r, escape (rules[r].lhs->tag)); + obstack_printf (oout, "%3d ", r); + print_lhs (oout, previous_rule, &rules[r]); + previous_rule = &rules[r]; for (sp = rules[r].rhs; sp < sp1; sp++) - obstack_printf (oout, " %s", escape (symbols[*sp]->tag)); + obstack_printf (oout, "%s ", escape (symbols[*sp]->tag)); - obstack_1grow (oout, '.'); + obstack_sgrow (oout, " ."); for (/* Nothing */; *sp >= 0; ++sp) obstack_printf (oout, " %s", escape (symbols[*sp]->tag)); diff --cc src/reader.h index 2a78f30a,e154deb0..badd372d --- a/src/reader.h +++ b/src/reader.h @@@ -51,9 -51,9 +51,9 @@@ void grammar_current_rule_prec_set (sym void grammar_current_rule_dprec_set (int dprec, location loc); void grammar_current_rule_merge_set (uniqstr name, location loc); void grammar_current_rule_symbol_append (symbol *sym, location loc, - named_ref *named_ref); - named_ref *nref); ++ named_ref *nref); void grammar_current_rule_action_append (const char *action, location loc, - named_ref *named_ref, bool); - named_ref *nref); ++ named_ref *nref, bool); void reader (void); void free_merger_functions (void); diff --cc tests/local.at index ac266daa,f172b244..bddcb00e --- a/tests/local.at +++ b/tests/local.at @@@ -465,55 -462,59 +465,59 @@@ m4_define([AT_BISON_CHECK_WARNINGS] [m4_null_if([$2], [AT_BISON_CHECK_WARNINGS_($@)])])]) m4_define([AT_BISON_CHECK_WARNINGS_], - [[# Defining POSIXLY_CORRECT causes bison to complain if options - # are added after the grammar file name, so skip these checks - # in that case. - if test -z "${POSIXLY_CORRECT+set}"; then + [[# Defining POSIXLY_CORRECT causes bison to complain if options are + # added after the grammar file name, so skip these checks in that + # case. + # + # 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 + # the environment variable. + if env | grep '^POSIXLY_CORRECT=' >/dev/null; then :; else - ]AT_SAVE_SPECIAL_FILES[ + ]AT_SAVE_SPECIAL_FILES[ - # To avoid expanding it repeatedly, store specified stdout. - ]AT_DATA([expout], [$3])[ + # To avoid expanding it repeatedly, store specified stdout. + ]AT_DATA([expout], [$3])[ - # Run with -Werror. + # Run with -Werror. ]AT_BISON_CHECK_([$1[ -Werror]], [[1]], [expout], [stderr])[ - # Build expected stderr up to and including the "warnings being - # treated as errors" message. - ]AT_DATA([[at-bison-check-warnings]], [$4])[ - at_bison_check_first=`sed -n \ - '/: warning: /{=;q;}' at-bison-check-warnings` - : ${at_bison_check_first:=1} - at_bison_check_first_tmp=`sed -n \ - '/conflicts: [0-9].*reduce$/{=;q;}' at-bison-check-warnings` - : ${at_bison_check_first_tmp:=1} - if test $at_bison_check_first_tmp -lt $at_bison_check_first; then - at_bison_check_first=$at_bison_check_first_tmp - fi - if test $at_bison_check_first -gt 1; then - sed -n "1,`expr $at_bison_check_first - 1`"p \ - at-bison-check-warnings > experr - fi - echo ']AT_BISON_WERROR_MSG[' >> experr - - # Finish building expected stderr and check. Unlike warnings, - # complaints cause bison to exit early. Thus, with -Werror, bison - # does not necessarily report all warnings that it does without - # -Werror, but it at least reports one. - at_bison_check_last=`sed -n '$=' stderr` - : ${at_bison_check_last:=1} - at_bison_check_last=`expr $at_bison_check_last - 1` - sed -n "$at_bison_check_first,$at_bison_check_last"p \ - at-bison-check-warnings >> experr - ]AT_CHECK([[sed 's,.*/\(]AT_BISON_WERROR_MSG[\)$,\1,' \ - stderr 1>&2]], [[0]], [[]], [experr])[ - - # Now check --warnings=error. - cp stderr experr + # Build expected stderr up to and including the "warnings being + # treated as errors" message. + ]AT_DATA([[at-bison-check-warnings]], [$4])[ + at_bison_check_first=`sed -n \ + '/: warning: /{=;q;}' at-bison-check-warnings` + : ${at_bison_check_first:=1} + at_bison_check_first_tmp=`sed -n \ + '/conflicts: [0-9].*reduce$/{=;q;}' at-bison-check-warnings` + : ${at_bison_check_first_tmp:=1} + if test $at_bison_check_first_tmp -lt $at_bison_check_first; then + at_bison_check_first=$at_bison_check_first_tmp + fi + if test $at_bison_check_first -gt 1; then + sed -n "1,`expr $at_bison_check_first - 1`"p \ + at-bison-check-warnings > experr + fi + echo ']AT_BISON_WERROR_MSG[' >> experr + + # Finish building expected stderr and check. Unlike warnings, + # complaints cause bison to exit early. Thus, with -Werror, bison + # does not necessarily report all warnings that it does without + # -Werror, but it at least reports one. + at_bison_check_last=`sed -n '$=' stderr` + : ${at_bison_check_last:=1} + at_bison_check_last=`expr $at_bison_check_last - 1` + sed -n "$at_bison_check_first,$at_bison_check_last"p \ + at-bison-check-warnings >> experr + ]AT_CHECK([[sed 's,.*/\(]AT_BISON_WERROR_MSG[\)$,\1,' \ + stderr 1>&2]], [[0]], [[]], [experr])[ + + # Now check --warnings=error. + cp stderr experr ]AT_BISON_CHECK_([$1[ --warnings=error]], [[1]], [expout], [experr])[ - # Now check -Wnone and --warnings=none by making sure that - # -Werror doesn't change the exit status when -Wnone or - # --warnings=none is specified. + # Now check -Wnone and --warnings=none by making sure that + # -Werror doesn't change the exit status when -Wnone or + # --warnings=none is specified. ]AT_BISON_CHECK_([$1[ -Wnone -Werror]], [[0]], [expout])[ ]AT_BISON_CHECK_([$1[ --warnings=none -Werror]], [[0]], [expout])[