Mercurial > hg > Applications > Grep
comparison regexParser/main.cc @ 216:4852bfa85db4
spell fix
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 30 Dec 2015 15:05:06 +0900 |
parents | a94f57af1600 |
children | a9e3512120e2 |
comparison
equal
deleted
inserted
replaced
215:63e9224c7b2b | 216:4852bfa85db4 |
---|---|
1 #include <stdio.h> | 1 #include <stdio.h> |
2 #include <stdlib.h> | 2 #include <stdlib.h> |
3 #include <string.h> | 3 #include <string.h> |
4 #include "regexParser.h" | 4 #include "regexParser.h" |
5 #include "subsetConstraction.h" | 5 #include "subsetConstruction.h" |
6 #include "node.h" | 6 #include "node.h" |
7 | 7 |
8 int main(int argc, char **argv) | 8 int main(int argc, char **argv) |
9 { | 9 { |
10 bool generate = true; | |
11 bool subset = false; | |
12 | |
10 RegexInfo ri; | 13 RegexInfo ri; |
11 ri.stateNumber = 1; | 14 ri.stateNumber = 1; |
12 for (int i = 1; i < argc; i++) { | 15 for (int i = 1; i < argc; i++) { |
13 if (strcmp(argv[i],"-regex") == 0) { | 16 if (strcmp(argv[i],"-regex") == 0) { |
14 ri.ptr = (unsigned char*)argv[i+1]; i++; | 17 ri.ptr = (unsigned char*)argv[i+1]; i++; |
18 } else if (strcmp(argv[i],"-noGeneration") == 0) { | |
19 generate = false; | |
20 } else if (strcmp(argv[i],"-subset") == 0) { | |
21 subset = true; | |
15 } | 22 } |
16 } | 23 } |
24 if (!ri.ptr) return 0; | |
25 | |
17 printf("regex : %s\n",ri.ptr); | 26 printf("regex : %s\n",ri.ptr); |
18 NodePtr n = regex(&ri); | 27 NodePtr n = regex(&ri); // parse only |
19 printTree(n); | 28 printTree(n); |
20 TransitionGeneratorPtr tg = generateTransitionList(n); | 29 |
21 printTree(n); | 30 if (generate) { // NFA generation |
22 printState(tg); | 31 TGValue tgv = generateTransitionList(n); |
32 printState(tgv.tg); | |
33 } else if (subset) { | |
34 TGValue tgv = generateTransitionList(n); | |
35 SCValue scv = createSCValue(tgv); | |
36 subsetConstruction(scv); // Determinization | |
37 printState(tgv.tg); | |
38 } | |
39 | |
23 return 0; | 40 return 0; |
24 } | 41 } |