mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
cex: use state_item_number consistently
* src/counterexample.c, src/state-item.c: here. (counterexample_report_state): While at it, prefer c2 to j/k, to match c1.
This commit is contained in:
@@ -1274,7 +1274,7 @@ counterexample_report_reduce_reduce (state_item_number itm1, state_item_number i
|
||||
static state_item_number
|
||||
find_state_item_number (const rule *r, state_number sn)
|
||||
{
|
||||
for (int i = state_item_map[sn]; i < state_item_map[sn + 1]; ++i)
|
||||
for (state_item_number i = state_item_map[sn]; i < state_item_map[sn + 1]; ++i)
|
||||
if (!SI_DISABLED (i)
|
||||
&& item_number_as_rule_number (*state_items[i].item) == r->number)
|
||||
return i;
|
||||
@@ -1290,13 +1290,13 @@ counterexample_report_state (const state *s, FILE *out, const char *prefix)
|
||||
{
|
||||
const rule *r1 = reds->rules[i];
|
||||
const state_item_number c1 = find_state_item_number (r1, sn);
|
||||
for (int j = state_item_map[sn]; j < state_item_map[sn + 1]; ++j)
|
||||
if (!SI_DISABLED (j))
|
||||
for (state_item_number c2 = state_item_map[sn]; c2 < state_item_map[sn + 1]; ++c2)
|
||||
if (!SI_DISABLED (c2))
|
||||
{
|
||||
item_number conf = *state_items[j].item;
|
||||
item_number conf = *state_items[c2].item;
|
||||
if (item_number_is_symbol_number (conf)
|
||||
&& bitset_test (reds->lookahead_tokens[i], conf))
|
||||
counterexample_report_shift_reduce (c1, j, conf, out, prefix);
|
||||
counterexample_report_shift_reduce (c1, c2, conf, out, prefix);
|
||||
}
|
||||
for (int j = i+1; j < reds->num; ++j)
|
||||
{
|
||||
@@ -1306,11 +1306,11 @@ counterexample_report_state (const state *s, FILE *out, const char *prefix)
|
||||
reds->lookahead_tokens[i],
|
||||
reds->lookahead_tokens[j]);
|
||||
if (!bitset_empty_p (conf))
|
||||
for (int k = state_item_map[sn]; k < state_item_map[sn + 1]; ++k)
|
||||
if (!SI_DISABLED (k)
|
||||
&& item_rule (state_items[k].item) == r2)
|
||||
for (state_item_number c2 = state_item_map[sn]; c2 < state_item_map[sn + 1]; ++c2)
|
||||
if (!SI_DISABLED (c2)
|
||||
&& item_rule (state_items[c2].item) == r2)
|
||||
{
|
||||
counterexample_report_reduce_reduce (c1, k, conf, out, prefix);
|
||||
counterexample_report_reduce_reduce (c1, c2, conf, out, prefix);
|
||||
break;
|
||||
}
|
||||
bitset_free (conf);
|
||||
|
||||
@@ -211,7 +211,7 @@ init_trans (void)
|
||||
for (int j = 0; j < t->num; ++j)
|
||||
if (!TRANSITION_IS_DISABLED (t, j))
|
||||
hash_xinsert (transition_set, t->states[j]);
|
||||
for (int j = state_item_map[i]; j < state_item_map[i + 1]; ++j)
|
||||
for (state_item_number j = state_item_map[i]; j < state_item_map[i + 1]; ++j)
|
||||
{
|
||||
item_number *item = state_items[j].item;
|
||||
if (item_number_is_rule_number (*item))
|
||||
@@ -248,7 +248,7 @@ init_prods (void)
|
||||
|
||||
// Add the nitems of state to skip to the production portion
|
||||
// of that state's state_items
|
||||
for (int j = state_item_map[i] + s->nitems;
|
||||
for (state_item_number j = state_item_map[i] + s->nitems;
|
||||
j < state_item_map[i + 1]; ++j)
|
||||
{
|
||||
state_item *src = &state_items[j];
|
||||
@@ -264,7 +264,7 @@ init_prods (void)
|
||||
}
|
||||
// For each item with a dot followed by a nonterminal,
|
||||
// try to create a production edge.
|
||||
for (int j = state_item_map[i]; j < state_item_map[i + 1]; ++j)
|
||||
for (state_item_number j = state_item_map[i]; j < state_item_map[i + 1]; ++j)
|
||||
{
|
||||
state_item *src = &state_items[j];
|
||||
item_number item = *(src->item);
|
||||
@@ -492,7 +492,7 @@ state_items_report (void)
|
||||
for (state_number i = 0; i < nstates; ++i)
|
||||
{
|
||||
printf ("State %d:\n", i);
|
||||
for (int j = state_item_map[i]; j < state_item_map[i + 1]; ++j)
|
||||
for (state_item_number j = state_item_map[i]; j < state_item_map[i + 1]; ++j)
|
||||
{
|
||||
state_item *si = &state_items[j];
|
||||
item_print (si->item, NULL, stdout);
|
||||
@@ -560,7 +560,7 @@ state_items_init (void)
|
||||
void
|
||||
state_items_free (void)
|
||||
{
|
||||
for (int i = 0; i < nstate_items; ++i)
|
||||
for (state_item_number i = 0; i < nstate_items; ++i)
|
||||
if (!SI_DISABLED (i))
|
||||
{
|
||||
state_item *si = &state_items[i];
|
||||
@@ -592,5 +592,5 @@ production_allowed (const state_item *si, const state_item *next)
|
||||
if (prec1 == prec2 && s1->assoc == left_assoc)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user