view c/regexParser/node.cc @ 118:31b0ba0050fa testcode

text
author Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
date Thu, 26 Nov 2015 17:19:00 +0900
parents 166136236891
children 5d29b6a1b50f
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%s(%lu)\n",d*4, ' ',n->cc->cond->w->word,n->nodeNumber);
    } else {
        printf("%*c%s\n",d*4, ' ',n->cc->cond->w->word);
    }

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

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