view c/regexParser/node.cc @ 134:dbafc753078e pairPro

fix concatination & selection & grouping
author masa
date Fri, 04 Dec 2015 17:45:09 +0900
parents a436526756b9
children e1a262ec75f0
line wrap: on
line source

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

static void descendTree(NodePtr n, int d) {
    if (n->left != NULL) {
        d++;
        descendTree(n->left, d);
        d--;
    }
    if (n->tokenType != 'a') {
        printf("%*c%c(%lu)\n",d*4, ' ',n->tokenType,n->nodeNumber);
    } else {
        printf("%*c",d*4, ' ');
        for (int i = 0; i < n->cc->cond->w->length; i++) {
            putchar(n->cc->cond->w->word[i]);
        }
        printf("(%lu)\n",n->nodeNumber);
    }

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

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