New debug utility, data1_pr_tree, that dumps a data1 tree.
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 27 Oct 1997 14:04:07 +0000 (14:04 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 27 Oct 1997 14:04:07 +0000 (14:04 +0000)
retrieval/Makefile
retrieval/d1_prtree.c [new file with mode: 0644]

index 8fb3da3..c2d7949 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.9 1997-09-17 12:10:34 adam Exp $
+# $Id: Makefile,v 1.10 1997-10-27 14:04:07 adam Exp $
 
 SHELL=/bin/sh
 RANLIB=ranlib
@@ -8,7 +8,7 @@ LIB=../lib/libret.a
 PO = d1_handle.o d1_read.o d1_attset.o d1_tagset.o d1_absyn.o d1_grs.o \
        d1_sutrs.o d1_varset.o d1_espec.o \
        d1_doespec.o d1_map.o d1_marc.o d1_write.o d1_expout.o d1_sumout.o \
-       d1_soif.o
+       d1_soif.o d1_prtree.o
 CPP=$(CC) -E
 
 all: $(LIB)
diff --git a/retrieval/d1_prtree.c b/retrieval/d1_prtree.c
new file mode 100644 (file)
index 0000000..1607a2e
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 1995-1997, Index Data.
+ * See the file LICENSE for details.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: d1_prtree.c,v $
+ * Revision 1.1  1997-10-27 14:04:07  adam
+ * New debug utility, data1_pr_tree, that dumps a data1 tree.
+ *
+ */
+
+#include <log.h>
+#include <data1.h>
+
+static void pr_tree (data1_handle dh, data1_node *n, FILE *out, int level)
+{
+     fprintf (out, "%*s", level, "");
+     switch (n->which)
+     {
+     case DATA1N_root:
+         fprintf (out, "root abstract syntax=%s\n", n->u.root.type);
+         break;
+     case DATA1N_tag:
+         fprintf (out, "tag type=%s\n", n->u.tag.tag);
+         break;
+     case DATA1N_data:
+         fprintf (out, "data type=");
+         switch (n->u.data.what)
+         {
+         case DATA1I_inctxt:
+             fprintf (out, "inctxt\n");
+             break;
+         case DATA1I_incbin:
+             fprintf (out, "incbin\n");
+             break;
+         case DATA1I_text:
+             fprintf (out, "text '%.*s'\n", n->u.data.len, n->u.data.data);
+             break;
+         case DATA1I_num:
+             fprintf (out, "num\n");
+             break;
+         case DATA1I_oid:
+             fprintf (out, "oid\n");
+             break;
+         default:
+             fprintf (out, "unknown(%d)\n", n->u.data.what);
+             break;
+         }
+         break;
+     case DATA1N_variant:
+         fprintf (out, "variant\n");
+         break;
+     default:
+         fprintf (out, "unknown(%d)\n", n->which);
+     }
+     if (n->child)
+         pr_tree (dh, n->child, out, level+4);
+     if (n->next)
+         pr_tree (dh, n->next, out, level);
+}
+
+
+void data1_pr_tree (data1_handle dh, data1_node *n, FILE *out)
+{
+     pr_tree (dh, n, out, 0);
+}