Mercurial > hg > Applications > Grep
view regexParser/test/ccMerge.cc @ 205:b7b8f0c03fe3
add test/ccMerge.cc
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 27 Dec 2015 14:57:40 +0900 |
parents | |
children | e5302c2f6e00 |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "regexParser.h" #include "node.h" #include "subsetConstraction.h" 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); printTree(n); BitVector nextState; nextState.bitContainer = 8; CharClassPtr cc = charClassMerge(n->cc,begin,end,nextState); printf("type : %c range : [%c-%c] NextState : %lu\n",cc->type,(unsigned char)cc->cond.range.begin,(unsigned char)cc->cond.range.end, cc->nextState.bitContainer); return 0; }