-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
71 lines (69 loc) · 1.35 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
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include <fstream>
#include "lexical.h"
#include "grammer.h"
#include "midCode.h"
#include "mipsCode.h"
#include "function.h"
#include "optimize.h"
using namespace std;
extern string filecontent; //文件的内容
ifstream inputfile;
ofstream outputfile;
ofstream errorfile;
ofstream midCodefile;
ofstream mipsCodefile;
int debug = 1;
bool error = false;
int main() {
inputfile.open("testfile.txt", ios::in);
outputfile.open("output.txt", ios::out);
errorfile.open("error.txt", ios::out);
midCodefile.open("midCode.txt", ios::out);
mipsCodefile.open("mips.txt", ios::out);
string tmpIn;
while (getline(inputfile, tmpIn)) { //读取文件内容
filecontent.append(tmpIn);
filecontent.append("\n");
}
int re = getsym();
if (re < 0) {
//error()
}
else {
if (procedure()) {
//success
//cout << "True!" << endl;
}
else {
//error()
}
}
if (!error) {
//midCodefile.open("midCode.txt", ios::out);
//mipsCodefile.open("mips.txt", ios::out);
if (debug) {
showFuncMidCode();
}
splitBlock();
if (debug) {
showFuncBlock();
}
outputMidCode();
genMips();
outputMipsCode();
//midCodefile.close();
//mipsCodefile.close();
if (debug) {
showGlobal();
showAll();
showString();
}
}
inputfile.close();
outputfile.close();
errorfile.close();
midCodefile.close();
mipsCodefile.close();
return 0;
}