Commit Graph

3436 Commits

Author SHA1 Message Date
Eric Blake
4bb975e1ad scan-gram: avoid portability trap with ctype usage.
* src/scan-gram.l (<SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER>):
Avoid compiler warning.

Signed-off-by: Eric Blake <ebb9@byu.net>
(cherry picked from commit bbbbe221d7)
2009-08-27 20:17:23 -06:00
Joel E. Denny
74baf5c966 tests: use perl for printing special sequences to files.
And skip tests if perl is not available.  This is better than
playing tricks with shell portability.  Suggested by Akim
Demaille.
* tests/input.at (Bad character literals): Use it here for
omitting final newlines.
(Bad escapes in literals): Use it here for special characters.
(cherry picked from commit b70c7fb4e1)
2009-08-27 03:55:24 -04:00
Joel E. Denny
d63e12792a tests: show a use of %define lr.default-reductions "consistent"
* tests/conflicts.at (%nonassoc and eof): Extend to test that it
prevents the omission of expected tokens for %error-verbose.
(cherry picked from commit d1cc31c5f0)
2009-08-26 16:36:13 -04:00
Akim Demaille
833d1720f8 tests: portability fix.
* tests/input.at (Bad escapes in literals): Don't expect "echo
	'\0'" to output \ then 0.
(cherry picked from commit 3bed3a757f)
2009-08-26 13:22:29 +02:00
Joel E. Denny
e4bcae3c5a Actually handle the yytable zero value correctly this time.
* data/glr.c, data/lalr1.cc, data/lalr1.java, data/yacc.c: Don't
mention zero values in the YYTABLE comments.
* data/glr.c (yytable_value_is_error): Don't check for zero
value.
* data/lalr1.cc (yy_table_value_is_error_): Likewise.
* data/yacc.c (yytable_value_is_error): Likewise.
* data/lalr1.java (yy_table_value_is_error_): Likewise.
(yysyntax_error): Fix typo in code: use yytable_ not yycheck_.
* src/tables.h: In header comments, explain why it's useless to
check for a zero value in yytable.
(cherry picked from commit aa0cb40d61)

Conflicts:

	data/bison.m4
	data/lalr1.java
2009-08-26 03:14:58 -04:00
Joel E. Denny
d5eb0826af More fixes related to last two patches.
* data/c.m4 (b4_table_value_equals): Comment that YYID must be
defined.
* data/glr.c, data/lalr1.cc, data/lalr1.java, data/yacc.c: Fix
yytable comments: zero indicates syntax error not default
action.
* data/glr.c (yyis_pact_ninf): Rename to...
(yypact_value_is_default): ... this.
(yyisDefaultedState): Update for rename.
(yyis_table_ninf): Rename to...
(yytable_value_is_error): ... this, and check for value zero
besides just YYTABLE_NINF.
(yygetLRActions): Check for default value from yypact.  It
appears that this check is always performed before this function
is invoked, and so adding the check here is probably redundant.
However, the code may evolve after this subtlety is forgotten.
Also, update for rename to yytable_value_is_error.  Because that
macro now checks for zero, a different but equivalent branch of
the if-then-else here is evaluated.
(yyreportSyntaxError): Update for rename to
yytable_value_is_error.  The zero condition was mishandled
before.
(yyrecoverSyntaxError): Update for renames.  No behavioral
changes.
* data/lalr1.cc, data/lalr1.java (yy_pact_value_is_default_):
New function.
(yy_table_value_is_error_): New function.
(parse): Use new functions where possible.  No behavioral
changes.
(yysyntax_error_, yysyntax_error): Use yy_table_value_is_error_.
The zero condition was mishandled before.
* data/yacc.c (yyis_pact_ninf): Rename to...
(yypact_value_is_default): ... this.
(yyis_table_ninf): Rename to...
(yytable_value_is_error): ... this, and check for value zero
besides just YYTABLE_NINF.
(yysyntax_error): Update for rename to yytable_value_is_error.
The zero condition was mishandled before.
(yyparse): Update for renames.  No behavioral changes.
* src/tables.h: Improve comments about yypact, yytable, etc.
more.  Most importantly, say yytable value of zero means syntax
error not default action.
(cherry picked from commit f2b30bdf37)

Conflicts:

	data/bison.m4
	data/lalr1.cc
	data/lalr1.java
	data/yacc.c
	src/parse-gram.c
	src/parse-gram.h
