view c/regexParser/node.cc @ 110:a3adc5c24e19 pairPro

start branch
author masa
date Fri, 20 Nov 2015 21:02:00 +0900
parents c/regexParser/printTree.cc@912d7bd51f38
children ec485345daf9
line wrap: on
line source

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

void descendTree(NodePtr n, int d) {
    if (n->right != NULL) {
        d++;
        descendTree(n->right, d);
        d--;
    }
    if (n->tokenType == 'a') {
        printf("%*c%c(%d)\n",d*4, ' ',n->Value.character,n->nodeNumber);
    } else {
        printf("%*c%c\n",d*4, ' ',n->Value.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("-----------------");
}