mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-11 13:23:04 +00:00
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.
This commit is contained in:
12
src/state.h
12
src/state.h
@@ -209,6 +209,11 @@ struct state
|
||||
a human readable description of the resolution. */
|
||||
const char *solved_conflicts;
|
||||
|
||||
/* Conflict resolution sometimes makes states unreachable. Initialized to 0
|
||||
in state_new and then used by state_remove_unreachable_states after
|
||||
conflicts_solve. */
|
||||
bool reachable;
|
||||
|
||||
/* Its items. Must be last, since ITEMS can be arbitrarily large.
|
||||
*/
|
||||
size_t nitems;
|
||||
@@ -248,9 +253,16 @@ state *state_hash_lookup (size_t core_size, item_number *core);
|
||||
/* Insert STATE in the state hash table. */
|
||||
void state_hash_insert (state *s);
|
||||
|
||||
/* Remove unreachable states, renumber remaining states, update NSTATES, and
|
||||
write to OLD_TO_NEW a mapping of old state numbers to new state numbers such
|
||||
that the old value of NSTATES is written as the new state number for removed
|
||||
states. The size of OLD_TO_NEW must be the old value of NSTATES. */
|
||||
void state_remove_unreachable_states (state_number old_to_new[]);
|
||||
|
||||
/* All the states, indexed by the state number. */
|
||||
extern state **states;
|
||||
|
||||
/* Free all the states. */
|
||||
void states_free (void);
|
||||
|
||||
#endif /* !STATE_H_ */
|
||||
|
||||
Reference in New Issue
Block a user