Mercurial > hg > Applications > Grep
view regexParser/main.cc @ 263:292753bb31e4
fix Makefile
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 27 Jan 2016 16:37:42 +0900 |
parents | 157f6886ba55 |
children | e51cac73e42a |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include "regexParser.h" #include "subsetConstruction.h" #include "node.h" #include "grepWalk.h" #include "fileread.h" #include "threadedSearch.h" int main(int argc, char **argv) { bool generate = true; bool subset = false; bool generateSequentialSearch = false; bool ts = false; char *filename; RegexInfo ri; ri.stateNumber = 1; 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],"-noGeneration") == 0) { generate = false; } else if (strcmp(argv[i],"-subset") == 0) { subset = true; } else if (strcmp(argv[i],"-seq") == 0) { generateSequentialSearch = true; } else if (strcmp(argv[i],"-file") == 0) { filename = argv[i+1]; i++; } else if (strcmp(argv[i],"-ts") == 0) { ts = true; } } if (!ri.ptr) return 0; printf("regex : %s\n",ri.ptr); NodePtr n = regex(&ri); // parse only printTree(n); TGValue tgv; if (generate && !subset) { // NFA generation tgv = generateTransitionList(n); printTree(n); printState(tgv.tg); if (generateSequentialSearch) { exportState(tgv.tg); } } else if (subset) { tgv = generateTransitionList(n); subsetConstruction(tgv.tg); // Determinization printState(tgv.tg); if (generateSequentialSearch) { exportState(tgv.tg); } } if (filename != NULL) { int fd = 0; st_mmap_t st_mmap = createSt_mmap(filename,fd); Buffer buff = createBuffer(st_mmap); if (ts) threadedSearch(tgv.tg,buff); else grepWalk(tgv.tg,buff); close(fd); } return 0; }