2009-08-25 20:34:28 -04:00
Joel E. Denny
1fa303077d Fix %error-verbose for conflicts resolved by %nonassoc.
* NEWS (2.5): Document.
* data/glr.c (yyreportSyntaxError): Fix this by checking
yyis_table_ninf.
* data/yacc.c (yysyntax_error): Likewise.
* data/lalr1.cc (yysyntax_error_): Fix this by checking
yytable_ninf_.
* data/lalr1.java (yysyntax_error): Likewise.
* tests/conflicts.at (%nonassoc and eof): Update expected output
and remove FIXME.
(cherry picked from commit 53f036ce02)

Conflicts:

	data/lalr1.cc
	data/lalr1.java
	src/parse-gram.c
	src/parse-gram.h
2009-08-25 02:58:16 -04:00
Joel E. Denny
77373efad2 Some code and documentation improvements.
* data/c.m4 (b4_table_value_equals): New macro to capture
some repeated code.
* data/glr.c (yyis_pact_ninf): Use it here.
(yyis_table_ninf): Likewise.
(yyreportSyntaxError): Improve internal comments.
* data/yacc.c (yyis_pact_ninf): New macro copied from glr.c.
Use it everywhere possible.
(yyis_table_ninf): Likewise.
(yysyntax_error): Improve internal comments.
* data/lalr1.cc (yysyntax_error_): Likewise.
* data/lalr1.java (yysyntax_error): Likewise.
* src/tables.h: Improve comments about yypact, yytable, etc.
(cherry picked from commit 8741288212)

Conflicts:

	data/lalr1.java
	data/yacc.c
2009-08-25 02:57:57 -04:00
Joel E. Denny
890ab17c84 Use locale when quoting.
* src/scan-gram.l (SC_ESCAPED_STRING, SC_ESCAPED_CHARACTER): Use
quote rather than implementing quoting here.
(cherry picked from commit e6c849d82a)
2009-08-21 20:32:11 -04:00
Eric Blake
aa50ba7bff Make previous patch more robust.
* src/output.c (ARRAY_CARDINALITY): New macro, copied from
argmatch.h.
(output_skeleton): Use it.
Suggested by Akim Demaille.

Signed-off-by: Eric Blake <ebb9@byu.net>
(cherry picked from commit 1266b63674)
2009-08-20 16:52:19 -06:00
Eric Blake
c519609864 Import latest m4/m4.m4.
* submodules/autoconf: Update to autoconf 2.64.
* configure.ac (M4_GNU_OPTION): New define.
* src/output.c (output_skeleton): Use it to resolve FIXME.
* NEWS: Mention this.

Signed-off-by: Eric Blake <ebb9@byu.net>
(cherry picked from commit b9ad39c1fb)
2009-08-20 09:48:49 -06:00
Joel E. Denny
39fb7e6239 Fix complaints about escape sequences.
Discussed starting at
<http://lists.gnu.org/archive/html/bison-patches/2009-08/msg00036.html>.
* src/scan-gram.l (SC_ESCAPED_STRING, SC_ESCAPED_CHARACTER):
For a \0 and similar escape sequences meaning the null
character, report an invalid escape sequence instead of an
invalid null character because the latter does not actually
appear in the user's input.
In all escape sequence complaints, don't escape the initial
backslash, and don't quote when the sequence appears at the end
of the complaint line unless there's whitespace that quotearg
won't escape.
Consistently say "invalid" not "unrecognized".
Consistently prefer "empty character literal" over "extra
characters in character literal" warning for invalid escape
sequences; that is, consistently discard those sequences.
* tests/input.at (Bad escapes in literals): New.
(cherry picked from commit c2724603c9)
2009-08-19 21:05:07 -04:00
Akim Demaille
c33bc80009 doc: fixes.
* doc/bison.texinfo: Fix minor Texinfo errors.
(cherry picked from commit 17aed602c6)
2009-08-19 14:52:49 +02:00
Akim Demaille
8fbbeba2a4 doc: %initial-action to initialize yylloc.
Reported by Bill Allombert.
	* doc/bison.texinfo: Set fill-column to 76.
	(Location Type): Document the use of %initial-action to initialize
	yylloc.

