* 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.
Akim Demaille [Wed, 10 Jun 2009 18:14:52 +0000 (20:14 +0200)]
deterministic test suite.
Some consistency checks on symbols are performed after all the
symbols were read, by an iteration over the symbol table. This
traversal is nondeterministic, which can be a problem for test
cases.
Avoid this.
Addresses another form of nondeterminism reported by Joel E. Denny.
http://lists.gnu.org/archive/html/bison-patches/2009-05/msg00023.html
* tests/input.at (Numbered tokens): Split the hexadecimal/decimal
test in two.
Use different file names for the three tests to make the
maintenance easier.
Akim Demaille [Wed, 10 Jun 2009 08:40:55 +0000 (10:40 +0200)]
gnulib: update.
* gnulib: Update to latest.
* lib/.cvsignore, lib/.gitignore, m4/.cvsignore,
* m4/.gitignore: Regen.
* src/symtab.c (symbol_from_uniqstr, semantic_type_from_uniqstr):
Call xalloc_die on hash_insert failures.
Requested by the new __warn_unused_result__ attribute of
hash_insert.
Joel E. Denny [Fri, 22 May 2009 05:39:07 +0000 (01:39 -0400)]
Update some comments to make sense for -D.
* data/bison.m4 (b4_check_user_names): In header comments, say
"user occurrence" instead of "grammar occurrence".
* src/muscle_tab.h (muscle_percent_define_insert): Likewise.
(muscle_percent_code_grow): Likewise just for consistency.
Joel E. Denny [Tue, 19 May 2009 21:51:05 +0000 (17:51 -0400)]
Handle a trailing `:' in a user-supplied C++ namespace better.
* data/c++.m4 (b4_namespace_close): Don't let it be printed
among the closing braces here. This fix might make the
generated code easier to debug, but otherwise it should be
insignificant because a trailing `:' is a C++ error already.
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_grammar): 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.
* 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.
(cherry picked from commit 4f646c3794c45940aaf96d5409eff02a2c74978e)
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.
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/Makefile.am (bison_SOURCES): Add AnnotationList.c,
AnnotationList.h, InadequacyList.c, InadequacyList.h, Sbitset.c,
Sbitset.h, ielr.h, and ielr.c.
* 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.
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.
(cherry picked from commit 6617622c9aaa6ec3a9de5b0867421e2849b68b2f)
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.
(cherry picked from commit e8cd1ad655bcc704b06fb2f191dc3ac1df32b796)
Akim Demaille [Tue, 12 Aug 2008 19:48:44 +0000 (21:48 +0200)]
--trace=muscles
* src/getargs.h, src/getargs.c (trace_muscle): New.
(trace_types, trace_args): Support it.
* src/output.c (output_skeleton): Use it.
(cherry picked from commit 5263bea9f7d576c20938619af2197eb5b47a90c3)
Di-an Jan [Thu, 20 Nov 2008 20:36:30 +0000 (12:36 -0800)]
Improves options in the manual.
* doc/bison.texinfo (-g, -x): Add space before argument.
(Option Cross Key): Implement FIXME: listing directives also.
* build-aux/cross-options.pl: Read from <STDIN> rather than <>.
(Short Option): Special case -d. Put arguments inside @option.
(Bison Directive): Add column, automatically extracted from
src/scan-gram.l (actual name passed as the first argument)
with special case for %define.
* doc/Makefile.am (doc/cross-options.texi): Pass src/scan-gram.l
to build-aux/cross-options.pl.
* src/getargs.c (usage): Document limitations of cross-options.pl.
* src/scan-gram.l: Likewise.
Pass command line location to skeleton_arg and language_argmatch.
* src/getargs.h, src/getargs.c (skeleton_arg, language_argmatch):
The location argument is now mandatory.
Adjust all dependencies.
(getargs): Use command_line_location.
Initialize the muscle table before parsing the command line.
* src/getargs.c (quotearg.h, muscle_tab.h): Include.
(getargs): Define file_name.
* src/main.c (main): Initialize muscle_tab before calling
getargs.
* src/muscle_tab.c (muscle_init): No longer define file_name, as
its value is not available yet.
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.
* build-aux/cross-options.pl: The argument ends at the first
space, not the first non-symbol character.
Use @var for each word appearing the argument description.
(cherry picked from commit 74eae918c3bf3772d260cb25777d9a998172a401)
Joel E. Denny [Sun, 5 Apr 2009 01:12:23 +0000 (21:12 -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: Replace with Autoconf 2.63's m4/m4.m4.
* configure.ac: Update to use AC_PROG_GNU_M4.
Reported by Eric Blake.
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.
Akim Demaille [Thu, 26 Mar 2009 22:02:18 +0000 (23:02 +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 [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.
Eric Blake [Fri, 5 Dec 2008 16:26:38 +0000 (09:26 -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 ')'.
Joel E. Denny [Wed, 19 Nov 2008 03:34:26 +0000 (22:34 -0500)]
Fix unexpanded macros in GLR defines file.
Reported by Csaba Raduly at
<http://lists.gnu.org/archive/html/bug-bison/2008-11/msg00048.html>.
* THANKS (Csaba Raduly): Add.
* data/glr.c: Fix overquoting on b4_prefix for yylval and yylloc.
* tests/calc.at (_AT_DATA_CALC_Y): If %defines is specified, generate
lexer in a separate module that includes the defines file.
(AT_CHECK_CALC): Use AT_FULL_COMPILE and request compilation of lexer
source.
* tests/local.at (_AT_BISON_OPTION_PUSHDEFS): Push AT_DEFINES_IF.
Adjust AT_LOC and AT_VAL to use AT_NAME_PREFIX.
(AT_BISON_OPTION_POPDEFS): Pop AT_DEFINES_IF.
(AT_DATA_SOURCE_PROLOGUE): New.
(AT_DATA_GRAMMAR_PROLOGUE): Use AT_DATA_SOURCE_PROLOGUE.
(AT_DATA_SOURCE): New.
(AT_FULL_COMPILE): New, copied from master branch and extended to
support an additional output file.
Di-an Jan [Mon, 17 Nov 2008 10:07:29 +0000 (11:07 +0100)]
Fix formatting and content of bison.texinfo menus
* doc/bison.texinfo: Synchronize ``Detail Node Listing''.
Align menus. Adjust word wrapping. Use node names for menu names.
(Examples): Don't abbreviate node names.
(LocalWords): Remove abbreviations.
(Copying): Make description a sentence.
(Java Action Features): Remove period to match the rest of menu.
Joel E. Denny [Fri, 7 Nov 2008 21:48:31 +0000 (16:48 -0500)]
Clean up %skeleton and %language priority implementation.
* src/getargs.c (skeleton_prio): Use default_prio rather than 2, and
remove static qualifier because others will soon need to see it.
(language_prio): Likewise.
(getargs): Use command_line_prio rather than 0.
* src/getargs.h (command_line_prio, grammar_prio, default_prio): New
enum fields.
(skeleton_prio): Extern it.
(language_prio): Extern it.
* src/parse-gram.y: Use grammar_prio rather than 1.