summaryrefslogtreecommitdiff
path: root/src/lalr.c
Commit message (Collapse)AuthorAgeFilesLines
* maint: fix some syntax-check issues.Akim Demaille2012-02-191-1/+0
| | | | | | | | | | | | | * cfg.mk (local-checks-to-skip): Remove sc_prohibit_quotearg_without_use, sc_prohibit_strcmp, sc_unmarked_diagnostics, sc_useless_cpp_parens. (sc_unmarked_diagnostics): Skip DJGPP. * data/yacc.c, src/LR0.c, src/closure.c, * src/flex-scanner.h, src/gram.c, src/lalr.c, * src/print-xml.c, src/print.c, src/print_graph.c, * src/reader.c, src/reduce.c, src/tables.c: Don't use parens with cpp's defined. Remove useless includes.
* maint: run "make update-copyright".Akim Demaille2012-01-131-1/+1
|
* maint: run "make update-copyright".Joel E. Denny2011-01-021-2/+2
|
* Do not use date ranges in copyright notices.Paul Eggert2010-06-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix some comments concerning LR(0) versus LALR(1).Joel E. Denny2010-01-041-2/+1
| | | | | | | | | | | | | | | Stop equating LR(0) with nondeterminism and LALR(1) with determinism. That is, if all states are consistent, then LR(0) tables are deterministic. On the other hand, LALR(1) tables might be nondeterministic before conflict resolution, and GLR permits LALR(1) tables to remain nondeterministic. * src/LR0.c, src/LR0.h: Here. * src/lalr.c, src/lalr.h: Here. * src/main.c (main): Here. * src/state.c, src/state.h: Here. * src/ielr.h (ielr): In preconditions, expect LR(0) not LALR(1) parser tables.
* maint: run "make update-copyright"Joel E. Denny2010-01-041-2/+2
|
* Rename muscle_tab.* to muscle-tab.* for consistency with master.Joel E. Denny2009-10-081-1/+1
| | | | | | | | | | * src/Makefile.am (bison_SOURCES): Update. * src/getargs.c, src/ielr.c, src/lalr.c, src/main.c, src/output.c, src/parse-gram.y, src/print.c, src/reader.c, src/tables.c: Update include. * src/muscle_tab.c, src/muscle_tab.h: Rename to... * src/muscle-tab.c, src/muscle-tab.h: ... these and update include.
* * src/lalr.c (state_lookahead_tokens_count): Correct comment.Joel E. Denny2009-07-241-4/+5
|
* Rename lr.default_reductions to lr.default-reductions.Joel E. Denny2009-04-291-1/+1
| | | | | | | | | | | * NEWS (2.5): Here. * doc/bison.texinfo: Here. * src/lalr.c (initialize_LA): Here. * src/print.c (print_reductions): Here. * src/reader.c (reader): Here. * src/tables.c (action_row): Here. * tests/input.at (%define enum variables): Here. * tests/reduce.at (AT_TEST_LR_DEFAULT_REDUCTIONS): Here.
* Rename "default rule" to "default reduction".Joel E. Denny2009-04-231-12/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This includes changing variable names in code, changing comments, and renaming %define lr.default_rules to %define lr.default_reductions. * NEWS (2.5): Update IELR documentation. * data/glr.c, data/lalr1.cc, data/lalr1.java, data/yacc.c: Adjust YYDEFACT and yydefact_ documentation. * doc/bison.texinfo (Decl Summary): Adjust lr.default_reductions and lr.type documentation. Make some other wording improvements. (Glossary): Adjust cross-references and Default Reduction definition. * src/lalr.c (state_lookahead_tokens_count): Adjust code. Remove a confusing comment pointed out by Akim Demaille. (initialize_LA): Adjust code. * src/print-xml.c (print_reductions): Adjust code. * src/print.c (print_reductions): Adjust code. * src/reader.c (reader): Adjust code. * src/tables.c (action_row): Adjust code. (token_actions): Adjust code. * src/tables.h: Adjust YYDEFACT documentation. * tests/input.at (%define lr.default_rules invalid values): Rename test group to... (%define lr.default_reductions invalid values): ... this, and update grammar file and expected output. * tests/reduce.at (AT_TEST_LR_DEFAULT_RULES): Rename to... (AT_TEST_LR_DEFAULT_REDUCTIONS): ... this, and update.
* Finish implementing %define lr.type.Joel E. Denny2009-04-211-21/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Implement %define lr.default_rules.Joel E. Denny2009-04-211-12/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/yacc.c: Reformat m4 a little for readability.Joel E. Denny2008-05-131-1/+1
| | | | * src/lalr.c (build_relations): Correct comment.
* Update to GPLv3.Paul Eggert2007-08-151-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/gpl-3.0.texi: New file. * doc/gpl.texi: Remove. * COPYING, GNUmakefile, HACKING, Makefile.am, Makefile.cfg: * Makefile.maint, NEWS, PACKAGING, README, README-alpha: * README-hacking, TODO, bootstrap, bootstrap.conf: * configure.ac, data/Makefile.am, 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/push.c, data/yacc.c, data/m4sugar/m4sugar.m4: * 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/Makefile.am, doc/bison.texinfo: * doc/fdl.texi, doc/refcard.tex, etc/Makefile.am, etc/README: * etc/bench.pl.in, examples/Makefile.am, examples/extexi: * examples/calc++/Makefile.am, lib/Makefile.am, 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/subpipe.c, lib/subpipe.h: * lib/timevar.c, lib/timevar.def, lib/timevar.h: * lib/vbitset.c, lib/vbitset.h, lib/yyerror.c: * m4/c-working.m4, m4/cxx.m4, m4/m4.m4, m4/subpipe.m4: * m4/timevar.m4, src/LR0.c, src/LR0.h, src/Makefile.am: * 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/lalr.c, src/lalr.h, src/location.c, src/location.h: * src/main.c, src/muscle_tab.c, src/muscle_tab.h: * src/nullable.c, src/nullable.h, src/output.c, src/output.h: * src/parse-gram.c, src/parse-gram.h, src/parse-gram.y: * 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/revision.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/Makefile.am, tests/actions.at, 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/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: Update to GPLv3.
* * src/lalr.c (state_lookahead_tokens_count): For code readability,Joel E. Denny2007-05-281-11/+6
| | | | | | | | | | | | | | | | | | | | | | | move the check for disabled transitions to an aver since conflict resolution hasn't happened yet. * src/lalr.c (state_lookahead_tokens_count): Remove the check that labels a state as inconsistent just because it has error transitions. The original form of this check appeared in revision 1.1 of lalr.c, which was committed on 1991-12-21. Now (at least), changing the consistency label on such a state appears to have no useful effect in any of the places it is examined, which I enumerate below. The key point to understanding each item in this enumeration is that a state with an error transition is labelled consistent in the first place only if it has no rules, so the check cannot matter for states that have rules. (1) Labelling a state as inconsistent will cause set_conflicts to try to identify its conflicts, and a state must have *rules* to have conflicts. (2) Labelling a state as inconsistent will affect how action_row sets the default *rule* for the state. (3) Labelling a state as inconsistent will cause build_relations to add lookback edges to *rules* in that state. * src/state.h (struct state): Word the comment for member consistent more carefully.
* Don't depend on C99 features.Joel E. Denny2007-05-281-16/+19
| | | | | | | | | | | | | | | | * src/conflicts.c (conflicts_update_state_numbers): Fix for-loop. * src/lalr.c (lalr_update_state_numbers): Fix for-loop. * src/reader.c (check_and_convert_grammar): Fix for-loop. * src/state.c (state_mark_reachable_states): Fix for-loop. (state_remove_unreachable_states): Fix for-loop. Don't widen struct state with member reachable just to temporarily record reachability. Instead, use a local bitset. * src/state.h (struct state): Remove member. * src/state.c (state_new): Don't initialize it. (state_mark_reachable_states): Rename to... (state_record_reachable_states): ... this, and use bitset. (state_remove_unreachable_states): Use bitset.
* * NEWS (2.3a+): Mention yesterday's state-removal change.Joel E. Denny2007-05-081-1/+1
| | | | | | | | (2.3a): Remove the %language entry, which was added after 2.3a. * src/LR0.c, src/closure.c, src/closure.h, src/conflicts.c, src/conflicts.h, src/lalr.c, src/lalr.h, src/print.c, src/print_graph.c, src/state.c, src/state.h, tests/conflicts.at, tests/existing.at: Update copyright date.
* If conflict resolution makes states unreachable, remove those states,Joel E. Denny2007-05-071-0/+31
| | | | | | | | | | | | | | | | | | | | | report rules that are then unused, and don't report conflicts in those states. * src/conflicts.c, src/conflicts.h (conflicts_update_state_numbers): New global function. * src/lalr.c, src/lalr.h (lalr_update_state_numbers): New global function. * src/main.c (main): After conflict resolution, remove the unreachable states and update all data structures that reference states by number. * src/state.c (state_new): Initialize each state's reachable member to false. (state_mark_reachable_states): New static function. (state_remove_unreachable_states): New global function. * src/state.h (struct state): Add member bool reachable. (state_remove_unreachable_states): Prototype. * tests/conflicts.at (Unreachable States After Conflict Resolution): New test case. * tests/existing.at (GNU pic Grammar): Update test case output now that an unused rule is discovered.
* Minor code cleanup in parser table construction.Joel E. Denny2007-05-071-1/+1
| | | | | | | | | | | | | | | * src/LR0.c (new_itemsets): Use item_number_is_symbol_number. (new_itemsets, save_reductions): Update for rename to nitemset. * src/closure.c (nritemset): Rename to... (nitemset): ... this since the "r" appears to meaningless and isn't used in the comments. (closure): Update for rename. * src/closure.h (nritemset): Update extern to... (nitemset): ... this. * src/lalr.c (LA): Fix a typo in comments. * src/print.c (print_core): Update for rename to nitemset. * src/print_graph.c (print_graph): Likewise. * src/state.h: Fix some typos in header comments.
* Port to GCC 2.95. First two problems reported by Michael Deutschmann inPaul Eggert2006-09-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | <http://lists.gnu.org/archive/html/bug-bison/2006-09/msg00018.html>. * src/parse-gram.y (symbol_declaration): Don't put statements before declarations; it's not portable to C89. * src/scan-code.l (handle_action_at): Likewise. * src/scan-code.l: Always initialize braces_level; the old code left it uninitialized and therefore had undefined behavior. Don't attempt to redefine 'assert', since it runs afoul of systems where standard headers (mistakenly) include <assert.h>. Instead, define and use our own alternative, called 'aver'. * src/reader.c: Don't include assert.h, since we no longer use assert. * src/scan-code.l: Likewise. * src/system.h (assert): Remove, replacing with.... (aver): New function, taking a bool arg. All uses changed. * src/tables.c (pack_vector): Ensure that aver arg is bool, not merely an integer.
* For consistency, use `lookahead' instead of `look-ahead' orJoel E. Denny2006-06-101-40/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `look_ahead'. Discussed starting at <http://lists.gnu.org/archive/html/bison-patches/2006-01/msg00049.html> and then at <http://lists.gnu.org/archive/html/bison-patches/2006-06/msg00017.html>. * NEWS: For the next release, note the change to `--report'. * TODO, doc/bison.1: Update English. * doc/bison.texinfo: Update English. (Understanding Your Parser, Bison Options): Document as `--report=lookahead' rather than `--report=look-ahead'. * src/conflicts.c: Update English in comments. (lookahead_set): Rename from look_ahead_set. (flush_reduce): Rename argument look_ahead_tokens to lookahead_tokens. (resolve_sr_conflict): Rename local look_ahead_tokens to lookahead_tokens, and update other uses. (flush_shift, set_conflicts, conflicts_solve, count_sr_conflicts, count_rr_conflicts, conflicts_free): Update uses. * src/getargs.c (report_args): Move "lookahead" before alternate spellings. (report_types): Update uses. (usage): For `--report' usage description, state `lookahead' spelling rather than `look-ahead'. * src/getargs.h (report.report_lookahead_tokens): Rename from report_look_ahead_tokens. * src/lalr.c: Update English in comments. (compute_lookahead_tokens): Rename from compute_look_ahead_tokens. (state_lookahead_tokens_count): Rename from state_look_ahead_tokens_count. Rename local n_look_ahead_tokens to n_lookahead_tokens. (lookahead_tokens_print): Rename from look_ahead_tokens_print. Rename local n_look_ahead_tokens to n_lookahead_tokens. Update other uses. Update English in output. (add_lookback_edge, initialize_LA, lalr, lalr_free): Update uses. * src/print.c: Update English in comments. (lookahead_set): Rename from look_ahead_set. (print_reduction): Rename argument lookahead_token from look_ahead_token. (print_core, state_default_rule, print_reductions, print_results): Update uses. * src/print_graph.c: Update English in comments. (print_core): Update uses. * src/state.c: Update English in comments. (reductions_new): Update uses. (state_rule_lookahead_tokens_print): Rename from state_rule_look_ahead_tokens_print, and update other uses. * src/state.h: Update English in comments. (reductions.lookahead_tokens): Rename from look_ahead_tokens. (state_rule_lookahead_tokens_print): Rename from state_rule_look_ahead_tokens_print. * src/tables.c: Update English in comments. (conflict_row, action_row): Update uses. * tests/glr-regression.at (Incorrect lookahead during deterministic GLR, Incorrect lookahead during nondeterministic GLR): Rename print_look_ahead to print_lookahead. * tests/torture.at: Update English in comments. (AT_DATA_LOOKAHEAD_TOKENS_GRAMMAR): Rename from AT_DATA_LOOK_AHEAD_TOKENS_GRAMMAR. (Many lookahead tokens): Update uses. * data/glr.c: Update English in comments. * lalr1.cc: Likewise. * yacc.c: Likewise. * src/conflicts.h: Likewise. * src/lalr.h: Likewise. * src/main.c: Likewise. * src/output.c: Likewise. * src/parse-gram.c: Likewise. * src/tables.h: Likewise. * tests/calc.at: Likewise.
* Be a bit more systematic about using 'abort'.Paul Eggert2006-01-211-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib/abitset.c (abitset_test): Remove ATTRIBUTE_UNUSED; not needed. * lib/bitset.c (bitset_bytes, bitset_init, bitset_op4_cmp): Put 'default: abort ();' before some other case, to satisfy older pedantic compilers. * lib/bitset_stats.c (bitset_stats_init): Likewise. * lib/ebitset.c (ebitset_elt_find, ebitset_op3_cmp): Likewise. * lib/lbitset.c (lbitset_elt_find, lbitset_op3_cmp): Likewise. * src/conflicts.c (resolve_sr_conflict): Likewise. * src/vcg.c (get_color_str, get_textmode_str, get_shape_str): (get_decision_str, get_orientation_str, get_node_alignment_str): (get_arrow_mode_str, get_crossing_type_str, get_view_str): (get_linestyle_str, get_arrowstyle_str): Likewise. * src/conflicts.c (resolve_sr_conflict): Use a default case rather than one for the one remaining enum value, to catch invalid enum values as well. * src/lalr.c (set_goto_map, map_goto): Prefer "assert (FOO);" to "if (!FOO) abort ();". * src/nullable.c (nullable_compute, token_definitions_output): Likewise. * src/reader.c (packgram, reader): Likewise. * src/state.c (transitions_to, state_new, state_reduction_find): Likewise. * src/symtab.c (symbol_user_token_number_set, symbol_make_alias): (symbol_pack): Likewise. * src/tables.c (conflict_row, pack_vector): Likewise. * src/scan-skel.l (QPUTS): Remove unnecessary parens. (BASE_QPUTS, "@output ".*\n): Remove unnecessary asserts. * src/system.h: Don't include <assert.h>. (assert): New macro.
* Avoid undefined behavior that accessed just before the start of an array.Paul Eggert2006-01-181-6/+8
| | | | | | * src/reader.c (packgram): Prepend a new sentinel before ritem. * src/lalr.c (build_relations): Rely on new sentinel. * src/gram.c (gram_free): Adjust to new sentinel.
* Work around portability problem on Solaris 10: flex-generatedPaul Eggert2005-12-091-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | files include <stdio.h> before <config.h>, which messes up because the latter defines __EXTENSIONS__. Address the problem by creating two new little files that include <config.h> first, then include the flex-generated files. Rewrite everyone else to include <config.h> first, as well. * lib/timevar.c: Always include "config.h". * src/Makefile.am (bison_SOURCES): Replace scan-gram.l with scan-gram-c.c, and scan-skel.l with scan-skel-c.c. (EXTRA_bison_SOURCES): New macro. * src/scan-gram-c.c, src/scan-skel-c.c: New files. * src/system.h: Don't include config.h. * src/LR0.c: Include <config.h> first. * src/assoc.c: Likewise. * src/closure.c: Likewise. * src/complain.c: Likewise. * src/conflicts.c: Likewise. * src/derives.c: Likewise. * src/files.c: Likewise. * src/getargs.c: Likewise. * src/gram.c: Likewise. * src/lalr.c: Likewise. * src/location.c: Likewise. * src/main.c: Likewise. * src/muscle_tab.c: Likewise. * src/nullable.c: Likewise. * src/output.c: Likewise. * src/parse-gram.y: Likewise. * src/print.c: Likewise. * src/print_graph.c: Likewise. * src/reader.c: Likewise. * src/reduce.c: Likewise. * src/relation.c: Likewise. * src/state.c: Likewise. * src/symlist.c: Likewise. * src/symtab.c: Likewise. * src/tables.c: Likewise. * src/uniqstr.c: Likewise. * src/vcg.c: Likewise.
* Undo the parts of the unlocked-I/O change that substitutedPaul Eggert2005-10-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | putc or puts for printf. This might hurt performance a bit, but some people prefer the printf style. * data/c.m4 (yysymprint): Prefer printf to puts and putc. * data/glr.c (YYFPUTC, YYFPUTS, YYDPUTS): Remove. All uses replaced by YYFPRINTF and YYDPRINTF. * data/yacc.c: Likewise. * lib/bitset.c (bitset_print): Likewise. * lib/bitsetv.c (bitsetv_dump, debug-bitsetv): Prefer printf to putc and puts. * lib/lbitset.c (debug_lbitset): Likewise. * src/closure.c (print_firsts, print_fderives): Likewise. * src/gram.c (grammar_dump): Likewise. * src/lalr.c (look_ahead_tokens_print): Likewise. * src/output.c (escaped_output): Likewise. (user_actions_output): Break apart two printfs. * src/parse-gram.y (%printer): Prefer printf to putc and puts. * src/reduce.c (reduce_print): Likewise. * src/state.c (state_rule_look_ahead_tokens_print): Likewise. * src/system.h: Include unlocked-io.h rathe than stdio.h.
* Use unlocked I/O for a minor performance improvement on hosts likePaul Eggert2005-10-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | GNU/Linux and Solaris that support unlocked I/O. The basic idea is to use the gnlib unlocked-io module, and to prefer putc and puts to printf when either will work (since the latter doesn't come in an unlocked flavor). * bootstrap (gnulib_modules): Add unlocked-io. * data/c.m4 (yysymprint): Prefer puts and putc to printf. * data/glr.c (YYFPUTC, YYFPUTS, YYDPUTS): New macros. Prefer them to YYFPRINTF and YYDPRINTF if either will do, and similarly for puts and putc and printf. * data/yacc.c: Likewise. * lib/bitset.c (bitset_print): Likewise. * lib/bitset.h [USE_UNLOCKED_IO]: Include unlocked-io.h. * lib/bitsetv.c (bitsetv_dump, debug-bitsetv): Prefer putc and puts to printf. * lib/lbitset.c (debug_lbitset): Likewise. * src/closure.c (print_firsts, print_fderives): Likewise. * src/gram.c (grammar_dump): Likewise. * src/lalr.c (look_ahead_tokens_print): Likewise. * src/output.c (escaped_output): Likewise. (user_actions_output): Coalesce two printfs. * src/parse-gram.h (%printer): Prefer putc and puts to printf. * src/reduce.c (reduce_print): Likewise. * src/state.c (state_rule_look_ahead_tokens_print): Likewise. * src/system.h: Include unlocked-io.h rathe than stdio.h.
* Update FSF postal mail address.Paul Eggert2005-05-141-2/+2
|
* * src/system.h (CALLOC, MALLOC, REALLOC): Remove. All callersPaul Eggert2004-12-101-16/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | changed to use xcalloc, xnmalloc, xnrealloc, respectively, unless otherwise specified below. * src/LR0.c (allocate_itemsets): Use xnmalloc, not xcalloc, to allocate kernel_base, kernel_items, kernel_size, since they needn't be initialized to 0. (allocate_storgae): Likewise, for shiftset, redset, shift_symbol. * src/closure.c (new_closure): Likewise, for itemset. * src/derives.c (derives_compute): Likewise, for delts, derives, q. * src/lalr.c (set_goto_map): Likewise, for temp_map. (initialize_F): Likewise, for reads, edge, reads[i], includes[i]. (build_relations): Likewise for edge, states1, includes. * src/nullable.c (nullable_compute): Likewise, for squeue, relts. * src/reader.c (packgram): Likewise, for ritem, rules. * src/reduce.c (nonterminals_reduce): Likewise for nontermmap. * src/relation.c (relation_digraph): Likewise for VERTICES. (relation_transpose): Likewise for new_R, end_R. * src/symtab.c (symbols_token_translations_init): Likewise for token_translations. * src/tables.c (save_row): Likewise for froms, tos, conflict_tos. (token_actions): Likewise for yydefact, actrow, conflrow, conflict_list. (save_column): Likewise for froms[symno], tos[symno]. (goto_actions): Likewise for state_count. (pack_table): Likewise for base, pos, check. (tables_generate): Likewise for width. * src/LR0.c (set_states): Don't reuse kernel_size and kernel_base for initial core. Just have a separate core, so we needn't worry about whether kernel_size and kernel_base are initialized. * src/LR0.c (shift_symbol, redset, shiftset, kernel_base, kernel_size, kernel_items): Remove unnecessary initialization. * src/conflicts.c (conflicts): Likewise. * src/derives.c (derives): Likewise. * src/muscle_tablc (muscle_insert): Likewise. * src/relation.c (relation_digraph): Likewise. * src/tables.c (froms, tos, conflict_tos, tally, width, actrow, order, conflrow, conflict_table, conflict_list, table, check): Likewise. * src/closure.c (new_closure): Arg is of type unsigned int, not int. This is because all callers pass unsigned int. * src/closure.h (new_closure): Likewise. * src/lalr.c (initialize_F): Initialize reads[i] in all cases. (build_relations): Initialize includes[i] in all cases. * src/reader.c (packgram): Always initialize rules[ruleno].prec and rules[ruleno].precsym. Initialize members in order. * src/relation.c (relation_transpose): Always initialize new_R[i] and end_R[i]. * src/table.c (conflict_row): Initialize 0 at end of conflict_list. * src/output.c (prepare_actions): Pass 0 instead of conflict_list[0]; conflict_list[0] was always 0, but now it isn't initialized. * src/table.c (table_grow): When conflict_table grew, the grown area wasn't cleared. Fix this.
* (set_goto_map): Don't allow ngotos to equalPaul Eggert2004-12-081-14/+17
| | | | | | | | GOTO_NUMBER_MAXIMUM, since we occasionally compute ngotos + 1 without checking for overflow. (build_relations): Use END_NODE, not -1, to denote end of edges. (set_goto_map, map_goto, initialize_F, add_loopback_edge, build_relations): Use goto_number, not int, for goto numbers.
* XFREE -> freePaul Eggert2004-11-221-9/+9
|
* (goto_map, ngotos, from_state, to_state): OmitPaul Eggert2004-10-221-6/+6
| | | | | initial values, since they're never used. (set_goto_map): ngotos is now unsigned, so test for overflow
* Use "look-ahead" instead of "lookahead", consistently.Paul Eggert2004-06-211-40/+40
|
* Switch from 'int' to 'bool' where that makes sense.Paul Eggert2003-05-241-5/+5
|
* (set_goto_map): Do not subtract from the returned value of malloc.Paul Eggert2002-12-131-27/+28
| | | | | (add_lookback_edge): Use malloc rather than calloc, since the resulting storage is always stored into.
* (struct goto_list): Renamed from struct goto_list_s.Paul Eggert2002-12-111-81/+83
| | | | (goto_list): Renamed from goto_list_t.
* (set_goto_map, map_goto): Use abort rather than assert.Paul Eggert2002-11-211-6/+5
|
* * src/tables.c (tables_generate): Use free for pointers thatAkim Demaille2002-11-121-3/+1
| | | | | | | | | | cannot be NULL, not XFREE. (pack_vector): Use assert, not fatal, for bound violations. * src/state.c (state_new): Likewise. * src/reader.c (reader): Likewise. * src/lalr.c (set_goto_map): Likewise. * src/location.h (LOCATION_PRINT): If first_line is 0, just issue the file name.
* * src/assoc.c, src/closure.c, src/gram.c, src/injections.c,Akim Demaille2002-09-041-4/+4
| | | | | * src/lalr.c, src/LR0.c, src/relation.c, src/tables.c: Don't translate maintainer only messages.
* (lookaheads_print): Wrap strings in _() if they need translation.Paul Eggert2002-08-121-4/+4
|
* Instead of attaching lookaheads and duplicating the rules beingAkim Demaille2002-08-011-109/+74
| | | | | | | | | | | | | | | | | | | | | | | reduced by a state, attach the lookaheads to the reductions. * src/state.h (state_t): Remove the `lookaheads', `lookaheads_rule' member. (reductions_t): Add a `lookaheads' member. Use a regular array for the `rules'. * src/state.c (reductions_new): Initialize the lookaheads member to 0. (state_rule_lookaheads_print): Adjust. * src/state.h, src/state.c (state_reductions_find): New. * src/conflicts.c (resolve_sr_conflict, set_conflicts) (count_rr_conflicts): Adjust. * src/lalr.c (LArule): Remove. (add_lookback_edge): Adjust. (state_lookaheads_count): New. (states_lookaheads_initialize): Merge into... (initialize_LA): this. (lalr_free): Adjust. * src/main.c (main): Don't free nullable and derives too early: it is used by --verbose. * src/print.c, src/print_graph.c, src/tables.c: Adjust.
* * src/derives.h, src/derives.c (derives): A `rule_t***' instead ofAkim Demaille2002-08-011-6/+6
| | | | | | | | | | | | | | `rule_number_t**'. (set_derives, free_derives): Rename as... (derives_compute, derives_free): this. Adjust all dependencies. * src/nullable.c (set_nullable, free_nullable): Rename as... (nullable_compute, nullable_free): these. (rule_list_t): Store rule_t *, not rule_number_t. * src/state.c (state_rule_lookaheads_print): Directly compare rule pointers, instead of their numbers. * src/main.c (main): Call nullable_free, and derives_free earlier, as they were lo longer used.
* * lib/timevar.c (get_time): Include children time.Akim Demaille2002-08-011-2/+30
| | | | | | | | | | | | | | * src/lalr.h (LA, LArule): Don't export them: used with the state_t. * src/lalr.c (LA, LArule): Static. * src/lalr.h, src/lalr.c (lalr_free): New. * src/main.c (main): Call it. * src/tables.c (pack_vector): Check whether loc is >= to the table_size, not >. (pack_tables): Don't free froms, tos, conflict_tos, and pos... (tables_generate): do it, since that's also it which allocates them. Don't free LA and LArule, main does.
* Let --trace have arguments.Akim Demaille2002-07-311-1/+1
| | | | | | | | | | | | | | | | * src/getargs.h (enum trace_e): New. * src/getargs.c (trace_args, trace_types, trace_argmatch): New. (long_options, short_options): --trace/-T takes an optional argument. Change all the uses of trace_flag to reflect the new flags. * tests/sets.at (Firsts, Nullable, Broken Closure): Use --trace=sets. Strengthen `stage' portability. * m4/stage.m4 (BISON_PREREQ_STAGE): New. * configure.in: Use it. Don't check for malloc.h and sys/times.h. * src/system.h: Include them when appropriate. * src/main.c (stage): Compile only when mallinfo, struct mallinfo, times and struct tms are available.
* * src/state.h, src/state.c (transitions_t): Holds state_t*'s, notAkim Demaille2002-07-291-5/+6
| | | | | | | | | state_number_t. (errs_t): symbol_t*, not symbol_number_t. (reductions_t): rule_t*, not rule_number_t. (FOR_EACH_SHIFT): New. * src/LR0.c, src/conflicts.c, src/lalr.c, src/output.c * src/print.c, src/print_graph.c: Adjust.
* Stop storing rules from 1 to nrules + 1.Akim Demaille2002-07-251-2/+2
| | | | | | | | | | | | | | | | | | * src/LR0.c, src/closure.c, src/derives.c, src/gram.c, src/lalr.c * src/nullable.c, src/output.c, src/print.c, src/reader.c * src/reduce.c: Allocate and free from &rules[0], not &rules[1]. Iterate from 0 to nrules. Use rule_number_as_item_number and item_number_as_rule_number. Adjust to `derive' now containing possibly 0. * src/gram.h (rule_number_as_item_number, item_number_as_rule_number): Handle the `- 1' part in rule numbers from/to item numbers. * src/conflicts.c (log_resolution): Fix the message which reversed shift and reduce. * src/output.c (action_row): Initialize default_rule to -1. (token_actions): Adjust. * tests/sets.at (Nullable, Firsts): Fix the previously bogus expected output. * tests/conflicts.at (Resolved SR Conflicts): Likewise.
* * src/lalr.h, src/lalr.c (goto_number_t): New.Akim Demaille2002-07-031-23/+31
| | | | | | | | * src/lalr.c (goto_list_t): New. Propagate them. * src/nullable.c (rule_list_t): New. Propagate. * src/types.h: Remove.
* Fix some memory leaks, and fix a bug: state 0 was examined twice.Akim Demaille2002-07-031-6/+6
| | | | | | | | | | | | | | | | | | | | | | * src/LR0.c (new_state): Merge into... (state_list_append): this. (new_states): Merge into... (generate_states): here. (set_states): Don't ensure a proper `errs' state member here, do it... * src/conflicts.c (conflicts_solve): here. * src/state.h, src/state.c: Comment changes. (state_t): Rename member `shifts' as `transitions'. Adjust all dependencies. (errs_new): For consistency, also take the values as argument. (errs_dup): Remove. (state_errs_set): New. (state_reductions_set, state_transitions_set): Assert that no previous value was assigned. (state_free): New. (states_free): Use it. * src/conflicts.c (resolve_sr_conflict): Don't use an `errs_t' as temporary storage: use `errs' and `nerrs' as elsewhere. (set_conflicts): Allocate and free this `errs'.
* * lib/libiberty.h: New.Akim Demaille2002-07-021-2/+4
| | | | | | | * lib: Update the bitset implementation from upstream. * src/closure.c, src/lalr.c, src/output.c, src/print_graph.c, * src/state.c: Use BITSET_FOR_EACH, not BITSET_EXECUTE. * src/main.c: Adjust bitset stats calls.
* We spend a lot of time in quotearg, in particular when --verbose.Akim Demaille2002-06-301-1/+1
| | | | | | * src/symtab.c (symbol_get): Store a quoted version of the key. (symbol_tag_get, symbol_tag_get_n, symbol_tag_print): Remove. Adjust all callers.
* * src/state.h (reductions_t): Rename member `nreds' as num.Akim Demaille2002-06-301-4/+4
| | | | | (errs_t): Rename members `nerrs' and `errs' as `num' and `symbols'. * src/state.c (ERRS_ALLOC, REDUCTIONS_ALLOC): Use the correct types.