-/* subroutine of augment_automaton.
- Create the next-to-final state, to which a shift has already been made in
- the initial state. */
+/*----------------------------------------------------------------.
+| Find which rules can be used for reduction transitions from the |
+| current state and make a reductions structure for the state to |
+| record their rule numbers. |
+`----------------------------------------------------------------*/
+
+static void
+save_reductions (void)
+{
+ short *isp;
+ short *rp1;
+ short *rp2;
+ int item;
+ int count;
+ reductions *p;
+
+ short *rend;
+
+ /* Find and count the active items that represent ends of rules. */
+
+ count = 0;
+ for (isp = itemset; isp < itemsetend; isp++)
+ {
+ item = ritem[*isp];
+ if (item < 0)
+ redset[count++] = -item;
+ }
+
+ /* 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. |
+`-------------------------------------------------------------------*/
+