mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 07:43:03 +00:00
Don't depend on C99 features.
* 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.
This commit is contained in:
35
src/lalr.c
35
src/lalr.c
@@ -459,22 +459,25 @@ lalr_update_state_numbers (state_number old_to_new[], state_number nstates_old)
|
||||
goto_number ngotos_reachable = 0;
|
||||
symbol_number nonterminal = 0;
|
||||
aver (nsyms == nvars + ntokens);
|
||||
for (goto_number i = 0; i < ngotos; ++i)
|
||||
{
|
||||
while (i == goto_map[nonterminal])
|
||||
goto_map[nonterminal++] = ngotos_reachable;
|
||||
/* If old_to_new[from_state[i]] = nstates_old, remove this goto
|
||||
entry. */
|
||||
if (old_to_new[from_state[i]] != nstates_old)
|
||||
{
|
||||
/* from_state[i] is not removed, so it and thus to_state[i] are
|
||||
reachable, so to_state[i] != nstates_old. */
|
||||
aver (old_to_new[to_state[i]] != nstates_old);
|
||||
from_state[ngotos_reachable] = old_to_new[from_state[i]];
|
||||
to_state[ngotos_reachable] = old_to_new[to_state[i]];
|
||||
++ngotos_reachable;
|
||||
}
|
||||
}
|
||||
{
|
||||
goto_number i;
|
||||
for (i = 0; i < ngotos; ++i)
|
||||
{
|
||||
while (i == goto_map[nonterminal])
|
||||
goto_map[nonterminal++] = ngotos_reachable;
|
||||
/* If old_to_new[from_state[i]] = nstates_old, remove this goto
|
||||
entry. */
|
||||
if (old_to_new[from_state[i]] != nstates_old)
|
||||
{
|
||||
/* from_state[i] is not removed, so it and thus to_state[i] are
|
||||
reachable, so to_state[i] != nstates_old. */
|
||||
aver (old_to_new[to_state[i]] != nstates_old);
|
||||
from_state[ngotos_reachable] = old_to_new[from_state[i]];
|
||||
to_state[ngotos_reachable] = old_to_new[to_state[i]];
|
||||
++ngotos_reachable;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (nonterminal <= nvars)
|
||||
{
|
||||
aver (ngotos == goto_map[nonterminal]);
|
||||
|
||||
Reference in New Issue
Block a user