-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
27 lines (23 loc) · 684 Bytes
/
main.cpp
File metadata and controls
27 lines (23 loc) · 684 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
#include <vector>
#include <string>
#include "LL1.h"
#include "type.h"
using namespace std;
int main() {
vector<pair<string, string>> grams({
{"S", "(S+F)"}, {"S", "F"}, {"F", "1"}
});
auto parser = Parser(grams);
parser.constructParseTable();
Node* root = nullptr;
cout << parser.parse("((1+1)+1)", root) << endl;
root->visitTreePreOrder();
root->visitLevelOrder();
cout << parser.parse("(1+(1+1)+1)") << endl;
cout << parser.parse("(+1)") << endl;
cout << parser.parse("()") << endl;
cout << parser.parse("1") << endl;
cout << parser.parse("1+") << endl;
cout << parser.parse("(1+1))))()") << endl;
return 0;
}