Mercurial > hg > Applications > Grep
view 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 source
#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",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) { d++; descendTree(n->right, d); d--; } } void printTree(NodePtr n) { puts("---Print Node----"); int d = 0; descendTree(n,d); puts("-----------------"); }