/[bison]/bison/src/reduce.c
ViewVC logotype

Diff of /bison/src/reduce.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.52 by akim, Sun Apr 7 17:41:28 2002 UTC revision 1.53 by akim, Sun Apr 7 17:42:12 2002 UTC
# Line 1  Line 1 
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    
# Line 26  Line 26 
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"
# Line 343  reduce_output (FILE *out) Line 344  reduce_output (FILE *out)
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    
# Line 356  reduce_output (FILE *out) Line 358  reduce_output (FILE *out)
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);
# Line 370  reduce_output (FILE *out) Line 373  reduce_output (FILE *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);
# Line 394  dump_grammar (FILE *out) Line 399  dump_grammar (FILE *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");
# Line 418  dump_grammar (FILE *out) Line 424  dump_grammar (FILE *out)
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");
# Line 484  reduce_grammar (void) Line 492  reduce_grammar (void)
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 ();

Legend:
Removed from v.1.52  
changed lines
  Added in v.1.53

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26