-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
58 lines (52 loc) · 1.25 KB
/
main.cpp
File metadata and controls
58 lines (52 loc) · 1.25 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "lex.h"
#include "syntax.h"
#include "execute.h"
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
using namespace std;
int main(){
try{
int y = 3;
cout << "What part do you want to test? (1 - lexical, 2 - syntax, 3 - execute)" << endl;
cin >> y;
if(y == 1){
Scanner scan("mytest.txt");
Lex H = scan.get_lex();
cout << H << endl;
while(H.get_type() != LEX_EXIT){
H = scan.get_lex();
cout << H << endl;
}
}
else if(y == 2){
Parser Par("mytest.txt");
Par.analyze();
Par.poliz.print();
}
else if(y == 3){
Interpretator I("mytest.txt");
I.interpretation();
}
return 0;
}
catch(char c){
cout << "\nunexpected symbol " << c << endl;
return 1;
}
catch(Lex l){
cout << "\nunexpected lexeme " << l << endl;
return 1;
}
catch(const char *source){
cout << source << endl;
return 1;
}
catch(...){
cout << "\nUnknown error" << endl;
return 1;
}
return 0;
}