Commit Graph

13 Commits

Author SHA1 Message Date
Akim Demaille
8f462efe92 named references: fix double free.
In `rhs[name]: "a" | "b"', do not free "name" twice.
Reported by Tys Lefering.
<http://lists.gnu.org/archive/html/bug-bison/2010-06/msg00002.html>

	* src/named-ref.h, src/named-ref.c (named_ref_copy): New.
	* src/parse-gram.y (current_lhs): Rename as...
	(current_lhs_symbol): this.
	(current_lhs): New function.  Use it to free the current lhs
	named reference.
	* src/reader.c: Bind lhs to a copy of the current named reference.
	* src/symlist.c: Rely on free (0) being valid.
	* tests/named-refs.at: Test this.
2011-03-09 21:04:17 +01:00
Akim Demaille
686e83e396 tests: style changes.
* tests/named-refs.at (Redundant words in LHS brackets)
	(Unresolved references): here.
2011-03-09 21:03:36 +01:00
Joel E. Denny
eb8c66bbda Do not allow identifiers that start with a dash.
This cleans up our previous fixes for a bug whereby Bison
discarded `.field' in `$-1.field'.  The previous fixes were less
restrictive about where a dash could appear in an identifier, but
the restrictions were hard to explain.  That bug was reported and
this final fix was originally suggested by Paul Hilfinger.  This
also fixes a remaining bug reported by Paul Eggert whereby Bison
parses `%token ID -123' as `%token ID - 123' and handles `-' as an
identifier.  Now, `-' cannot be an identifier.  Discussed in
threads beginning at
<http://lists.gnu.org/archive/html/bug-bison/2011-01/msg00000.html>,
<http://lists.gnu.org/archive/html/bug-bison/2011-01/msg00004.html>.
* NEWS (2.5): Update entry describing the dash extension to
grammar symbol names.  Also, move that entry before the named
references entry because the latter mentions the former.
* doc/bison.texinfo (Symbol): Update documentation for symbol
names.  As suggested by Paul Eggert, mention the effect of periods
and dashes on named references.
(Decl Summary): Update documentation for unquoted %define values,
which, as a side effect, can no longer start with dashes either.
* src/scan-code.l (id): Implement.
* src/scan-gram.l (id): Implement.
* tests/actions.at (Exotic Dollars): Extend test group to exercise
bug reported by Paul Hilfinger.
* tests/input.at (Symbols): Update test group, and extend to
exercise bug reported by Paul Eggert.
* tests/named-refs.at (Stray symbols in brackets): Update test
group.
($ or @ followed by . or -): Likewise.
* tests/regression.at (Invalid inputs): Likewise.
(cherry picked from commit 82f3355eaf)
2011-02-05 19:15:51 -05:00
Joel E. Denny
8cbbf1786f Improve error messages for $' or @' followed by .' or -'.
Previously, for this special case of an invalid reference, the
usual "symbol not found in production:" was printed.  However,
because the symbol name was parsed as the empty string, that
message was followed immediately by a newline instead of a symbol
name.  In reality, this is a syntax error, so the reference is
invalid regardless of the symbols actually appearing in the
production.  Discussed at
<http://lists.gnu.org/archive/html/bison-patches/2011-01/msg00012.html>.
* src/scan-code.l (parse_ref): Report the above case as a syntax
error.  Other than that, continue to handle this case like any
other invalid reference that Bison manages to parse because
"possibly meant" messages can still be helpful to the user.
* tests/named-refs.at ($ or @ followed by . or -): New test group.
(cherry picked from commit 5c9efc755e)
2011-01-09 18:14:45 -05:00
Joel E. Denny
ea0a767697 maint: run "make update-copyright". 2011-01-02 09:56:16 -05:00
Paul Eggert
6e30ede87a Do not use date ranges in copyright notices.
See http://www.gnu.org/prep/maintain/maintain.html#Copyright-Notices

* HACKING, Makefile.am, NEWS, PACKAGING, README, README-alpha:
* TODO, bootstrap, bootstrap.conf:
* build-aux/update-b4-copyright, cfg.mk, configure.ac:
* data/README, data/bison.m4, data/c++-skel.m4, data/c++.m4:
* data/c-skel.m4, data/c.m4, data/glr.c, data/glr.cc:
* data/java-skel.m4, data/java.m4, data/lalr1.cc:
* data/lalr1.java, data/location.cc:
* data/xslt/bison.xsl:
* data/xslt/xml2dot.xsl, data/xslt/xml2text.xsl:
* data/xslt/xml2xhtml.xsl, data/yacc.c, djgpp/Makefile.maint:
* djgpp/README.in, djgpp/config.bat, djgpp/config.sed:
* djgpp/config.site, djgpp/config_h.sed, djgpp/djunpack.bat:
* djgpp/subpipe.c, djgpp/subpipe.h:
* djgpp/testsuite.sed, doc/bison.texinfo:
* doc/refcard.tex, etc/README, etc/bench.pl.in:
* examples/calc++/Makefile.am, examples/extexi:
* lib/abitset.c, lib/abitset.h:
* lib/bbitset.h, lib/bitset.c, lib/bitset.h:
* lib/bitset_stats.c, lib/bitset_stats.h, lib/bitsetv-print.c:
* lib/bitsetv-print.h, lib/bitsetv.c, lib/bitsetv.h:
* lib/ebitset.c, lib/ebitset.h, lib/get-errno.c:
* lib/get-errno.h, lib/lbitset.c, lib/lbitset.h:
* lib/libiberty.h, lib/main.c, lib/timevar.c:
* lib/timevar.def, lib/timevar.h, lib/vbitset.c:
* lib/vbitset.h, lib/yyerror.c, m4/bison-i18n.m4:
* m4/c-working.m4, m4/cxx.m4, m4/subpipe.m4, m4/timevar.m4:
* src/AnnotationList.c, src/AnnotationList.h:
* src/InadequacyList.c, src/InadequacyList.h, src/LR0.c:
* src/LR0.h, src/Sbitset.c, src/Sbitset.h, src/assoc.c:
* src/assoc.h, src/closure.c, src/closure.h, src/complain.c:
* src/complain.h, src/conflicts.c, src/conflicts.h:
* src/derives.c, src/derives.h, src/files.c, src/files.h:
* src/flex-scanner.h, src/getargs.c, src/getargs.h:
* src/gram.c, src/gram.h, src/graphviz.c, src/ielr.c:
* src/ielr.h, src/lalr.c, src/lalr.h:
* src/location.c, src/location.h, src/main.c:
* src/muscle-tab.c, src/muscle-tab.h, src/named-ref.c:
* src/named-ref.h, src/nullable.c, src/nullable.h:
* src/output.c, src/output.h, src/parse-gram.y:
* src/print-xml.c, src/print-xml.h, src/print.c, src/print.h:
* src/print_graph.c, src/print_graph.h, src/reader.c:
* src/reader.h, src/reduce.c, src/reduce.h, src/relation.c:
* src/relation.h, src/scan-code.h, src/scan-code.l:
* src/scan-gram.h, src/scan-gram.l, src/scan-skel.h:
* src/scan-skel.l, src/state.c, src/state.h, src/symlist.c:
* src/symlist.h, src/symtab.c, src/symtab.h, src/system.h:
* src/tables.c, src/tables.h, src/uniqstr.c, src/uniqstr.h:
* tests/actions.at, tests/atlocal.in, tests/c++.at:
* tests/calc.at, tests/conflicts.at, tests/cxx-type.at:
* tests/existing.at, tests/glr-regression.at:
* tests/headers.at, tests/input.at, tests/java.at:
* tests/local.at, tests/named-refs.at:
* tests/output.at, tests/push.at, tests/reduce.at:
* tests/regression.at, tests/sets.at, tests/skeletons.at:
* tests/synclines.at, tests/testsuite.at, tests/torture.at:
* data/Makefile.am, data/location.cc, doc/Makefile.am, src/Makefile.am:
* tests/Makefile.am, lib/Makefile.am, examples/Makefile.am:
* etc/Makefile.am:
Don't use date ranges in copyright notices.

Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996,
1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
2008, 2009, 2010 Free Software Foundation, Inc.
2010-06-23 13:07:29 -07:00
Joel E. Denny
1462fcee1e maint: run "make update-copyright" 2010-01-04 13:46:45 -05:00
Alex Rozenman
348f560883 Keep sub-messages aligned. Fix strings for translation.
* src/location.h: (location_print): Add return value.
	* src/location.c: (location_print): Return number of printed
	characters.
	* src/complain.h: Two new functions (complain_at_indent,
	warn_at_indent).
	* src/complain.cpp: Implement the alignment mechanism. Add new
	static variable (indent_ptr). Use and update it (error_message,
	complain_at_indent, warn_at_indent).
	* src/scan-code.l: Fix strings for translations. Use new *_indent
	functions (parse_ref, show_sub_messages).
	* tests/named-ref.at: Adjust testcases.
	* NEWS (2.5): Add an announcement about named references.
2009-09-19 13:15:53 +03:00
Alex Rozenman
4c56b1319d Provide an additional sub-message for clarity.
Add "symbol not found in production" error message when
an "invalid reference" is detected in named references
resolution.

	* src/scan-code.l: Update "invalid reference" case.
	* tests/named-ref.at: Adjust test-cases.
2009-09-12 11:54:34 +03:00
Alex Rozenman
14e568d744 Use "Unresolved reference" error message when no symbols were found
in a symbolic reference resolution. Remove .expr and -expr from
	the shown reference when the reference is unresolved.

	* src/scan-code.l: Change the error message, adjust location columns,
	rename variable "exact_mode" to "explicit_bracketing".
	* tests/named-ref.at: Adjust existing tests and add a new one.
2009-09-05 13:22:19 +03:00
Alex Rozenman
1a323c2f71 Convert "misleading reference" messages to warnings.
* src/scan-code.l: New function 'show_sub_messages', more
	factoring.
	* tests/named-ref.at: Adjust tests.
2009-08-08 18:18:31 +03:00
Alex Rozenman
d5e8574bf6 Style changes and factoring.
* src/named-ref.h: Add comments.
	* src/parse-gram.y: Readability and style changes.
	* src/reader.c: Factoring: assign_named_ref function.
	* src/scan-code.l: Factoring and style changes. Rename
	parse_named_ref to parse_ref. Use "c-ctype.h" from gnulib.
	Use "unsigned" type for variant index. Improve readablity.
	* src/scan-gram.l: Change error messages and add comments.
	* src/symlist.h: symbol_list_null: New function decl.
	* src/symlist.c: symbol_list_null: Implement here.
	* tests/named-refs.at: Adjust for new error messages.
2009-07-04 22:16:17 +03:00
Alex Rozenman
7685e2f7ba Named symbol references.
Discussed in:
http://lists.gnu.org/archive/html/bison-patches/2009-01/msg00000.html
http://lists.gnu.org/archive/html/bison-patches/2009-02/msg00002.html
http://lists.gnu.org/archive/html/bison-patches/2009-03/msg00009.html

	* src/parse-gram.y: Add new syntax (named_ref.opt).
	* src/reader.c: Store named refs in symbol lists.
	* src/reader.h: New argument for symbol_append and
	action_append functions.
	* src/scan-code.h: Add new field (named_ref) into
	code_props data structure. Keeps named ref of midrule
	actions.
	* src/scan-code.l: Support for named refs in semantic
	action code. New function 'parse_named_ref'.
	* src/scan-gram.l: Support bracketed id.
	* src/symlist.c: Store named refs in symbol lists.
	* src/symlist.h: New field in symbol list: named_ref.
	* src/named-ref.h: New file, a struct for named_ref.
	* src/named-ref.c: New file, named_ref_new function.
	* src/Makefile.am: Add two new files.
	* tests/testsuite.at: Include new test group:
	* tests/named-refs.at: this new file.
2009-06-27 23:35:16 +03:00