]> git.cameronkatri.com Git - mandoc.git/blobdiff - tree.c
Complete eqn.7 parsing. Features all productions from the original 1975
[mandoc.git] / tree.c
diff --git a/tree.c b/tree.c
index a446fb14a4763612ffee076c7cd1907f2c08b696..09ebca30770e63195cba626a30ca963ed747e5dd 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -1,4 +1,4 @@
-/*     $Id: tree.c,v 1.38 2011/07/21 11:34:53 kristaps Exp $ */
+/*     $Id: tree.c,v 1.44 2011/07/21 23:30:39 kristaps Exp $ */
 /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -19,6 +19,7 @@
 #endif
 
 #include <assert.h>
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
@@ -270,16 +271,30 @@ print_box(const struct eqn_box *ep, int indent)
 
        switch (ep->type) {
        case (EQN_ROOT):
-               puts("eqn-root");
-               print_box(ep->child, indent + 1);
-               return;
+               printf("eqn-root(%d, %d, %d, %d)\n", 
+                       EQN_DEFSIZE == ep->size ? 0 : ep->size,
+                       ep->pos, ep->font, ep->mark);
+               print_box(ep->first, indent + 1);
+               break;
+       case (EQN_SUBEXPR):
+               printf("eqn-subxpr(%d, %d, %d, %d, %d, %d, \"%s\", \"%s\")\n", 
+                       EQN_DEFSIZE == ep->size ? 0 : ep->size,
+                       ep->pos, ep->font, ep->mark,
+                       ep->pile, ep->above,
+                       ep->left ? ep->left : "",
+                       ep->right ? ep->right : "");
+               print_box(ep->first, indent + 1);
+               break;
        case (EQN_TEXT):
-               printf("eqn-text: [%s]\n", ep->text);
-               print_box(ep->next, indent);
-               return;
+               printf("eqn-text(%d, %d, %d, %d): [%s]\n", 
+                       EQN_DEFSIZE == ep->size ? 0 : ep->size,
+                       ep->pos, ep->font, ep->mark, ep->text);
+               break;
        default:
                break;
        }
+
+       print_box(ep->next, indent);
 }
 
 static void