-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
55 lines (53 loc) · 1.43 KB
/
Copy pathmain.cpp
File metadata and controls
55 lines (53 loc) · 1.43 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
#ifndef defs_hpp
#include "defs.hpp"
#define defs_hpp
#endif
using namespace std;
extern void yyparse();
#ifdef LOCALTEST
int main(int argc, char **argv) {
string file_name = argv[1];
if (file_name[-3 + file_name.size()] == '.')
file_name = file_name.substr(0, -3 + file_name.size());
string sysy_file = file_name + ".sy";
string eeyore_file = file_name + ".eeyore";
string tigger_file = file_name + ".tigger";
string riscv_file = "output.S";
freopen(sysy_file.c_str(), "r", stdin);
#else
int main(int argc, char **argv)
{
if (argc == 6) {
freopen(argv[3], "r", stdin);
freopen(argv[5], "w", stdout);
}
else {
freopen(argv[2], "r", stdin);
freopen(argv[4], "w", stdout);
}
#endif
varManager->newEnviron();
yyparse();
sysyRoot->translate("", "", true);
#ifdef LOCALTEST
freopen(eeyore_file.c_str(), "w", stdout);
eeyoreRoot->Dump();
freopen(tigger_file.c_str(), "w", stdout);
eeyoreRoot->translate();
tiggerRoot->Dump();
freopen(riscv_file.c_str(), "w", stdout);
tiggerRoot->translate();
#else
if (strcmp(argv[2], "-e") == 0)
eeyoreRoot->Dump();
/* compile to eeyore */
else {
eeyoreRoot->translate();
if (strcmp(argv[2], "-t") == 0)
tiggerRoot->Dump();
else
tiggerRoot->translate();
}
#endif
return 0;
}