-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
35 lines (30 loc) · 691 Bytes
/
main.cpp
File metadata and controls
35 lines (30 loc) · 691 Bytes
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 <iostream>
#include "Algo.h"
int main() {
Algo early_algorithm;
Grammar grammar;
std::cout << "Number of rules : ";
size_t num_rules = 0;
std::cin >> num_rules;
std::cout << "Rules : \n";
for (size_t i = 0; i < num_rules; ++i) {
std::string raw_format;
std::cin >> raw_format;
try {
grammar.AddRule(raw_format);
} catch (std::exception& error) {
std::cerr << error.what() << std::endl;
return 1;
}
}
std::cout << "Word to search : ";
std::string word;
std::cin >> word;
if (early_algorithm.Check(grammar, word)) {
std::cout << "YES";
} else {
std::cout << "NO";
}
std::cout << std::endl;
return 0;
}