view c/regexParser/printTree.cc @ 79:52da06c3f050

add printTree.cc & fix Makefile
author Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
date Tue, 29 Sep 2015 18:36:31 +0900
parents
children 50a146c05192
line wrap: on
line source

#include <stdio.h>
#include "regexParser.h"

void descendTree(NodePtr n) {
    static int d = 0;
    if (n->right != NULL) {
        d++;
        descendTree(n->right);
        d--;
    }
    printf("%*c%c\n",d*4, ' ',n->Value.character);
    if (n->left != NULL) {
        d++;
        descendTree(n->left);
        d--;
    }
}

void printTree(NodePtr n) {
    puts("---Print Node----");
    descendTree(n);
    puts("-----------------");
}