- symbol_number_t symbol1 = states[to_state[i]]->accessing_symbol;
- rule_t **rulep;
-
- for (rulep = derives[symbol1]; *rulep; rulep++)
- {
- int done;
- int length = 1;
- item_number_t *rp;
- state_t *state = states[from_state[i]];
- states1[0] = state->number;
-
- for (rp = (*rulep)->rhs; *rp >= 0; rp++)
- {
- state = transitions_to (state->transitions,
- item_number_as_symbol_number (*rp));
- states1[length++] = state->number;
- }
-
- if (!state->consistent)
- add_lookback_edge (state, *rulep, i);
-
- length--;
- done = 0;
- while (!done)
- {
- done = 1;
- rp--;
- /* JF added rp>=ritem && I hope to god its right! */
- if (rp >= ritem && ISVAR (*rp))
- {
- /* Downcasting from item_number_t to symbol_number_t. */
- edge[nedges++] = map_goto (states1[--length],
- item_number_as_symbol_number (*rp));
- if (nullable[*rp])
- done = 0;
- }
- }
- }
-
- if (nedges)
- {
- int j;
- includes[i] = XCALLOC (goto_number_t, nedges + 1);
- for (j = 0; j < nedges; j++)
- includes[i][j] = edge[j];
- includes[i][nedges] = -1;
- }
+ symbol_number symbol1 = states[to_state[i]]->accessing_symbol;
+ rule **rulep;
+
+ for (rulep = derives[symbol1 - ntokens]; *rulep; rulep++)
+ {
+ bool done;
+ int length = 1;
+ item_number const *rp;
+ state *s = states[from_state[i]];
+ states1[0] = s->number;
+
+ for (rp = (*rulep)->rhs; ! item_number_is_rule_number (*rp); rp++)
+ {
+ s = transitions_to (s->transitions,
+ item_number_as_symbol_number (*rp));
+ states1[length++] = s->number;
+ }
+
+ if (!s->consistent)
+ add_lookback_edge (s, *rulep, i);
+
+ length--;
+ done = false;
+ while (!done)
+ {
+ done = true;
+ /* Each rhs ends in a rule number, and there is a
+ sentinel (ritem[-1]=0) before the first rhs, so it is safe to
+ decrement RP here. */
+ rp--;
+ if (ISVAR (*rp))
+ {
+ /* Downcasting from item_number to symbol_number. */
+ edge[nedges++] = map_goto (states1[--length],
+ item_number_as_symbol_number (*rp));
+ if (nullable[*rp - ntokens])
+ done = false;
+ }
+ }
+ }
+
+ if (nedges == 0)
+ includes[i] = NULL;
+ else
+ {
+ int j;
+ includes[i] = xnmalloc (nedges + 1, sizeof includes[i][0]);
+ for (j = 0; j < nedges; j++)
+ includes[i][j] = edge[j];
+ includes[i][nedges] = END_NODE;
+ }