/* Allocate input grammar variables for Bison.
- Copyright (C) 1984, 1986, 1989, 2001-2003, 2005-2012 Free Software
+ Copyright (C) 1984, 1986, 1989, 2001-2003, 2005-2013 Free Software
Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
{
fprintf (out, " %3d ", r->number);
if (previous_lhs != r->lhs)
- {
- fprintf (out, "%s:", r->lhs->tag);
- }
+ fprintf (out, "%s:", r->lhs->tag);
else
- {
- int n;
- for (n = strlen (previous_lhs->tag); n > 0; --n)
- fputc (' ', out);
- fputc ('|', out);
- }
+ fprintf (out, "%*s|", (int) strlen (previous_lhs->tag), "");
}
void
void
rule_rhs_print (rule const *r, FILE *out)
{
- if (*r->rhs >= 0)
+ if (0 <= *r->rhs)
{
item_number *rp;
for (rp = r->rhs; *rp >= 0; rp++)
fprintf (out, " %s", symbols[*rp]->tag);
}
else
- {
- fprintf (out, " /* %s */", _("empty"));
- }
+ fputs (" %empty", out);
}
static void
}
}
-static void
-rule_print (rule const *r, FILE *out)
-{
- fprintf (out, "%s:", r->lhs->tag);
- rule_rhs_print (r, out);
-}
-
void
ritem_print (FILE *out)
{
rule_number r;
for (r = 0; r < nrules + nuseless_productions; r++)
{
- fprintf (out, "%-5d ", r);
- rule_print (&rules[r], out);
+ fprintf (out, "%-5d %s:", r, rules[r].lhs->tag);
+ rule_rhs_print (&rules[r], out);
fprintf (out, "\n");
}
}
void
grammar_rules_useless_report (const char *message)
{
- warnings w = Wother;
- if (warnings_flag & w)
- {
- rule_number r;
- for (r = 0; r < nrules ; ++r)
- if (!rules[r].useful)
- {
- if (feature_flag & feature_caret)
- complain (&rules[r].location, w, "%s", message);
- else
- {
- complain (&rules[r].location, w | silent, "%s: ", message);
- rule_print (&rules[r], stderr);
- warnings_print_categories (w);
- fprintf (stderr, "\n");
- }
- }
- }
+ rule_number r;
+ for (r = 0; r < nrules ; ++r)
+ if (!rules[r].useful)
+ complain (&rules[r].location, Wother, "%s", message);
}
void