Mercurial > hg > Applications > Grep
comparison regexParser/main.cc @ 232:1a34e702776a
add fileread.cc
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 19 Jan 2016 13:16:35 +0900 |
parents | d67649929e96 |
children | 4aab1e93a971 |
comparison
equal
deleted
inserted
replaced
231:d67649929e96 | 232:1a34e702776a |
---|---|
3 #include <string.h> | 3 #include <string.h> |
4 #include "regexParser.h" | 4 #include "regexParser.h" |
5 #include "subsetConstruction.h" | 5 #include "subsetConstruction.h" |
6 #include "node.h" | 6 #include "node.h" |
7 #include "grepWalk.h" | 7 #include "grepWalk.h" |
8 #include "fileread.h" | |
8 | 9 |
9 int main(int argc, char **argv) | 10 int main(int argc, char **argv) |
10 { | 11 { |
11 bool generate = true; | 12 bool generate = true; |
12 bool subset = false; | 13 bool subset = false; |
13 bool generateSequentialSearch = false; | 14 bool generateSequentialSearch = false; |
15 char *filename; | |
14 | 16 |
15 RegexInfo ri; | 17 RegexInfo ri; |
16 ri.stateNumber = 1; | 18 ri.stateNumber = 1; |
17 for (int i = 1; i < argc; i++) { | 19 for (int i = 1; i < argc; i++) { |
18 if (strcmp(argv[i],"-regex") == 0) { | 20 if (strcmp(argv[i],"-regex") == 0) { |
21 generate = false; | 23 generate = false; |
22 } else if (strcmp(argv[i],"-subset") == 0) { | 24 } else if (strcmp(argv[i],"-subset") == 0) { |
23 subset = true; | 25 subset = true; |
24 } else if (strcmp(argv[i],"-seq") == 0) { | 26 } else if (strcmp(argv[i],"-seq") == 0) { |
25 generateSequentialSearch = true; | 27 generateSequentialSearch = true; |
28 } else if (strcmp(argv[i],"-file") == 0) { | |
29 filename = argv[i+1]; i++; | |
26 } | 30 } |
27 } | 31 } |
28 if (!ri.ptr) return 0; | 32 if (!ri.ptr) return 0; |
29 | 33 |
30 printf("regex : %s\n",ri.ptr); | 34 printf("regex : %s\n",ri.ptr); |
47 if (generateSequentialSearch) { | 51 if (generateSequentialSearch) { |
48 exportState(tgv.tg); | 52 exportState(tgv.tg); |
49 } | 53 } |
50 } | 54 } |
51 | 55 |
52 grepWalk(tgv.tg); | 56 if (filename != NULL) { |
57 int fd = 0; | |
58 st_mmap_t st_mmap = createSt_mmap(filename,fd); | |
59 Buffer buff = createBuffer(st_mmap); | |
60 grepWalk(tgv.tg,buff); | |
61 } | |
53 return 0; | 62 return 0; |
54 } | 63 } |