Mercurial > hg > Applications > Grep
view regexParser/mergeTest.cc @ 176:c092dd0e1ae0 pairPro
implement appendState() and serchState()
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 23 Dec 2015 15:41:27 +0900 |
parents | 3bf2c6d6d53e |
children | 109d22faf7b5 |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "subsetConstraction.h" extern NodePtr regex(RegexInfoPtr); extern void printTree(NodePtr); int main(int argc, char **argv) { RegexInfoPtr ri = (RegexInfoPtr)malloc(sizeof(RegexInfo)); ri->nodeNumber = 1; 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); printTree(n); BitVector nextState; charClassMerge(n->cc,begin,end,nextState); return 0; }