bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

17-fyi-escape-tags.patch


From: Akim Demaille
Subject: 17-fyi-escape-tags.patch
Date: Sun, 07 Apr 2002 17:24:11 +0200

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        
        * src/lalr.c, src/LR0.c, src/closure.c, src/gram.c, src/reduce.c:
        Properly escape the symbols' TAG when outputting them.
        
Index: src/LR0.c
--- src/LR0.c Wed, 03 Apr 2002 22:07:02 +0200 akim
+++ src/LR0.c Sat, 06 Apr 2002 00:02:19 +0200 akim
@@ -24,6 +24,7 @@
 
 #include "system.h"
 #include "bitset.h"
+#include "quotearg.h"
 #include "symtab.h"
 #include "getargs.h"
 #include "reader.h"
@@ -190,7 +191,8 @@
 
   if (trace_flag)
     fprintf (stderr, "Entering new_state, state = %d, symbol = %d (%s)\n",
-            nstates, symbol, symbols[symbol]->tag);
+            nstates, symbol, quotearg_style (escape_quoting_style,
+                                             symbols[symbol]->tag));
 
   if (nstates >= MAXSHORT)
     fatal (_("too many states (max %d)"), MAXSHORT);
@@ -234,7 +236,8 @@
 
   if (trace_flag)
     fprintf (stderr, "Entering get_state, state = %d, symbol = %d (%s)\n",
-            this_state->number, symbol, symbols[symbol]->tag);
+            this_state->number, symbol, quotearg_style (escape_quoting_style,
+                                             symbols[symbol]->tag));
 
   /* Add up the target state's active item numbers to get a hash key.
      */
@@ -416,7 +419,8 @@
       if (trace_flag)
        fprintf (stderr, "Processing state %d (reached by %s)\n",
                 this_state->number,
-                symbols[this_state->accessing_symbol]->tag);
+                quotearg_style (escape_quoting_style,
+                                symbols[this_state->accessing_symbol]->tag));
       /* Set up ruleset and itemset for the transitions out of this
          state.  ruleset gets a 1 bit for each rule that could reduce
          now.  itemset gets a vector of all the items that could be
Index: src/closure.c
--- src/closure.c Wed, 03 Apr 2002 22:07:02 +0200 akim
+++ src/closure.c Sat, 06 Apr 2002 00:06:44 +0200 akim
@@ -19,6 +19,7 @@
    02111-1307, USA.  */
 
 #include "system.h"
+#include "quotearg.h"
 #include "bitset.h"
 #include "bitsetv.h"
 #include "getargs.h"
@@ -57,7 +58,8 @@
       short *rp;
       fprintf (stderr, "  %2d: .", array[i]);
       for (rp = &ritem[array[i]]; *rp >= 0; ++rp)
-       fprintf (stderr, " %s", symbols[*rp]->tag);
+       fprintf (stderr, " %s",
+                quotearg_style (escape_quoting_style, symbols[*rp]->tag));
       fprintf (stderr, "  (rule %d)\n", -*rp - 1);
     }
   fputs ("\n\n", stderr);
@@ -72,11 +74,14 @@
   fprintf (stderr, "FIRSTS\n");
   for (i = ntokens; i < nsyms; i++)
     {
-      fprintf (stderr, "\t%s firsts\n", symbols[i]->tag);
+      fprintf (stderr, "\t%s firsts\n",
+              quotearg_style (escape_quoting_style, symbols[i]->tag));
       for (j = 0; j < nvars; j++)
        if (bitset_test (FIRSTS (i), j))
          fprintf (stderr, "\t\t%d (%s)\n",
-                  j + ntokens, symbols[j + ntokens]->tag);
+                  j + ntokens,
+                  quotearg_style (escape_quoting_style,
+                                  symbols[j + ntokens]->tag));
     }
   fprintf (stderr, "\n\n");
 }