(cherry picked from commit d59e456dbf)
2009-08-19 13:36:22 +02:00
Joel E. Denny
1874a474b9 maint: update for gnulib's recent update-copyright changes
* gnulib: Update.
* .x-update-copyright (COPYING): Add as it's no longer implied
when .x-update-copyright is present.
* cfg.mk (update-copyright-local): Remove, now ignored.
(update-copyright): Declare update-b4-copyright as a dependency.
(cherry picked from commit c67e466f9d)
2009-08-18 18:43:36 -04:00
Akim Demaille
f4bfd5a96f build: require gettext 0.17.
Suggested by Bruno Haible.
http://lists.gnu.org/archive/html/bug-bison/2009-08/msg00009.html

	* configure.ac: require gettext 0.17 to ensure compatibility with
	gnulib.
(cherry picked from commit af6d235843)
2009-08-18 13:51:16 +02:00
Akim Demaille
2509eba631 build: lower gettext requirements.
Bison was uselessly requiring the formatstring macros from
gettext, which resulted in mo files not being installed on systems
that perfectly supported Bison mo files.  Lower the requirement.
http://lists.gnu.org/archive/html/bug-bison/2009-08/msg00006.html

	* configure.ac: Require need-ngettext instead of
	need-formatstring-macros.
	Reported by Martin Jabocs.
	Suggested by Bruno Haible.
	* INSTALL: Restructure.
	(Internationalization): New.
(cherry picked from commit b9e42bb439)
2009-08-17 10:26:50 +02:00
Joel E. Denny
314542f905 maint: fix use of copyright year intervals.
* gnulib: Update.
* bootstrap.conf (gnulib_modules): Update getopt to getopt-gnu
as now recommended in gnulib/NEWS.
* build-aux/update-b4-copyright: Fix.
* cfg.mk (update-copyright-env): Configure update-copyright.
(cherry picked from commit 75ac158b82)
2009-08-14 18:48:36 -04:00
Joel E. Denny
2498596474 Make it easier to write deterministic tests.
Continues Akim's work from his 2009-06-10 commits.
* src/reader.c (check_and_convert_grammar): Don't add any
symbols after the first symbols_do invocation.
* src/symtab.c (symbols_sorted): New static global.
(user_token_number_redeclaration): Update comments.
(symbol_from_uniqstr): If a new symbol is being created, assert
that symbols_sorted hasn't been allocated yet.
(symbols_free): Free symbols_sorted.
(symbols_cmp, symbols_cmp_qsort): New functions.
(symbols_do): Sort symbol_table into symbols_sorted on first
invocation.
* tests/input.at (Numbered tokens): Recombine tests now that the
output should be deterministic across multiple numbers.
(cherry picked from commit 83b60c97ee)
2009-08-13 01:24:58 -04:00
Akim Demaille
47076da5b6 distcheck: fix.
* examples/calc++/Makefile.am: (EXTRA_DIST): Ship calc.stamp.
(cherry picked from commit 67af719840)
2009-08-12 14:05:59 +02:00
Joel E. Denny
36dfe4662e * tests/Makefile.am (TESTSUITE_AT): Add named-refs.at. 2009-08-10 23:39:43 -04:00
Joel E. Denny
07c0db18b4 Miscellaneous code readability improvements.
* src/reader.c (reader): Move %define front-end variable
defaults and checking into...
(prepare_percent_define_front_end_variables): ... this new
function.

* src/scan-gram.l (INITIAL): For consistency with string
literals, don't store open quote on character literal.  It's
discarded before returning anyway.
(SC_ESCAPED_CHARACTER): Similarly, don't store close quote.
Make length test more readable, and make the character stored
for an empty literal more obvious while consistent with the
previous behavior.

* src/symtab.c, src/symtab.h: Rename USER_NUMBER_ALIAS to
USER_NUMBER_HAS_STRING_ALIAS throughout.
* src/symtab.c (symbol_make_alias): Remove comment from symtab.c
that is repeated in symtab.h.  Improve argument names to make it
clear which side of the symbol-string alias pair is which.
(symbol_check_alias_consistency): Improve local variable names
for the same purpose.
* src/symtab.h (struct symbol): Make comments about aliases
clearer.
(symbol_make_alias): Improve comments and argument name.
* src/output.c (token_definitions_output): Update for rename to
USER_NUMBER_HAS_STRING_ALIAS and improve comments about aliases.
(cherry picked from commit dfaa48602d)

