+ /* Make a reductions structure and copy the data into it. */
+
+ if (count)
+ {
+ p = (reductions *) xmalloc ((unsigned) (sizeof (reductions) +
+ (count - 1) * sizeof (short)));
+
+ p->number = this_state->number;
+ p->nreds = count;
+
+ rp1 = redset;
+ rp2 = p->rules;
+ rend = rp1 + count;
+
+ for (/* nothing */; rp1 < rend; ++rp1, ++rp2)
+ *rp2 = *rp1;
+
+ if (last_reduction)
+ {
+ last_reduction->next = p;
+ last_reduction = p;
+ }
+ else
+ {
+ first_reduction = p;
+ last_reduction = p;
+ }
+ }
+}
+
+\f
+/*-------------------------------------------------------------------.
+| Compute the nondeterministic finite state machine (see state.h for |
+| details) from the grammar. |
+`-------------------------------------------------------------------*/
+
+void
+generate_states (void)
+{
+ allocate_storage ();
+ new_closure (nitems);
+ new_states ();
+
+ while (this_state)
+ {
+ /* Set up ruleset and itemset for the transitions out of this
+ state. ruleset gets a 1 bit for each rule that could reduce
+ now. itemset gets a vector of all the items that could be
+ accepted next. */
+ closure (this_state->items, this_state->nitems);
+ /* record the reductions allowed out of this state */
+ save_reductions ();
+ /* find the itemsets of the states that shifts can reach */
+ new_itemsets ();
+ /* find or create the core structures for those states */
+ append_states ();
+
+ /* create the shifts structures for the shifts to those states,
+ now that the state numbers transitioning to are known */
+ if (nshifts > 0)
+ save_shifts ();
+
+ /* states are queued when they are created; process them all */
+ this_state = this_state->next;
+ }
+
+ /* discard various storage */
+ free_closure ();
+ free_storage ();
+
+ /* set up initial and final states as parser wants them */
+ augment_automaton ();