summaryrefslogtreecommitdiff
path: root/src/lalr.h
diff options
context:
space:
mode:
authorJoel E. Denny <jdenny@ces.clemson.edu>2007-05-07 02:56:56 +0000
committerJoel E. Denny <jdenny@ces.clemson.edu>2007-05-07 02:56:56 +0000
commit5967f0cf594cf19cd596b171392cc51bbd0ee596 (patch)
tree4fb296835aea974adbf7f8c9515d1e09978bb4a0 /src/lalr.h
parentb09f4f48512c274a7574b6a22e4a1eac6a86fd61 (diff)
downloadbison-5967f0cf594cf19cd596b171392cc51bbd0ee596.tar.gz
If conflict resolution makes states unreachable, remove those states,
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.
Diffstat (limited to 'src/lalr.h')
-rw-r--r--src/lalr.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lalr.h b/src/lalr.h
index fe148d03..0c68cd74 100644
--- a/src/lalr.h
+++ b/src/lalr.h
@@ -46,6 +46,18 @@
*/
void lalr (void);
+/**
+ * Update state numbers recorded in #goto_map, #from_state, and #to_state such
+ * that:
+ * - \c nstates_old is the old number of states.
+ * - Where \c i is the old state number, <tt>old_to_new[i]</tt> is either:
+ * - \c nstates_old if state \c i is removed because it is unreachable.
+ * Thus, remove all goto entries involving this state.
+ * - The new state number.
+ */
+void lalr_update_state_numbers (state_number old_to_new[],
+ state_number nstates_old);
+
/** Release the information related to lookahead tokens.