Conflicts:

	src/symtab.c
	src/symtab.h
2009-08-10 23:25:21 -04: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
Joel E. Denny
38609c3455 maint: run "make update-copyright" 2009-08-06 19:16:29 -04:00
Joel E. Denny
642f240e22 maint: make update-b4-copyright easier to use
* build-aux/update-b4-copyright: In warnings, report line
numbers rather than character positions.
* cfg.mk (update-copyright-local): Set to update-b4-copyright so
that update-copyright runs it.
* gnulib: Update.
(cherry picked from commit a1a9422d4a)
2009-08-06 18:59:48 -04:00
Joel E. Denny
d0caad01ab maint: clean up update-b4-copyright code
* build-aux/update-b4-copyright: Do not accept 2-digit
UPDATE_COPYRIGHT_YEAR, which was not handled correctly.
Don't accept a `[' in a b4_copyright argument.
Format code more consistently.
Don't assume b4*copyright never occurs.
(cherry picked from commit 0b61a8ec18)
2009-08-05 19:55:48 -04:00
Joel E. Denny
ac2def5602 maint: automate b4_copyright updates.
* Makefile.am (update-b4-copyright): New target rule.
* build-aux/Makefile.am (EXTRA_DIST): Add update-b4-copyright.
* build-aux/update-b4-copyright: New.
* data/yacc.c: Remove stray characters around b4_copyright
invocations.
(cherry picked from commit 269e222e24)

Conflicts:

	build-aux/local.mk
	data/yacc.c
2009-08-04 21:32:58 -04:00
Joel E. Denny
dbbb64f091 maint: automate annual package-wide copyright-year update.
* .x-update-copyright: New.
* Makefile.am (EXTRA_DIST): Remove maint.mk.
* bootstrap.conf (gnulib_modules): Add maintainer-makefile and
update-copyright.  Remove gnumakefile, which is implied by
maintainer-makefile.
* cfg.mk (bootstrap-tools): Copy from old maint.mk.
* gnulib: Update.
* maint.mk: Remove, now copied from gnulib.
* examples/extexi: Add missing "(C)" in copyright statement so
update-copyright can recognize it.
* src/LR0.h: Likewise.
* src/print.h: Likewise.
* src/print_graph.h: Likewise.
* src/named-ref.c: Likewise.
* src/named-ref.h: Likewise.
* src/gram.c: Add missing comma in copyright statement.
* src/gram.h: Likewise.
(cherry picked from commit 50bcb22c4c)

Conflicts:

	gnulib
	src/gram.c
2009-08-04 20:03:51 -04:00
Joel E. Denny
bfa018d447 Fix "make distcheck".
* examples/calc++/Makefile.am: Say $(srcdir)/calc.stamp instead
of just calc.stamp.
(cherry picked from commit cfc9e431c3)
2009-08-04 15:43:38 -04:00
Joel E. Denny
4521fcdf02 Pacify "gcc -Wunused" for the input function from Flex.
Reported by Alex Rozenman.  This warning shows up with gcc-4.3.0
and later.
* src/scan-code.l: Add "%option noinput", which I cannot find in
the Flex manual, but which Flex has supported since at least as
far back as 2.5.4.  However, if any of our developers still use
Flex 2.5.4, they'll need to stop configuring with
--enable-gcc-warnings because "%option noinput" didn't work
correctly until Flex 2.5.6.
* src/scan-gram.l: Likewise.
* src/scan-skel.l: Likewise.
(cherry picked from commit 42f8609bbd)
2009-08-01 18:26:41 -04:00
Alex Rozenman
cbc6a70e9d Fix mail address in ChangeLog. 2009-07-31 22:36:18 +03:00
Alex Rozenman
992e874a7c Fix --enable-gcc-warnings problems.
* src/reader.c: Adjust variable names.
	* src/scan-code.l: Fix prototypes and adjust names.
	* src/named-ref.c: Remove redundant "if".
2009-07-31 22:26:20 +03:00
Joel E. Denny
a1ed2b71fa Fix a --enable-gcc-warnings problem.
* src/scan-gram.l (SC_ESCAPED_CHARACTER): Actually use length
variable.
2009-07-29 13:47:02 -04:00
Alex Rozenman
1e20ad112f Fix some memory leaks.
* src/named-ref.c: Add a pointer check (named_ref_free).
	* src/scan-code.l: New function (variant_table_free). Called in
	code_scanner_free.
	* src/symlist.c: Call to named_ref_free (symbol_list_free).
