bison-patches
[Top][All Lists]
Advanced

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

29-fyi-print-closure.patch


From: Akim Demaille
Subject: 29-fyi-print-closure.patch
Date: Wed, 05 Dec 2001 08:26:27 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * src/closure.c (print_closure): Improve.
        (closure): Use it for printing input and output.
        
        
Index: src/LR0.c
--- src/LR0.c Sat, 01 Dec 2001 20:18:59 +0100 akim
+++ src/LR0.c Mon, 03 Dec 2001 20:32:28 +0100 akim
@@ -583,6 +583,9 @@
 
   while (this_state)
     {
+      if (trace_flag)
+       fprintf (stderr, "Processing state %d (reached by %s)\n",
+                this_state->number, tags[this_state->accessing_symbol]);
       /* 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 Mon, 03 Dec 2001 20:21:33 +0100 akim
+++ src/closure.c Mon, 03 Dec 2001 20:45:38 +0100 akim
@@ -52,13 +52,19 @@
 `-----------------*/
 
 static void
-print_closure (int n)
+print_closure (const char *title, short *array, size_t size)
 {
-  int i;
-  fprintf (stderr, "n = %d\n", n);
-  for (i = 0; i < itemsetsize; ++i)
-    fprintf (stderr, "   %d\n", itemset[i]);
-  fprintf (stderr, "\n\n");
+  size_t i;
+  fprintf (stderr, "Closure: %s\n", title);
+  for (i = 0; i < size; ++i)
+    {
+      short *rp;
+      fprintf (stderr, "  %2d: .", array[i]);
+      for (rp = &ritem[array[i]]; *rp > 0; ++rp)
+       fprintf (stderr, " %s", tags[*rp]);
+      fprintf (stderr, "  (rule %d)\n", -*rp);
+    }
+  fputs ("\n\n", stderr);
 }
 
 
@@ -194,12 +200,7 @@
   int ruleno;
 
   if (trace_flag)
-    {
-      fprintf (stderr, "Entering closure (items = {");
-      for (c = 0; c < n; ++c)
-       fprintf (stderr, " %d ", core[c]);
-      fprintf (stderr, "})\n");
-    }
+    print_closure ("input", core, n);
 
   if (n == 0)
     {
@@ -241,7 +242,7 @@
     }
 
   if (trace_flag)
-    print_closure (n);
+    print_closure ("output", itemset, itemsetsize);
 }
 
 



reply via email to

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