Mercurial > hg > Members > masakoha > testcode
diff c/regexParser/node.cc @ 135:e1a262ec75f0 pairPro
impl charclass
author | masa |
---|---|
date | Fri, 04 Dec 2015 19:07:10 +0900 |
parents | dbafc753078e |
children | 6c258910cacb |
line wrap: on
line diff
--- a/c/regexParser/node.cc Fri Dec 04 17:45:09 2015 +0900 +++ b/c/regexParser/node.cc Fri Dec 04 19:07:10 2015 +0900 @@ -1,20 +1,32 @@ #include <stdio.h> #include "node.h" +static void printCharacterClass(CharClassPtr cc, int d) { + if (cc->type == 'r') { + printf("%*c",d*4, ' '); + for (RangeListPtr range = cc->cond->range; range; range = range->next) { + printf("%c-%c ",*range->begin,*range->end); + } + printf("\n"); + } +} + 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 { + if (n->tokenType == 'a') { 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); + } else if (n->tokenType == 'c') { + printCharacterClass(n->cc,d); + } else { + printf("%*c%c(%lu)\n",d*4, ' ',n->tokenType,n->nodeNumber); } if (n->right != NULL) {