Mercurial > hg > Applications > Grep
comparison 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 |
comparison
equal
deleted
inserted
replaced
109:6401c708f5dd | 110:a3adc5c24e19 |
---|---|
1 #include <stdio.h> | |
2 #include "regexParser.h" | |
3 | |
4 void descendTree(NodePtr n, int d) { | |
5 if (n->right != NULL) { | |
6 d++; | |
7 descendTree(n->right, d); | |
8 d--; | |
9 } | |
10 if (n->tokenType == 'a') { | |
11 printf("%*c%c(%d)\n",d*4, ' ',n->Value.character,n->nodeNumber); | |
12 } else { | |
13 printf("%*c%c\n",d*4, ' ',n->Value.character); | |
14 } | |
15 | |
16 if (n->left != NULL) { | |
17 d++; | |
18 descendTree(n->left, d); | |
19 d--; | |
20 } | |
21 } | |
22 | |
23 void printTree(NodePtr n) { | |
24 puts("---Print Node----"); | |
25 int d = 0; | |
26 descendTree(n,d); | |
27 puts("-----------------"); | |
28 } |