* src/LR0.c (set_state_table): here.
* src/lalr.c (lalr): Call it.
+2001-12-10 Akim Demaille <akim@epita.fr>
+
+ * src/lalr.c (initialize_lookaheads): New. Extracted from...
+ * src/LR0.c (set_state_table): here.
+ * src/lalr.c (lalr): Call it.
+
2001-12-10 Akim Demaille <akim@epita.fr>
* src/state.h (shifts): Remove the `number' member: shifts are
if (!state_table[i]->shifts)
state_table[i]->shifts = shifts_new (0);
}
-
- /* Initializing the lookaheads members. Please note that it must be
- performed after having set some of the other members which are
- used below. Change with extreme caution. */
- {
- int i;
- int count = 0;
- for (i = 0; i < nstates; i++)
- {
- int k;
- reductions *rp = state_table[i]->reductions;
- shifts *sp = state_table[i]->shifts;
-
- state_table[i]->lookaheads = count;
-
- if (rp
- && (rp->nreds > 1 || (sp->nshifts && SHIFT_IS_SHIFT (sp, 0))))
- count += rp->nreds;
- else
- state_table[i]->consistent = 1;
-
- for (k = 0; k < sp->nshifts; k++)
- if (SHIFT_IS_ERROR (sp, k))
- {
- state_table[i]->consistent = 0;
- break;
- }
- }
-
- /* Seems to be needed by conflicts.c. */
- state_table[nstates] = STATE_ALLOC (0);
- state_table[nstates]->lookaheads = count;
- }
}
/*-------------------------------------------------------------------.
}
+/*--------------------------------------.
+| Initializing the lookaheads members. |
+`--------------------------------------*/
+
+static void
+initialize_lookaheads (void)
+{
+ int i;
+ int count = 0;
+ for (i = 0; i < nstates; i++)
+ {
+ int k;
+ reductions *rp = state_table[i]->reductions;
+ shifts *sp = state_table[i]->shifts;
+
+ state_table[i]->lookaheads = count;
+
+ if (rp
+ && (rp->nreds > 1 || (sp->nshifts && SHIFT_IS_SHIFT (sp, 0))))
+ count += rp->nreds;
+ else
+ state_table[i]->consistent = 1;
+
+ for (k = 0; k < sp->nshifts; k++)
+ if (SHIFT_IS_ERROR (sp, k))
+ {
+ state_table[i]->consistent = 0;
+ break;
+ }
+ }
+
+ /* Seems to be needed by conflicts.c. */
+ state_table[nstates] = STATE_ALLOC (0);
+ state_table[nstates]->lookaheads = count;
+}
+
void
lalr (void)
{
tokensetsize = WORDSIZE (ntokens);
+ initialize_lookaheads ();
initialize_LA ();
set_goto_map ();
initialize_F ();