+ /* Compute the width of the lookahead token column. */
+ if (default_rule)
+ width = strlen (_("$default"));
+
+ if (reds->lookahead_tokens)
+ for (i = 0; i < ntokens; i++)
+ {
+ bool count = bitset_test (no_reduce_set, i);
+
+ for (j = 0; j < reds->num; ++j)
+ if (bitset_test (reds->lookahead_tokens[j], i))
+ {
+ if (! count)
+ {
+ if (reds->rules[j] != default_rule)
+ max_length (&width, symbols[i]->tag);
+ count = true;
+ }
+ else
+ {
+ max_length (&width, symbols[i]->tag);
+ }
+ }
+ }
+
+ /* Nothing to report. */
+ if (!width)
+ return;
+
+ fputc ('\n', out);
+ width += 2;
+
+ /* Report lookahead tokens (or $default) and reductions. */
+ if (reds->lookahead_tokens)
+ for (i = 0; i < ntokens; i++)
+ {
+ bool defaulted = false;
+ bool count = bitset_test (no_reduce_set, i);
+
+ for (j = 0; j < reds->num; ++j)
+ if (bitset_test (reds->lookahead_tokens[j], i))
+ {
+ if (! count)
+ {
+ if (reds->rules[j] != default_rule)
+ print_reduction (out, width,
+ symbols[i]->tag,
+ reds->rules[j], true);
+ else
+ defaulted = true;
+ count = true;
+ }
+ else
+ {
+ if (defaulted)
+ print_reduction (out, width,
+ symbols[i]->tag,
+ default_rule, true);
+ defaulted = false;
+ print_reduction (out, width,
+ symbols[i]->tag,
+ reds->rules[j], false);
+ }
+ }
+ }
+
+ if (default_rule)
+ print_reduction (out, width,
+ _("$default"), default_rule, true);