X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/510c8497f81feb0b81ecd656b32c497643796734..026816664ff8283a55f91915843a8ff0ac5cf86c:/src/gram.c?ds=sidebyside diff --git a/src/gram.c b/src/gram.c index 20aefe19..f6cc3c5d 100644 --- a/src/gram.c +++ b/src/gram.c @@ -1,6 +1,6 @@ /* 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. @@ -69,16 +69,9 @@ rule_lhs_print (rule const *r, symbol const *previous_lhs, FILE *out) { 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 @@ -100,16 +93,14 @@ rule_rhs_length (rule const *r) 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 @@ -132,13 +123,6 @@ rule_rhs_print_xml (rule const *r, FILE *out, int level) } } -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) { @@ -296,8 +280,8 @@ grammar_dump (FILE *out, const char *title) 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"); } } @@ -307,24 +291,10 @@ grammar_dump (FILE *out, const char *title) 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