+print_reductions (FILE *out, state *s)
+{
+ transitions *trans = s->transitions;
+ reductions *reds = s->reductions;
+ rule *default_rule = NULL;
+ size_t width = 0;
+ int i, j;
+
+ if (reds->num == 0)
+ return;
+
+ default_rule = state_default_rule (s);
+
+ bitset_zero (shiftset);
+ FOR_EACH_SHIFT (trans, i)
+ bitset_set (shiftset, TRANSITION_SYMBOL (trans, i));
+
+ /* Compute the width of the lookaheads column. */
+ if (default_rule)
+ width = strlen (_("$default"));
+
+ if (reds->lookaheads)
+ for (i = 0; i < ntokens; i++)
+ {
+ int count = bitset_test (shiftset, i);
+
+ for (j = 0; j < reds->num; ++j)
+ if (bitset_test (reds->lookaheads[j], i))
+ {
+ if (count == 0)
+ {
+ if (reds->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 (reds->lookaheads)
+ for (i = 0; i < ntokens; i++)
+ {
+ int defaulted = 0;
+ int count = bitset_test (shiftset, i);
+
+ for (j = 0; j < reds->num; ++j)
+ if (bitset_test (reds->lookaheads[j], i))
+ {
+ if (count == 0)
+ {
+ if (reds->rules[j] != default_rule)
+ print_reduction (out, width,
+ symbols[i]->tag,
+ reds->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,
+ reds->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 S. |
+`--------------------------------------------------------------*/
+
+static void
+print_actions (FILE *out, state *s)
+{
+ /* Print shifts. */
+ print_transitions (s, out, true);
+ print_errs (out, s);
+ print_reductions (out, s);
+ /* Print gotos. */
+ print_transitions (s, out, false);
+}
+
+
+/*----------------------------------.
+| Report all the data on S on OUT. |
+`----------------------------------*/
+
+static void
+print_state (FILE *out, state *s)