mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 23:03:04 +00:00
Fix some memory leaks, and fix a bug: state 0 was examined twice.
* 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'.
This commit is contained in:
12
src/lalr.c
12
src/lalr.c
@@ -94,7 +94,7 @@ set_goto_map (void)
|
||||
ngotos = 0;
|
||||
for (state = 0; state < nstates; ++state)
|
||||
{
|
||||
transitions_t *sp = states[state]->shifts;
|
||||
transitions_t *sp = states[state]->transitions;
|
||||
int i;
|
||||
for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
|
||||
{
|
||||
@@ -127,7 +127,7 @@ set_goto_map (void)
|
||||
|
||||
for (state = 0; state < nstates; ++state)
|
||||
{
|
||||
transitions_t *sp = states[state]->shifts;
|
||||
transitions_t *sp = states[state]->transitions;
|
||||
int i;
|
||||
for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
|
||||
{
|
||||
@@ -189,7 +189,7 @@ initialize_F (void)
|
||||
for (i = 0; i < ngotos; i++)
|
||||
{
|
||||
state_number_t stateno = to_state[i];
|
||||
transitions_t *sp = states[stateno]->shifts;
|
||||
transitions_t *sp = states[stateno]->transitions;
|
||||
|
||||
int j;
|
||||
for (j = 0; j < sp->num && TRANSITION_IS_SHIFT (sp, j); j++)
|
||||
@@ -266,8 +266,8 @@ build_relations (void)
|
||||
|
||||
for (rp = rules[*rulep].rhs; *rp >= 0; rp++)
|
||||
{
|
||||
state = transitions_to (state->shifts,
|
||||
item_number_as_symbol_number (*rp));
|
||||
state = transitions_to (state->transitions,
|
||||
item_number_as_symbol_number (*rp));
|
||||
states1[length++] = state->number;
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ states_lookaheads_count (void)
|
||||
int k;
|
||||
int nlookaheads = 0;
|
||||
reductions_t *rp = states[i]->reductions;
|
||||
transitions_t *sp = states[i]->shifts;
|
||||
transitions_t *sp = states[i]->transitions;
|
||||
|
||||
/* We need a lookahead either to distinguish different
|
||||
reductions (i.e., there are two or more), or to distinguish a
|
||||
|
||||
Reference in New Issue
Block a user