-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
60 lines (55 loc) · 1.43 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include "lexer.h"
#include "parser.h"
#include "executioner.h"
using namespace std;
int main(){
/// lexer
// try{
// FileSource input("test1.js");
//// FileSource input("function a()", false);
// Lexer lexer(input);
// Token tmp;
// while(true){
// if((tmp = lexer.get_token()).get_type() == ENDOF) break;
// cout << tmp;
// }
// }
// catch(bad_jaba err){
// cerr << err << endl << "stopping" << endl;
// }
/// parser & reverse polish notation
// try{
// FileSource input("test0.js");
// Lexer lexer(input);
// Parser parser(&lexer, true);
// parser.parse();
// parser.out_rpn_array(); /// die "POLIZ"
// }
// catch(bad_jaba err){
// cerr << err << endl << "stopping" << endl;
// }
// clog << "done." << endl;
/// execution
try{
FileSource input("test0.js");
Lexer lexer(input);
Parser parser(&lexer, false);
parser.parse();
parser.out_rpn_array();
Executioner executor(parser.get_rpn_el());
cout << endl << "program returned " << executor.execute() << endl;
}
catch(bad_jaba err){
cerr << err << endl << "stopping" << endl;
}
catch(exception err){
cerr << err.what() << endl;
}
catch(...){
cerr << "unknown error" << endl;
}
// int i;
// cin >> i;
return 0;
}