Joel E. Denny [Thu, 30 Apr 2009 05:04:33 +0000 (01:04 -0400)]
Convert underscores to dashes in some %define variable names.
For now, just api.push-pull and lr.keep-unreachable-states.
Maintain old names for backward compatibility.
* NEWS (2.5): Document.
* data/c.m4 (b4_identification): Update comment.
* data/yacc.c: Update access.
* doc/bison.texinfo: Update.
* etc/bench.pl.in (bench_push_parser): Update use.
* src/files.c (tr): Move to...
* src/getargs.c, src/getargs.h (tr): ... here because I can't
think of a better place to expose it. My logic is that, for all
uses of tr so far, command-line arguments can be involved, and
getargs.h is already included.
* src/main.c (main): Update access.
* src/muscle_tab.c (muscle_percent_define_insert): Convert old
variable names to new variable names before assigning value.
* src/reader.c (reader): Update setting default.
* tests/calc.at: Update uses.
* tests/conflicts.at (Unreachable States After Conflict
Resolution): Update use.
* tests/input.at (%define enum variables): Update use.
(%define backward compatibility): New test group.
* tests/push.at: Update uses.
* tests/reduce.at: Update uses.
* tests/torture.at: Update uses.
(cherry picked from commit 812775a0391e122eff1983afea2da96c600c7307)
Joel E. Denny [Tue, 21 Apr 2009 09:12:01 +0000 (05:12 -0400)]
Document %define lr.type and lr.default_rules.
* NEWS (2.5): Add an entry.
* src/getargs.c (usage): Mention IELR(1) and canonical LR(1)
besides just LALR(1) and GLR(1).
* doc/bison.texinfo (Introduction): Likewise.
(Language and Grammar): Bison is no longer limited to LALR(1)
restrictions.
(GLR parsing): Say deterministic or LR(1) rather than LALR(1)
when trying to distinguish from GLR. Talk about LR(1) grammars
rather than LALR(1) grammars.
(Decl Summary): In %define api.push_pull entry, say it applies
to deterministic parsers in C rather than LALR(1) parsers in C.
Add lr.default_rules entry.
Add lr.type entry.
(Mystery Conflicts): Bison is no longer limited to LALR(1)
restrictions.
(Generalized LR Parsing): Same changes as for the previous GLR
section.
(Memory Management): Say deterministic rather than LALR(1).
(Understanding): Correct some bison output.
Index discussion of "accepting state".
Say deterministic rather than LALR(1).
(Bison Options): In --yacc entry, say deterministic rather than
LALR(1).
In --report, --graph, and --xml entries, just don't mention
LALR(1).
(C++ Parsers): Say deterministic rather than LALR(1).
(Table of Symbols): Likewise in YYSTACK_USE_ALLOCA entry.
(Glossary): Add Accepting State, Consistent State, Default Rule,
and IELR(1) definitions.
In Generalized LR (GLR) definition, make same changes as in
previous GLR sections.
In LALR(1) definition, say Bison uses LALR(1) by default rather
than implying Bison is limited to LALR(1).
(LocalWords): Add IELR.
(cherry picked from commit 34a6c2d19b85d4650b2d90f60b76d44071d167d1)
Joel E. Denny [Tue, 21 Apr 2009 07:40:16 +0000 (03:40 -0400)]
Finish implementing %define lr.type.
Its value can be "LALR", "IELR", or "canonical LR".
* lib/timevar.def (TV_IELR_PHASE1): New var.
(TV_IELR_PHASE2): New var.
(TV_IELR_PHASE3): New var.
(TV_IELR_PHASE4): New var.
* src/local.mk (src_bison_SOURCES): Add AnnotationList.c,
AnnotationList.h, InadequacyList.c, InadequacyList.h, Sbitset.c,
Sbitset.h, ielr.c, and ielr.h.
* src/getargs.h, src/getargs.c (enum trace, trace_args,
trace_types): Add trace_ielr.
* src/lalr.h, src/lalr.c (ngotos): Export it.
(F): Rename to...
(goto_follows): ... this, update all uses, and export it.
(set_goto_map): Export it.
(map_goto): Export it.
(compute_lookahead_tokens): Don't free goto_follows yet. Now
handled in ielr.
(initialize_LA): Export it. Move lookback allocation to...
(lalr): ... here because, for canonical LR, initialize_LA must
be invoked but lookback and much of the rest of LALR isn't
needed.
* main.c (main): Instead of lalr, invoke ielr, which invokes
lalr.
* src/reader.c (reader): Default lr.type to "LALR".
Default lr.default_rules to "accepting" if lr.type is "canonical
LR". Leave the default as "all" otherwise.
Check for a valid lr.type value.
* src/state.h, src/state.c (struct state_list): Add state_list
member.
(state_new): Initialize state_list member to NULL.
(state_new_isocore): New function, exported.
* tests/existing.at (AT_TEST_EXISTING_GRAMMAR): New macro that
exercises all values of lr.type.
(GNU AWK Grammar): Rename test group to...
(GNU AWK 3.1.0 Grammar): ... this, and extend to use
AT_TEST_EXISTING_GRAMMAR.
(GNU Cim Grammar): Extend to use AT_TEST_EXISTING_GRAMMAR.
(GNU pic Grammar): Rename test group to...
(GNU pic (Groff 1.18.1) Grammar): ... this, and extend to use
AT_TEST_EXISTING_GRAMMAR.
* tests/reduce.at (AT_TEST_LR_TYPE): New macro that exercises
all values of lr.type.
(Single State Split): New test groups using AT_TEST_LR_TYPE.
(Lane Split): Likewise.
(Complex Lane Split): Likewise.
(Split During Added Lookahead Propagation): Likewise.
Joel E. Denny [Mon, 20 Apr 2009 04:55:50 +0000 (00:55 -0400)]
Implement %define lr.default_rules.
Its value describes the states that are permitted to contain
default rules: "all", "consistent", or "accepting".
* src/reader.c (reader): Default lr.default_rules to "all".
Check for a valid lr.default_rules value.
* src/lalr.c (state_lookahead_tokens_count): If lr.default_rules
is "accepting", then only mark the accepting state as
consistent.
(initialize_LA): Tell state_lookahead_tokens_count whether
lr.default_rules is "accepting".
* src/tables.c (action_row): If lr.default_rules is not "all",
then disable default rules in inconsistent states.
* src/print.c (print_reductions): Use this opportunity to
perform some assertions about whether lr.default_rules was
obeyed correctly.
* tests/local.at (AT_TEST_TABLES_AND_PARSE): New macro that
helps with checking the parser tables for a grammar.
* tests/input.at (%define lr.default_rules invalid values): New
test group.
* tests/reduce.at (AT_TEST_LR_DEFAULT_RULES): New macro using
AT_TEST_TABLES_AND_PARSE.
(`no %define lr.default_rules'): New test group generated by
AT_TEST_LR_DEFAULT_RULES.
(`%define lr.default_rules "all"'): Likewise.
(`%define lr.default_rules "consistent"'): Likewise.
(`%define lr.default_rules "accepting"'): Likewise.
* data/bison.m4 (b4_percent_define_if_define_): Also map dashes to
underscores.
* src/scan-gram.l ({id}): Also accept dashes after the initial
letter.
({directive}): Use {id}.
* src/parse-gram.y: Comment and formatting changes.
* doc/bison.texinfo (Symbols): Adjust the lexical definitions of
symbols.
* src/complain.h, src/complain.c (yacc_at): New.
* src/symtab.c (symbol_new): Use yacc_at to report inappropriate
symbol names.
* src/output.c (token_definitions_output): Do not #define token
names with dashes.
* src/getargs.h, src/getargs.c (locations_flag): Remove.
* src/getargs.c, src/scan-code.l: Use muscle_percent_define_ensure
to set "locations" to true.
* src/output.c (prepare): Don't output "locations".
* src/scan-gram.l (%locations): Handle it as a %<flag>.
* src/parse-gram.y: It's no longer a token.
Don't handle it.
* data/bison.m4 (b4_locations_if): Define it with
b4_percent_define_if_define.
* data/c.m4, data/glr.cc: Adjust.
Joel E. Denny [Mon, 6 Apr 2009 06:16:39 +0000 (02:16 -0400)]
Fix options documentation.
* build-aux/cross-options.pl: As in --help output, write optional
arguments as [=ARG] not =[ARG].
* doc/bison.texinfo (Bison Options): Add -W/--warnings argument.
Joel E. Denny [Sun, 5 Apr 2009 00:58:46 +0000 (20:58 -0400)]
Replace BISON_PROG_GNU_M4 with Autoconf's AC_PROG_GNU_M4.
If the first m4 in $PATH is wrong, it keeps looking. Moreover, its
requirements for a correct m4 are stricter.
* m4/m4.m4: Make it a symbolic link to submodules/autoconf/m4/m4.m4.
* configure.ac: Update to use AC_PROG_GNU_M4.
Reported by Eric Blake.
* src/parse-gram.y (PERCENT_DEBUG, PERCENT_ERROR_VERBOSE): Token
definitions and associated rules, replaced by....
(PERCENT_FLAG): this new token type, and rule.
* src/scan-gram.l (RETURN_PERCENT_FLAG): New.
Use it for %debug and %error-verbose.
This allows to pass -Derror_verbose on the command line. Better yet, it
allows to pass -Derror_verbose=$(ERROR_VERBOSE), with ERROR_VERBOSE being
defined as false or true.
* data/bison.m4 (b4_percent_define_if_define): Instead of relying
on b4_percent_define_ifdef, for does not check the defined value,
but only whether the symbol is defined, rely on
b4_percent_define_flag_if, so that a value of "false" is processed
as a false.
If not defined, define the flag to "false".
(b4_error_verbose_if): New.
* data/glr.c, data/lalr1.cc, data/yacc.c: Use it instead of
b4_error_verbose_flag.
* src/getargs.h, src/getargs.c (error_verbose_flag): Remove.
* src/output.c (prepare): Don't output it.
* src/parse-gram.y (%error-verbose): Treat as %define error_verbose.
Joel E. Denny [Fri, 3 Apr 2009 07:13:36 +0000 (03:13 -0400)]
Fix strange %define locations for default values.
Reported by Akim Demaille at
<http://lists.gnu.org/archive/html/bug-bison/2007-12/msg00001.html>
and discussed again starting at
<http://lists.gnu.org/archive/html/bison-patches/2008-11/msg00102.html>.
* data/bison.m4 (b4_percent_define_default): Leave syncline blank
because location information is bogus.
Use angle brackets to delimit fake file name because square brackets
look like over-quoted m4. Choose a better fake file name.
Use negative line numbers.
* src/muscle_tab.c (muscle_percent_define_default): Likewise.
* src/location.c (location_print): If line for a boundary is negative,
only print that boundary's file name.
* src/location.h: Document that.
* tests/skeletons.at (%define Boolean variables: invalid skeleton
defaults): Update output.
Joel E. Denny [Fri, 3 Apr 2009 04:32:27 +0000 (00:32 -0400)]
Pacify ./configure --enable-gcc-warnings.
* Makefile.am (AM_CFLAGS): Remove $(WERROR_CFLAGS) because many files
in lib won't compile with it.
* src/local.mk (src_bison_CFLAGS): Use $(WERROR_CFLAGS) here only.
Akim Demaille [Fri, 27 Mar 2009 06:26:24 +0000 (07:26 +0100)]
lalr1.cc: avoid GCC 4.3 warnings.
GCC 4.3 now warns about "a || b && c" and asks for explicit
parentheses.
Reported by Alexandre Duret-Lutz.
* data/location.cc: Update copyright years.
(Position::operator==): Use parens to make precedence explicit.
Compare lines and columns first, as they are more likely to be
different, and they are faster to compare.
Akim Demaille [Wed, 31 Dec 2008 15:13:04 +0000 (16:13 +0100)]
Use locations in the variant example.
Yes, this obfuscates the point of this example, variants only. But glr.cc
cannot work (yet?) without locations. This change makes it easier to use
this example with glr.cc.
* examples/variant.yy (assert): %define it.
(locations): Request them.
(yylex): Bind the location to the stage.
Akim Demaille [Wed, 31 Dec 2008 15:08:02 +0000 (16:08 +0100)]
Dub make_TOKEN as a public type interface.
* data/c++.m4 (b4_symbol_constructor_declare)
(b4_symbol_constructor_define): New empty stubs.
(b4_public_types_declare, b4_public_types_define): Use them.
* data/lalr1.cc (b4_symbol_constructor_declare)
(b4_symbol_constructor_declare_)
(b4_symbol_constructor_define_, b4_symbol_constructor_define):
Move to...
* data/variant.hh: here.
Remove the "b4_variant_if" parts, as variant.hh is loaded only if
needed.
* data/lalr1.cc: No longer invoke b4_symbol_constructor_define and
b4_symbol_constructor_declare, as it is now done by
b4_public_types_define and b4_public_types_declare.
Akim Demaille [Wed, 31 Dec 2008 13:29:25 +0000 (14:29 +0100)]
Dub symbol_type_base as a public type.
* data/c++.m4 (b4_public_types_declare): Now define
symbol_type_base and symbol_type.
(b4_public_types_define): New.
In both cases, the definitions are taken verbatim from lalr1.cc.
* data/lalr1.cc: Adjust.
Akim Demaille [Wed, 31 Dec 2008 11:44:58 +0000 (12:44 +0100)]
b4_semantic_type_declare.
* data/c++.m4 (b4_semantic_type_declare): New.
Factors and generalizes what was in glr.cc and lalr1.cc.
* data/variant.hh (b4_semantic_type_declare): Redefine it for
variants.
* data/lalr1.cc, data/glr.cc: Use it.
Akim Demaille [Wed, 31 Dec 2008 11:35:32 +0000 (12:35 +0100)]
Make yyparser::error public.
* data/lalr1.cc: here.
There is no good reason to keep it private (and it is convenient
to use it from the scanner for instance). It is already public in
glr.cc.
Akim Demaille [Thu, 8 Jan 2009 08:41:21 +0000 (09:41 +0100)]
Fix grep portability issues.
Grep on Solaris does not support -q.
Reported by Summum Bonum.
* NEWS: Add a stub for 2.4.2.
* THANKS: Add Summum Bonum.
* tests/atlocal.in (EGREP): New.
(CC, CXX, XSLTPROC): Make it possible to override them via
envvars.
* tests/java.at: Use $EGREP instead of egrep.
Use AT_CHECK's ignore instead of grep's -q.
Akim Demaille [Thu, 11 Dec 2008 08:37:40 +0000 (09:37 +0100)]
Propagate i18n changes into glr.c.
* TODO: Update.
* data/glr.c (yyreportSyntaxError): Use "switch" instead of
building the error message format dynamically.
* data/lalr1.java: Formatting changes.
Akim Demaille [Thu, 11 Dec 2008 00:00:53 +0000 (01:00 +0100)]
Use testsuite -C.
* tests/local.mk: Replace "cd && testsuite" by "testsuite -C".
Solves problems when top_srcdir is an absolute path.
Suggested by Eric Blake.
* configure.ac: Require Autoconf 2.62.
Akim Demaille [Wed, 10 Dec 2008 23:59:13 +0000 (00:59 +0100)]
Simplify the i18n of the error messages.
* data/lalr1.cc: Comment changes.
* data/yacc.c (yysyntax_error): Rewrite, using a switch as in
lalr1.cc instead of building dynamically the format string.
Akim Demaille [Mon, 8 Dec 2008 09:26:38 +0000 (10:26 +0100)]
Fix portability issue in the test suite.
* tests/local.at (AT_MATCHES_CHECK): New.
Based on Perl instead of Sed. Sed has too many portability
pitfalls, not ever Sed is GNU Sed.
* tests/actions.at (Fix user actions without a trailing semicolon):
Use it.
Akim Demaille [Sun, 7 Dec 2008 12:58:06 +0000 (13:58 +0100)]
Test token.prefix in all the skeletons.
* data/java.m4 (b4_token_enum): Use the token.prefix.
* tests/local.at (AT_BISON_OPTION_PUSHDEFS): Define AT_TOKEN_PREFIX.
* tests/calc.at (_AT_DATA_CALC_Y): Use it.
Add checks for yacc.c, glr.c, lalr1.cc and glr.cc.
* tests/java.at: Comment changes.
(AT_CHECK_JAVA_MINIMAL): Define the END token.
(Java parser class and package names): Add token.prefix check.
Akim Demaille [Sun, 7 Dec 2008 12:44:05 +0000 (13:44 +0100)]
Fix regeneration of atconfig.
* tests/local.mk (tests/atconfig): The rule was incorrect, but
remove it: now that there is no tests/Makefile.am, the top-level
Makefile properly updates atconfig when needed.
Di-an Jan [Mon, 8 Dec 2008 05:54:45 +0000 (21:54 -0800)]
Implement the FIXME that ends an user action with a semicolon
if it seems necessary.
* src/scan-code.l (flex rules section): Flag cpp directive from
any `#' to the first unescaped end-of-line. Semicolon is not
needed after `;', `{', '}', or cpp directives and is needed after
any other token (whitespaces and comments have no effect).
* tests/actions.at (Fix user actions without a trailing semicolon):
New test.
* tests/input.at (AT_CHECK_UNUSED_VALUES): Add semicolons to
to make user actions complete statements.
Adjust column numbers in error messages.
* tests/regression.at (Fix user actions without a trailing semicolon):
Remove. Covered by new test.
Eric Blake [Tue, 2 Dec 2008 17:59:17 +0000 (10:59 -0700)]
Build testsuite with newer autoconf.
* tests/output.at (m4_expand): Don't override in newer autoconf,
where the underlying implementation changed.
* tests/cxx-type.at (_AT_RESOLVED_GLR_OUTPUT)
(_AT_RESOLVED_GLR_OUTPUT_WITH_LOC, _AT_AMBIG_GLR_OUTPUT)
(_AT_AMBIG_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
(_AT_VERBOSE_GLR_STDERR): Expand to double-quoted strings,
since some of them contain unbalanced ')'.