1 |
/* Grammar reduction for Bison. |
/* Grammar reduction for Bison. |
2 |
Copyright 1988, 1989, 2000, 2001 Free Software Foundation, Inc. |
Copyright (C) 1988, 1989, 2000, 2001, 2002 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of Bison, the GNU Compiler Compiler. |
This file is part of Bison, the GNU Compiler Compiler. |
5 |
|
|
26 |
user's parser. */ |
user's parser. */ |
27 |
|
|
28 |
#include "system.h" |
#include "system.h" |
29 |
|
#include "quotearg.h" |
30 |
#include "getargs.h" |
#include "getargs.h" |
31 |
#include "files.h" |
#include "files.h" |
32 |
#include "symtab.h" |
#include "symtab.h" |
344 |
int i; |
int i; |
345 |
fprintf (out, "%s\n\n", _("Useless nonterminals:")); |
fprintf (out, "%s\n\n", _("Useless nonterminals:")); |
346 |
for (i = 0; i < nuseless_nonterminals; ++i) |
for (i = 0; i < nuseless_nonterminals; ++i) |
347 |
fprintf (out, " %s\n", symbols[nsyms + i]->tag); |
fprintf (out, " %s\n", quotearg_style (escape_quoting_style, |
348 |
|
symbols[nsyms + i]->tag)); |
349 |
fputs ("\n\n", out); |
fputs ("\n\n", out); |
350 |
} |
} |
351 |
|
|
358 |
if (!b) |
if (!b) |
359 |
fprintf (out, "%s\n\n", _("Terminals which are not used:")); |
fprintf (out, "%s\n\n", _("Terminals which are not used:")); |
360 |
b = TRUE; |
b = TRUE; |
361 |
fprintf (out, " %s\n", symbols[i]->tag); |
fprintf (out, " %s\n", quotearg_style (escape_quoting_style, |
362 |
|
symbols[i]->tag)); |
363 |
} |
} |
364 |
if (b) |
if (b) |
365 |
fputs ("\n\n", out); |
fputs ("\n\n", out); |
373 |
{ |
{ |
374 |
rule r; |
rule r; |
375 |
fprintf (out, "#%-4d ", rules[i].user_number - 1); |
fprintf (out, "#%-4d ", rules[i].user_number - 1); |
376 |
fprintf (out, "%s:", rules[i].lhs->tag); |
fprintf (out, "%s:", quotearg_style (escape_quoting_style, |
377 |
|
rules[i].lhs->tag)); |
378 |
for (r = rules[i].rhs; *r >= 0; r++) |
for (r = rules[i].rhs; *r >= 0; r++) |
379 |
fprintf (out, " %s", symbols[*r]->tag); |
fprintf (out, " %s", quotearg_style (escape_quoting_style, |
380 |
|
symbols[*r]->tag)); |
381 |
fputs (";\n", out); |
fputs (";\n", out); |
382 |
} |
} |
383 |
fputs ("\n\n", out); |
fputs ("\n\n", out); |
399 |
for (i = ntokens; i < nsyms; i++) |
for (i = ntokens; i < nsyms; i++) |
400 |
fprintf (out, "%5d %5d %5d %s\n", |
fprintf (out, "%5d %5d %5d %s\n", |
401 |
i, |
i, |
402 |
symbols[i]->prec, symbols[i]->assoc, symbols[i]->tag); |
symbols[i]->prec, symbols[i]->assoc, |
403 |
|
quotearg_style (escape_quoting_style, symbols[i]->tag)); |
404 |
fprintf (out, "\n\n"); |
fprintf (out, "\n\n"); |
405 |
fprintf (out, "Rules\n-----\n\n"); |
fprintf (out, "Rules\n-----\n\n"); |
406 |
fprintf (out, "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem range) [Num]\n"); |
fprintf (out, "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem range) [Num]\n"); |
424 |
fprintf (out, "Rules interpreted\n-----------------\n\n"); |
fprintf (out, "Rules interpreted\n-----------------\n\n"); |
425 |
for (i = 1; i < nrules + nuseless_productions + 1; i++) |
for (i = 1; i < nrules + nuseless_productions + 1; i++) |
426 |
{ |
{ |
427 |
fprintf (out, "%-5d %s :", i, rules[i].lhs->tag); |
fprintf (out, "%-5d %s :", |
428 |
|
i, quotearg_style (escape_quoting_style, rules[i].lhs->tag)); |
429 |
for (r = rules[i].rhs; *r >= 0; r++) |
for (r = rules[i].rhs; *r >= 0; r++) |
430 |
fprintf (out, " %s", symbols[*r]->tag); |
fprintf (out, " %s", |
431 |
|
quotearg_style (escape_quoting_style, symbols[*r]->tag)); |
432 |
fputc ('\n', out); |
fputc ('\n', out); |
433 |
} |
} |
434 |
fprintf (out, "\n\n"); |
fprintf (out, "\n\n"); |
492 |
|
|
493 |
if (!bitset_test (N, start_symbol - ntokens)) |
if (!bitset_test (N, start_symbol - ntokens)) |
494 |
fatal (_("Start symbol %s does not derive any sentence"), |
fatal (_("Start symbol %s does not derive any sentence"), |
495 |
symbols[start_symbol]->tag); |
quotearg_style (escape_quoting_style, symbols[start_symbol]->tag)); |
496 |
|
|
497 |
if (nuseless_productions > 0) |
if (nuseless_productions > 0) |
498 |
reduce_grammar_tables (); |
reduce_grammar_tables (); |