Make recursive case completely regular, hurray.
authorBen Pfaff <blp@cs.stanford.edu>
Fri, 7 Nov 2014 06:58:29 +0000 (22:58 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Fri, 7 Nov 2014 06:58:29 +0000 (22:58 -0800)
dump.c

diff --git a/dump.c b/dump.c
index 34270b962ae0e09ab0cdfb2c83dfa9c4e2ac2d9e..8a2fbc4e5269e6c7a91279a3eb898d7c7964e066 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -205,6 +205,19 @@ dump_value_31(void)
 }
 
 static void dump_value(int level, bool match1);
+static void dump_substs(void (*dump)(int level), int level);
+static void dump_value__(int level, bool match1);
+
+static void
+dump_value__with_preskip(int level)
+{
+  match_byte(0);
+  match_byte(0);
+  match_byte(0);
+  match_byte(0);
+  dump_value__ (level, false);
+  putchar('\n');
+}
 
 static void
 dump_value__(int level, bool match1)
@@ -276,33 +289,7 @@ dump_value__(int level, bool match1)
         match_byte (1);
     }
   else
-    {
-      dump_value_31();
-      char *base = get_string();
-
-      int x = get_u32();
-      printf ("\"%s\" with %d variables:\n", base, x);
-      for (int i = 0; i < x; i++)
-        {
-          int y = get_u32();
-          if (!y)
-            y = 1;
-          else
-            match_u32_assert(0);
-          for (int j = 0; j <= level; j++)
-            printf ("    ");
-          printf("variable %d has %d values:\n", i, y);
-          for (int j = 0; j < y; j++)
-            {
-              match_byte(0);
-              match_byte(0);
-              match_byte(0);
-              match_byte(0);
-              dump_value__ (level+1, false);
-              putchar('\n');
-            }
-        }
-    }
+    dump_substs(dump_value__with_preskip, level + 1);
 }
 
 static void