view c/regexParser/node.cc @ 117:166136236891 pairPro

add header files
author Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
date Wed, 25 Nov 2015 14:58:03 +0900
parents 66c633575b53
children 31b0ba0050fa
line wrap: on
line source

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

static void descendTree(NodePtr n, int d) {
    if (n->right != NULL) {
        d++;
        descendTree(n->right, d);
        d--;
    }
    if (n->tokenType == 'a') {
        printf("%*c%c(%lu)\n",d*4, ' ',n->cc->cond->character,n->nodeNumber);
    } else {
        printf("%*c%c\n",d*4, ' ',n->cc->cond->character);
    }

    if (n->left != NULL) {
        d++;
        descendTree(n->left, d);
        d--;
    }
}

void printTree(NodePtr n) {
    puts("---Print Node----");
    int d = 0;
    descendTree(n,d);
    puts("-----------------");
}