Mercurial > hg > Applications > Grep
view c/regexParser/node.cc @ 145:50217a0545e8 pairPro
fix charClass()
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 14 Dec 2015 19:39:16 +0900 |
parents | d8a4922eceae |
children | 84d32375383a |
line wrap: on
line source
#include <stdio.h> #include "node.h" static void printCharacterClass(CharClassPtr cc, long nodeNumber,int d) { if (cc->type == 'r') { printf("%*c",d*4, ' '); for (RangeList range = cc->cond.range; range.begin != 0;) { printf("[%c-%c] ",(unsigned char)range.begin,(unsigned char)range.end); if (range.next != NULL) { range = *range.next; } else { break; } } printf("(%lu)\n",nodeNumber); } } 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,n->nodeNumber,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("-----------------"); }