2009-07-24 21:08:46 +03:00
Joel E. Denny
ac9b0e954b Warn about character literals not of length one.
* NEWS (2.5): Document.
* src/scan-gram.l (INITIAL): Remove comment that we don't check
the length.
(SC_ESCAPED_CHARACTER): Warn if length is wrong.
* tests/input.at (Bad character literals): New test group.
2009-07-24 10:31:16 -04:00
Joel E. Denny
2de160e12e * src/lalr.c (state_lookahead_tokens_count): Correct comment. 2009-07-24 10:05:21 -04:00
Joel E. Denny
cba975069a Some M4 cleanup in the testsuite.
Suggested by Eric Blake at
<http://lists.gnu.org/archive/html/bison-patches/2009-04/msg00083.html>.
* tests/existing.at (_AT_TEST_EXISTING_GRAMMAR): Do not
complicate the code by distinguishing between a missing value
and an empty string value for an optional argument.  This fix is
allowed by the similar fix in AT_TEST_TABLES_AND_PARSE below.
* tests/local.at (_AT_TEST_TABLES_AND_PARSE): Merge into...
(AT_TEST_TABLES_AND_PARSE): ... this now that the special
arguments are not needed because of the following changes.
Fix stale comments.
Bison developers should use GNU M4 and should not use
POSIXLY_CORRECT when building the test suite, so do not
complicate the code by avoiding $10 and above.
Do not quote an empty string value for an optional argument, and
do not distinguish between a missing value and an empty string
value.
2009-07-22 15:12:20 -04:00
Joel E. Denny
62eb2d1bd9 * m4/m4.m4: Make it a sym link to submodules/autoconf/m4/m4.m4. 2009-07-21 14:10:54 -04:00
Joel E. Denny
620b2e3691 Revert unnecessary column realignment in --help output.
Reported by Akim Demaille at
<http://lists.gnu.org/archive/html/bison-patches/2009-06/msg00010.html>.
* src/getargs.c (usage): Here.
2009-07-15 04:30:56 -04:00
Alex Rozenman
dad6544d4a Alphabetical order in src/Makefile.am.
* src/Makefile.am: Adjust.
2009-07-04 22:59:29 +03:00
Alex Rozenman
8bea3dbd84 Regen. 2009-07-04 22:17:09 +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
Eric Blake
ae09ec8577 scan-code: avoid compiler warnings
* src/scan-code.l (parse_named_ref): Use correct specifiers.

Signed-off-by: Eric Blake <ebb9@byu.net>
2009-06-29 21:46:38 -06:00
Akim Demaille
80d653fd30 build: avoid concurrent extraction of calc++.
* examples/calc++/Makefile.am (calc.stamp): New.
	Depend on it to create the sources of calc++ so that concurrent
	builds don't launch several "extexi" in parallel.
	Not only this is inefficient, this also builds incorrect sources
	with several extractions mixed together.

Cherry-picked from 5ece73eaa1.
2009-06-29 20:40:02 +02:00
Alex Rozenman
0210a4bf5e Regen. 2009-06-27 23:45:54 +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
Akim Demaille
67f8cf51c3 hash: check insertion for memory exhaustion.
* src/uniqstr.c (uniqstr_new): New.
2009-06-25 06:08:56 +02:00
Akim Demaille
83b66dddb6 style changes.
* data/xslt/xml2dot.xsl, data/xslt/xml2xhtml.xsl: Space changes.
	* src/print-xml.c: Style changes.
	* tests/conflicts.at: Comment changes.
2009-06-11 15:27:45 +02:00
Akim Demaille
517cb0ad9c xml: beware of user strings used to give a %prec to rules.
* tests/conflicts.at (%prec with user strings): New.
	* src/gram.c (grammar_rules_print_xml): Escape the precedence for
	XML output.
2009-06-11 15:27:30 +02:00
Akim Demaille
75c7a52a31 hash: check insertion for memory exhaustion.
* src/muscle-tab.c (muscle_insert, muscle_grow)
	* src/state.c (state_hash_insert): Check the return value of
	hash_insert.
2009-06-11 15:26:33 +02:00