@@ -90,14 +95,17 @@
   fprintf (stderr, "FDERIVES\n");
   for (i = ntokens; i < nsyms; i++)
     {
-      fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
+      fprintf (stderr, "\t%s derives\n",
+              quotearg_style (escape_quoting_style, symbols[i]->tag));
       for (j = 0; j < nrules + 1; j++)
        if (bitset_test (FDERIVES (i), j))
          {
            short *rhsp;
            fprintf (stderr, "\t\t%d:", j - 1);
            for (rhsp = rules[j].rhs; *rhsp >= 0; ++rhsp)
-             fprintf (stderr, " %s", symbols[*rhsp]->tag);
+             fprintf (stderr, " %s",
+                      quotearg_style (escape_quoting_style,
+                                      symbols[*rhsp]->tag));
            fputc ('\n', stderr);
          }
     }
Index: src/closure.h
--- src/closure.h Mon, 03 Dec 2001 21:27:23 +0100 akim
+++ src/closure.h Sat, 06 Apr 2002 00:01:50 +0200 akim
@@ -1,5 +1,5 @@
 /* Subroutines for bison
-   Copyright 1984, 1989, 2000, 2001  Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989, 2000, 2001, 2002  Free Software Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
 
@@ -21,8 +21,6 @@
 #ifndef CLOSURE_H_
 # define CLOSURE_H_
 
-/* Subroutines of file LR0.c. */
-
 /* Allocates the itemset and ruleset vectors, and precomputes useful
    data so that closure can be called.  n is the number of elements to
    allocate for itemset.  */
@@ -31,23 +29,23 @@
 
 
 /* Given the kernel (aka core) of a state (a vector of item numbers
-   ITEMS, of length N), set up ruleset and itemset to indicate what
+   ITEMS, of length N), set up RULESET and ITEMSET to indicate what
    rules could be run and which items could be accepted when those
    items are the active ones.
 
-   ruleset contains a bit for each rule.  closure sets the bits for
+   RULESET contains a bit for each rule.  CLOSURE sets the bits for
    all rules which could potentially describe the next input to be
    read.
 
    ITEMSET is a vector of item numbers; NITEMSET is its size
-   9actually, points to just beyond the end of the part of it that is
-   significant).  closure places there the indices of all items which
+   (actually, points to just beyond the end of the part of it that is
+   significant).  CLOSURE places there the indices of all items which
    represent units of input that could arrive next.  */
 
 void closure PARAMS ((short *items, int n));
 
 
-/* Frees itemset, ruleset and internal data.  */
+/* Frees ITEMSET, RULESET and internal data.  */
 
 void free_closure PARAMS ((void));
 
Index: src/gram.c
--- src/gram.c Mon, 25 Mar 2002 20:34:56 +0100 akim
+++ src/gram.c Fri, 05 Apr 2002 23:59:09 +0200 akim
@@ -1,5 +1,5 @@
 /* Allocate input grammar variables for bison,
-   Copyright 1984, 1986, 1989, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1986, 1989, 2001, 2002 Free Software Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
 
@@ -20,6 +20,7 @@
 
 
 #include "system.h"
+#include "quotearg.h"
 #include "gram.h"
 #include "symtab.h"
 #include "reader.h"
@@ -77,7 +78,8 @@
   fputs ("RITEM\n", out);
   for (i = 0; i < nritems; ++i)
     if (ritem[i] >= 0)
-      fprintf (out, "  %s", symbols[ritem[i]]->tag);
+      fprintf (out, "  %s", quotearg_style (escape_quoting_style,
+                                           symbols[ritem[i]]->tag));
     else
       fprintf (out, "  (rule %d)\n", -ritem[i] - 1);
   fputs ("\n\n", out);
Index: src/lalr.c
--- src/lalr.c Thu, 04 Apr 2002 19:44:17 +0200 akim
+++ src/lalr.c Sat, 06 Apr 2002 00:17:46 +0200 akim
@@ -27,6 +27,7 @@
 #include "system.h"
 #include "bitset.h"
 #include "bitsetv.h"
+#include "quotearg.h"
 #include "reader.h"
 #include "types.h"
 #include "LR0.h"
@@ -559,9 +560,9 @@
 
       for (j = 0; j < states[i]->nlookaheads; ++j)
        for (k = 0; k < ntokens; ++k)
-         if (bitset_test (LA[states[i]->lookaheadsp + j], j))
+         if (bitset_test (LA[states[i]->lookaheadsp + j], k))
            fprintf (out, "   on %d (%s) -> rule %d\n",
-                    k, symbols[k]->tag,
+                    k, quotearg_style (escape_quoting_style, symbols[k]->tag),
                     LArule[states[i]->lookaheadsp + j]->number - 1);
     }
   fprintf (out, "Lookaheads: END\n");
Index: src/reduce.c
--- src/reduce.c Thu, 04 Apr 2002 19:41:33 +0200 akim
+++ src/reduce.c Sat, 06 Apr 2002 00:04:43 +0200 akim
@@ -1,5 +1,5 @@
 /* Grammar reduction for Bison.
-   Copyright 1988, 1989, 2000, 2001  Free Software Foundation, Inc.
+   Copyright (C) 1988, 1989, 2000, 2001, 2002  Free Software Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
 
@@ -26,6 +26,7 @@
    user's parser.  */
 
 #include "system.h"
