Mercurial > hg > Applications > Grep
view c/regexParser/printTree.cc @ 89:50a146c05192
add NodeNumber in Regex Parser tree
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 23 Oct 2015 17:20:54 +0900 |
parents | 52da06c3f050 |
children | d139af3bbd67 |
line wrap: on
line source
#include <stdio.h> #include "regexParser.h" void descendTree(NodePtr n) { static int d = 0; if (n->right != NULL) { d++; descendTree(n->right); d--; } if (n->tokenType == 'a') { printf("%*c(%d)%c\n",d*4, ' ',n->nodeNumber,n->Value.character); } else { printf("%*c%c\n",d*4, ' ',n->Value.character); } if (n->left != NULL) { d++; descendTree(n->left); d--; } } void printTree(NodePtr n) { puts("---Print Node----"); descendTree(n); puts("-----------------"); }