-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
35 lines (33 loc) · 847 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "fort.hpp"
#include "nfa.hpp"
#include <iostream>
#include <string>
int main() {
NFA nfa;
int s = 0, t = 0;
std::cin >> s;
for (int i = 0; i < s; ++i) {
std::string str;
std::cin >> str;
if (str.front() == '-') {
if (str[1] == '+') {
nfa.addInitialState(str.substr(2), true);
} else {
nfa.addInitialState(str.substr(1), false);
}
} else if (str.front() == '+') {
nfa.addState(str.substr(1), true);
} else {
nfa.addState(str, false);
}
}
std::cin >> t;
for (int i = 0; i < t; ++i) {
std::string a, b;
char c;
std::cin >> a >> b >> c;
nfa.addTransition(a, b, c);
}
std::cout << nfa << '\n';
std::cout << nfa.toDFA() << '\n';
}