+#include "quotearg.h"
 #include "getargs.h"
 #include "files.h"
 #include "symtab.h"
@@ -343,7 +344,8 @@
       int i;
       fprintf (out, "%s\n\n", _("Useless nonterminals:"));
       for (i = 0; i < nuseless_nonterminals; ++i)
-       fprintf (out, "   %s\n", symbols[nsyms + i]->tag);
+       fprintf (out, "   %s\n", quotearg_style (escape_quoting_style,
+                                                symbols[nsyms + i]->tag));
       fputs ("\n\n", out);
     }
 
@@ -356,7 +358,8 @@
          if (!b)
            fprintf (out, "%s\n\n", _("Terminals which are not used:"));
          b = TRUE;
-         fprintf (out, "   %s\n", symbols[i]->tag);
+         fprintf (out, "   %s\n", quotearg_style (escape_quoting_style,
+                                                  symbols[i]->tag));
        }
     if (b)
       fputs ("\n\n", out);
@@ -370,9 +373,11 @@
        {
          rule r;
          fprintf (out, "#%-4d  ", rules[i].user_number - 1);
-         fprintf (out, "%s:", rules[i].lhs->tag);
+         fprintf (out, "%s:", quotearg_style (escape_quoting_style,
+                                              rules[i].lhs->tag));
          for (r = rules[i].rhs; *r >= 0; r++)
-           fprintf (out, " %s", symbols[*r]->tag);
+           fprintf (out, " %s", quotearg_style (escape_quoting_style,
+                                                symbols[*r]->tag));
          fputs (";\n", out);
        }
       fputs ("\n\n", out);
@@ -394,7 +399,8 @@
   for (i = ntokens; i < nsyms; i++)
     fprintf (out, "%5d  %5d   %5d  %s\n",
             i,
-            symbols[i]->prec, symbols[i]->assoc, symbols[i]->tag);
+            symbols[i]->prec, symbols[i]->assoc,
+            quotearg_style (escape_quoting_style, symbols[i]->tag));
   fprintf (out, "\n\n");
   fprintf (out, "Rules\n-----\n\n");
   fprintf (out, "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem 
range) [Num]\n");
@@ -418,9 +424,11 @@
   fprintf (out, "Rules interpreted\n-----------------\n\n");
   for (i = 1; i < nrules + nuseless_productions + 1; i++)
     {
-      fprintf (out, "%-5d  %s :", i, rules[i].lhs->tag);
+      fprintf (out, "%-5d  %s :",
+              i, quotearg_style (escape_quoting_style, rules[i].lhs->tag));
       for (r = rules[i].rhs; *r >= 0; r++)
-       fprintf (out, " %s", symbols[*r]->tag);
+       fprintf (out, " %s",
+                quotearg_style (escape_quoting_style, symbols[*r]->tag));
       fputc ('\n', out);
     }
   fprintf (out, "\n\n");
@@ -484,7 +492,7 @@
 
   if (!bitset_test (N, start_symbol - ntokens))
     fatal (_("Start symbol %s does not derive any sentence"),
-          symbols[start_symbol]->tag);
+          quotearg_style (escape_quoting_style, symbols[start_symbol]->tag));
 
   /* First reduce the nonterminals, as they renumber themselves in the
      whole grammar.  If you change the order, nonterms would be



reply via email to

[Prev in Thread] Current Thread [Next in Thread]