Mercurial > hg > Applications > Grep
changeset 231:d67649929e96
add grepWalk
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 19 Jan 2016 12:54:11 +0900 |
parents | 2081b9d6a179 |
children | 1a34e702776a |
files | regexParser/grepWalk.cc regexParser/grepWalk.h regexParser/main.cc regexParser/sequentialSearch.cc regexParser/sequentialSearch.h |
diffstat | 5 files changed, 55 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/regexParser/grepWalk.cc Tue Jan 19 12:54:11 2016 +0900 @@ -0,0 +1,9 @@ +#include <stdio.h> + +#include "regexParser.h" +#include "sequentialSearch.h" +#include "grepWalk.h" + +void grepWalk(TransitionGeneratorPtr tg) { + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/regexParser/grepWalk.h Tue Jan 19 12:54:11 2016 +0900 @@ -0,0 +1,1 @@ +extern void grepWalk(TransitionGeneratorPtr tg);
--- a/regexParser/main.cc Mon Jan 18 16:41:17 2016 +0900 +++ b/regexParser/main.cc Tue Jan 19 12:54:11 2016 +0900 @@ -4,6 +4,7 @@ #include "regexParser.h" #include "subsetConstruction.h" #include "node.h" +#include "grepWalk.h" int main(int argc, char **argv) { @@ -30,15 +31,16 @@ NodePtr n = regex(&ri); // parse only printTree(n); + TGValue tgv; if (generate && !subset) { // NFA generation - TGValue tgv = generateTransitionList(n); + tgv = generateTransitionList(n); printTree(n); printState(tgv.tg); if (generateSequentialSearch) { exportState(tgv.tg); } } else if (subset) { - TGValue tgv = generateTransitionList(n); + tgv = generateTransitionList(n); SCValue scv = createSCValue(tgv); subsetConstruction(scv); // Determinization printState(tgv.tg); @@ -46,5 +48,7 @@ exportState(tgv.tg); } } + + grepWalk(tgv.tg); return 0; }
--- a/regexParser/sequentialSearch.cc Mon Jan 18 16:41:17 2016 +0900 +++ b/regexParser/sequentialSearch.cc Tue Jan 19 12:54:11 2016 +0900 @@ -4,19 +4,8 @@ #include <fcntl.h> #include <sys/stat.h> #include <sys/mman.h> -#include <sys/types.h> -typedef struct buffer { - unsigned char *buff; - unsigned char *buffptr; - unsigned char *buffend; - unsigned char *matchBegin; -} Buffer, *BufferPtr; - -typedef struct { - caddr_t file_mmap; - off_t size; -} st_mmap_t; +#include "sequentialSearch.h" void state1(Buffer buff); @@ -31,19 +20,10 @@ stateSkip(buff); } -#include "state.cc" -int main(int argc, char **argv) { - char *filename; - for (int i = 1; i < argc; i++) { - if (strcmp(argv[i],"-file") == 0) { - filename = argv[i+1]; i++; - } - } - +st_mmap_t createSt_mmap(char* filename,int fd) { + st_mmap_t st_mmap; int map = MAP_PRIVATE; - st_mmap_t st_mmap; struct stat sb; - int fd; if ((fd=open(filename,O_RDONLY,0666))==0) { perror(""); fprintf(stderr,"can't open %s\n",filename); @@ -59,10 +39,29 @@ perror(""); fprintf(stderr,"cannot mmap %s\n",filename); } + st_mmap.file_mmap = file_mmap; + return st_mmap; +} +Buffer createBuffer(st_mmap_t st_mmap) { Buffer buff; - buff.buff = buff.buffptr = buff.matchBegin = file_mmap; + buff.buff = buff.buffptr = buff.matchBegin = st_mmap.file_mmap; buff.buffend = buff.buff + st_mmap.size; + return buff; +} + +#include "state.cc" +int main(int argc, char **argv) { + char *filename; + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i],"-file") == 0) { + filename = argv[i+1]; i++; + } + } + + int fd; + st_mmap_t st_mmap = createSt_mmap(filename,fd); + Buffer buff = createBuffer(st_mmap); stateSkip(buff); close(fd); return 0;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/regexParser/sequentialSearch.h Tue Jan 19 12:54:11 2016 +0900 @@ -0,0 +1,16 @@ +#include <sys/types.h> + +typedef struct buffer { + unsigned char *buff; + unsigned char *buffptr; + unsigned char *buffend; + unsigned char *matchBegin; +} Buffer, *BufferPtr; + +typedef struct { + unsigned char* file_mmap; + off_t size; +} st_mmap_t; + +extern st_mmap_t createSt_mmap(char* filename, int fd); +extern Buffer createBuffer(st_mmap_t st_mmap);