Mercurial > hg > Members > masakoha > testcode
annotate regexParser/main.cc @ 217:a9e3512120e2
NFA generation end
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 30 Dec 2015 18:37:01 +0900 |
parents | 4852bfa85db4 |
children | a8e477f1352d |
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; | |
12 | |
178
5e8c6857934c
implement charClassMerge
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
167
diff
changeset
|
13 RegexInfo ri; |
5e8c6857934c
implement charClassMerge
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
167
diff
changeset
|
14 ri.stateNumber = 1; |
56
8901bc071d33
implement string() and literal()
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
15 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
|
16 if (strcmp(argv[i],"-regex") == 0) { |
178
5e8c6857934c
implement charClassMerge
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
167
diff
changeset
|
17 ri.ptr = (unsigned char*)argv[i+1]; i++; |
216 | 18 } else if (strcmp(argv[i],"-noGeneration") == 0) { |
19 generate = false; | |
20 } else if (strcmp(argv[i],"-subset") == 0) { | |
21 subset = true; | |
56
8901bc071d33
implement string() and literal()
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
22 } |
8901bc071d33
implement string() and literal()
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
23 } |
216 | 24 if (!ri.ptr) return 0; |
25 | |
178
5e8c6857934c
implement charClassMerge
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
167
diff
changeset
|
26 printf("regex : %s\n",ri.ptr); |
216 | 27 NodePtr n = regex(&ri); // parse only |
214
a94f57af1600
remove allocateCCstate createCCState
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
195
diff
changeset
|
28 printTree(n); |
216 | 29 |
30 if (generate) { // NFA generation | |
31 TGValue tgv = generateTransitionList(n); | |
217 | 32 printTree(n); |
216 | 33 printState(tgv.tg); |
34 } else if (subset) { | |
35 TGValue tgv = generateTransitionList(n); | |
36 SCValue scv = createSCValue(tgv); | |
37 subsetConstruction(scv); // Determinization | |
38 printState(tgv.tg); | |
39 } | |
40 | |
45 | 41 return 0; |
42 } |