Mercurial > hg > Members > masakoha > testcode
annotate regexParser/main.cc @ 228:399380ad95b7
fix generateTransitionGenerator
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 15 Jan 2016 19:48:53 +0900 |
parents | c38a7b2dd996 |
children | d67649929e96 |
rev | line source |
---|---|
45 | 1 #include <stdio.h> |
56
8901bc071d33
implement string() and literal()
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2 #include <stdlib.h> |
8901bc071d33
implement string() and literal()
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3 #include <string.h> |
187
ef798db705e9
remove some warnings and errors(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
180
diff
changeset
|
4 #include "regexParser.h" |
216 | 5 #include "subsetConstruction.h" |
190
3e8e5780ad4a
change node::State to State
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
189
diff
changeset
|
6 #include "node.h" |
76 | 7 |
62
a49b4a8b8c14
implement isLiteral
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
61
diff
changeset
|
8 int main(int argc, char **argv) |
55 | 9 { |
216 | 10 bool generate = true; |
11 bool subset = false; | |
228
399380ad95b7
fix generateTransitionGenerator
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
222
diff
changeset
|
12 bool generateSequentialSearch = false; |
216 | 13 |
178
5e8c6857934c
implement charClassMerge
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
167
diff
changeset
|
14 RegexInfo ri; |
5e8c6857934c
implement charClassMerge
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
167
diff
changeset
|
15 ri.stateNumber = 1; |
56
8901bc071d33
implement string() and literal()
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
16 for (int i = 1; i < argc; i++) { |
8901bc071d33
implement string() and literal()
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
17 if (strcmp(argv[i],"-regex") == 0) { |
178
5e8c6857934c
implement charClassMerge
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
167
diff
changeset
|
18 ri.ptr = (unsigned char*)argv[i+1]; i++; |
216 | 19 } else if (strcmp(argv[i],"-noGeneration") == 0) { |
20 generate = false; | |
21 } else if (strcmp(argv[i],"-subset") == 0) { | |
22 subset = true; | |
228
399380ad95b7
fix generateTransitionGenerator
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
222
diff
changeset
|
23 } else if (strcmp(argv[i],"-seq") == 0) { |
399380ad95b7
fix generateTransitionGenerator
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
222
diff
changeset
|
24 generateSequentialSearch = true; |
56
8901bc071d33
implement string() and literal()
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
25 } |
8901bc071d33
implement string() and literal()
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
26 } |
216 | 27 if (!ri.ptr) return 0; |
28 | |
178
5e8c6857934c
implement charClassMerge
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
167
diff
changeset
|
29 printf("regex : %s\n",ri.ptr); |
216 | 30 NodePtr n = regex(&ri); // parse only |
214
a94f57af1600
remove allocateCCstate createCCState
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
195
diff
changeset
|
31 printTree(n); |
216 | 32 |
219
a8e477f1352d
add an example for subset construction
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
217
diff
changeset
|
33 if (generate && !subset) { // NFA generation |
216 | 34 TGValue tgv = generateTransitionList(n); |
217 | 35 printTree(n); |
216 | 36 printState(tgv.tg); |
228
399380ad95b7
fix generateTransitionGenerator
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
222
diff
changeset
|
37 if (generateSequentialSearch) { |
399380ad95b7
fix generateTransitionGenerator
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
222
diff
changeset
|
38 exportState(tgv.tg); |
399380ad95b7
fix generateTransitionGenerator
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
222
diff
changeset
|
39 } |
216 | 40 } else if (subset) { |
41 TGValue tgv = generateTransitionList(n); | |
42 SCValue scv = createSCValue(tgv); | |
43 subsetConstruction(scv); // Determinization | |
44 printState(tgv.tg); | |
228
399380ad95b7
fix generateTransitionGenerator
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
222
diff
changeset
|
45 if (generateSequentialSearch) { |
399380ad95b7
fix generateTransitionGenerator
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
222
diff
changeset
|
46 exportState(tgv.tg); |
399380ad95b7
fix generateTransitionGenerator
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
222
diff
changeset
|
47 } |
216 | 48 } |
45 | 49 return 0; |
50 } |