Mercurial > hg > Applications > Grep
diff c/regexParser/node.cc @ 147:84d32375383a pairPro
implement insertCharClass
author | masa |
---|---|
date | Tue, 15 Dec 2015 17:14:35 +0900 |
parents | 50217a0545e8 |
children |
line wrap: on
line diff
--- a/c/regexParser/node.cc Tue Dec 15 16:20:35 2015 +0900 +++ b/c/regexParser/node.cc Tue Dec 15 17:14:35 2015 +0900 @@ -3,6 +3,9 @@ static void printCharacterClass(CharClassPtr cc, long nodeNumber,int d) { if (cc->type == 'r') { + if (cc->left) { + printCharacterClass(cc->left,nodeNumber,d+1); + } printf("%*c",d*4, ' '); for (RangeList range = cc->cond.range; range.begin != 0;) { printf("[%c-%c] ",(unsigned char)range.begin,(unsigned char)range.end); @@ -13,14 +16,15 @@ } } printf("(%lu)\n",nodeNumber); + if (cc->right) { + printCharacterClass(cc->right,nodeNumber,d+1); + } } } static void descendTree(NodePtr n, int d) { if (n->left != NULL) { - d++; - descendTree(n->left, d); - d--; + descendTree(n->left, d+1); } if (n->tokenType == 'a') { printf("%*c",d*4, ' '); @@ -35,9 +39,7 @@ } if (n->right != NULL) { - d++; - descendTree(n->right, d); - d--; + descendTree(n->right, d+1); } }