+
+/*----------------------------------------------------.
+| Report on OUT the reduction actions of this STATE. |
+`----------------------------------------------------*/
+
+static void
+print_reductions (FILE *out, state_t *state)
+{
+ transitions_t *transitions = state->transitions;
+ reductions_t *redp = state->reductions;
+ rule_t *default_rule = NULL;
+ size_t width = 0;
+ int i, j;
+
+ if (redp->num == 0)
+ return;
+
+ default_rule = state_default_rule (state);
+
+ bitset_zero (shiftset);
+ FOR_EACH_SHIFT (transitions, i)
+ bitset_set (shiftset, TRANSITION_SYMBOL (transitions, i));
+
+ /* Compute the width of the lookaheads column. */
+ if (default_rule)
+ width = strlen (_("$default"));
+
+ if (redp->lookaheads)
+ for (i = 0; i < ntokens; i++)
+ {
+ int count = bitset_test (shiftset, i);
+
+ for (j = 0; j < redp->num; ++j)
+ if (bitset_test (redp->lookaheads[j], i))
+ {
+ if (count == 0)
+ {
+ if (redp->rules[j] != default_rule)
+ max_length (&width, symbols[i]->tag);
+ count++;
+ }
+ else
+ {
+ max_length (&width, symbols[i]->tag);
+ }
+ }
+ }
+
+ /* Nothing to report. */
+ if (!width)
+ return;
+
+ fputc ('\n', out);
+ width += 2;
+
+ /* Report lookaheads (or $default) and reductions. */
+ if (redp->lookaheads)
+ for (i = 0; i < ntokens; i++)
+ {
+ int defaulted = 0;
+ int count = bitset_test (shiftset, i);
+
+ for (j = 0; j < redp->num; ++j)
+ if (bitset_test (redp->lookaheads[j], i))
+ {
+ if (count == 0)
+ {
+ if (redp->rules[j] != default_rule)
+ print_reduction (out, width,
+ symbols[i]->tag,
+ redp->rules[j], TRUE);
+ else
+ defaulted = 1;
+ count++;
+ }
+ else
+ {
+ if (defaulted)
+ print_reduction (out, width,
+ symbols[i]->tag,
+ default_rule, TRUE);
+ defaulted = 0;
+ print_reduction (out, width,
+ symbols[i]->tag,
+ redp->rules[j], FALSE);
+ }
+ }
+ }
+
+ if (default_rule)
+ print_reduction (out, width,
+ _("$default"), default_rule, TRUE);
+}
+
+
+/*--------------------------------------------------------------.
+| Report on OUT all the actions (shifts, gotos, reductions, and |
+| explicit erros from %nonassoc) of STATE. |
+`--------------------------------------------------------------*/
+