]> git.saurik.com Git - bison.git/commitdiff
* src/gram.c, src/gram.h (ritem_print): New.
authorAkim Demaille <akim@epita.fr>
Wed, 5 Dec 2001 09:26:05 +0000 (09:26 +0000)
committerAkim Demaille <akim@epita.fr>
Wed, 5 Dec 2001 09:26:05 +0000 (09:26 +0000)
* src/gram.c (dummy): Remove, now there is actual code in gram.c.
(This useless function was defined only to work around VMS linkers
that can't handle compilation units with variables only).
* src/reduce.c (dump_grammar): Use it to trace the construction of
ritem.

ChangeLog
src/gram.c
src/gram.h
src/reader.c
src/reduce.c

index 5c0df688c8c3905ed80cb23e66257e96f0a4531a..1a82f4385061ed6c46a5e1c10760a926aec0c0ec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2001-12-05  Akim Demaille  <akim@epita.fr>
+
+       * src/gram.c, src/gram.h (ritem_print): New.
+       * src/gram.c (dummy): Remove, now there is actual code in gram.c.
+       (This useless function was defined only to work around VMS linkers
+       that can't handle compilation units with variables only).
+       * src/reduce.c (dump_grammar): Use it to trace the construction of
+       ritem.
+
 2001-12-04  Paul Eggert  <eggert@twinsun.com>
 
        * src/bison.simple (union yyalloc): Change member names
index 1df89a0276d3fa8a5a07d6fbd4e7522b4688bf96..35302616ace92a925b46d4bc0cd2c4c44409e31f 100644 (file)
@@ -21,6 +21,7 @@ Boston, MA 02111-1307, USA.  */
 
 #include "system.h"
 #include "gram.h"
+#include "reader.h"
 
 void dummy PARAMS((void));
 
@@ -52,10 +53,15 @@ int pure_parser;
 
 int error_token_number;
 
-/* This is to avoid linker problems which occur on VMS when using GCC,
-   when the file in question contains data definitions only.  */
-
 void
-dummy (void)
+ritem_print (FILE *out)
 {
+  int i;
+  fputs ("RITEM\n", out);
+  for (i = 0; ritem[i]; ++i)
+    if (ritem[i] > 0)
+      fprintf (out, "  %s", tags[ritem[i]]);
+    else
+      fprintf (out, "  (rule %d)\n", -ritem[i]);
+  fputs ("\n\n", out);
 }
index ca55d007b55ed79062969415f4b054469c0c673c..516907c225878e2daee5f008c786e5184bbf0cfb 100644 (file)
@@ -147,4 +147,8 @@ extern int pure_parser;
 /* ERROR_TOKEN_NUMBER is the token number of the error token.  */
 
 extern int error_token_number;
+
+
+/* Dump RITEM for traces. */
+void ritem_print (FILE *out);
 #endif /* !GRAM_H_ */
index 0cce616d937e495829fdd7cc0dbb5ce1ad069b6d..6bfc7d7304dba2ef15d579351254402eac64a99b 100644 (file)
@@ -2005,6 +2005,9 @@ packgram (void)
     }
 
   ritem[itemno] = 0;
+
+  if (trace_flag)
+    ritem_print (stderr);
 }
 \f
 /*-------------------------------------------------------------------.
index 190f357746a43f9165e380302ab82efb89ae395c..048f5a632236524fd78fd15f95c6b2b84bb77f04 100644 (file)
@@ -455,18 +455,22 @@ dump_grammar (FILE *out)
     fprintf (out, "%5d  %5d   %5d  %s\n", i, sprec[i], sassoc[i], tags[i]);
   fprintf (out, "\n\n");
   fprintf (out, "Rules\n-----\n\n");
-  fprintf (out, "Num (Prec, Assoc) Lhs : (@Rhs) Ritems [Num?]\n");
+  fprintf (out, "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem range) [Num]\n");
   for (i = 1; i <= nrules; i++)
     {
-      fprintf (out, "%-5d(%5d%5d)%5d : (@%-5d)",
+      int rhs_count = 0;
+      /* Find the last RHS index in ritems. */
+      for (r = &ritem[rule_table[i].rhs]; *r > 0; ++r)
+       ++rhs_count;
+      fprintf (out, "%3d (%2d, %2d, %2d, %2d-%2d)   %2d ->",
               i,
-              rule_table[i].prec,
-              rule_table[i].assoc,
-              rule_table[i].lhs,
-              rule_table[i].rhs);
+              rule_table[i].prec, rule_table[i].assoc, rule_table[i].useful,
+              rule_table[i].rhs, rule_table[i].rhs + rhs_count - 1,
+              rule_table[i].lhs);
+      /* Dumped the RHS. */
       for (r = &ritem[rule_table[i].rhs]; *r > 0; r++)
-       fprintf (out, "%5d", *r);
-      fprintf (out, " [%d]\n", -(*r));
+       fprintf (out, "%3d", *r);
+      fprintf (out, "  [%d]\n", -(*r));
     }
   fprintf (out, "\n\n");
   fprintf (out, "Rules interpreted\n-----------------\n\n");