Mercurial > hg > Applications > Grep
view regexParser/test/ccMerge.cc @ 206:e5302c2f6e00
implement printCCTree
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 27 Dec 2015 16:00:19 +0900 |
parents | b7b8f0c03fe3 |
children | 2ec95755238e |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "regexParser.h" #include "node.h" #include "subsetConstraction.h" void printCCTree(CharClassPtr cc) { if (cc->left != NULL) { printCCTree(cc->left); } printf("range : [%c-%c] NextState : %lu\n",(unsigned char)cc->cond.range.begin,(unsigned char)cc->cond.range.end, cc->nextState.bitContainer); if (cc->right != NULL) { printCCTree(cc->right); } } int main(int argc, char **argv) { RegexInfo ri; unsigned char* merge = NULL; for (int i = 1; i < argc; i++) { if (strcmp(argv[i],"-regex") == 0) { ri.ptr = (unsigned char*)argv[i+1]; i++; } else if (strcmp(argv[i],"-merge") == 0) { merge = (unsigned char*)argv[i+1]; i++; } } printf("regex : %s\n",ri.ptr); printf("merge : %s\n",merge); unsigned char begin, end; if (merge[0] == '[') merge++; begin = *merge; end = *merge; for (; *merge && *merge != ']'; merge++) { if (*merge == '-') { end = *(merge + 1); merge++; continue; } if (merge[0] == 0 || merge[0] == ']') break; begin = *merge; end = *merge; } NodePtr n = regex(&ri); TransitionGeneratorPtr tg = generateTransitionList(n); BitVector nextState; nextState.bitContainer = 8; CharClassPtr cc = charClassMerge(n->cc,begin,end,nextState); printCCTree(cc); return 0; }