Mercurial > hg > Applications > Grep
view regexParser/node.cc @ 216:4852bfa85db4
spell fix
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 30 Dec 2015 15:05:06 +0900 |
parents | a94f57af1600 |
children | a9e3512120e2 |
line wrap: on
line source
#include <stdio.h> #include "regexParser.h" #include "node.h" void printCharacterClass(CharClassPtr cc, long nodeNumber,int d) { if (!cc) return; if (cc->type == 'a' || 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); if (range.next != NULL) { range = *range.next; } else { break; } } printf("(%lx)\n",cc->nextState.bitContainer); if (cc->right) { printCharacterClass(cc->right,nodeNumber,d+1); } } } void descendTree(NodePtr n, int d) { if (n->left != NULL) { descendTree(n->left, d+1); } 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]); } if (n->state) { printf("(%ld)->(%ld)\n",n->state->bitState.bitContainer,n->nextState->bitState.bitContainer); } else { printf("\n"); } } else if (n->tokenType == 'c') { printCharacterClass(n->cc,n->stateNum,d); } else if (n->tokenType == 'a') { printf("%*c%c(%d)\n",d*4, ' ',n->tokenType,n->stateNum); } else { printf("%*c%c\n",d*4, ' ',n->tokenType); } if (n->right != NULL) { descendTree(n->right, d+1); } } void printTree(NodePtr n) { puts("---Print Node----"); int d = 0; descendTree(n,d); puts("-----------------"); }