Mercurial > hg > Applications > Grep
diff 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 diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c/regexParser/node.cc Fri Nov 20 21:02:00 2015 +0900 @@ -0,0 +1,28 @@ +#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("-----------------"); +}