-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
28 lines (25 loc) · 897 Bytes
/
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
#include <iostream>
#include <fstream>
#include"Lexer.h"
#include "Parser.h"
//要按照错误的先后顺序 对着文法来
int main() {
ifstream input("testfile.txt");
ofstream output("output.txt");
ofstream errorFile("error.txt");
ofstream mipsFile("mips.txt");
Lexer & my_lexer = Lexer::initLexer(input,output);//相当于 放给语法Parser去指导Lexer
IntermediateCode intermediateCode{};
MipsCode mipsCode(intermediateCode,mipsFile);
ErrorHandler errorHandler(my_lexer,errorFile);
TableManager tableManager(errorHandler);
Semantic semantic(my_lexer,tableManager,errorHandler);
Parser parser(my_lexer,tableManager,errorHandler,semantic,intermediateCode);
parser.CompUnit();
//errorHandler.Print_Errors();
// intermediateCode.debug_print();
mipsCode.translate();
//mipsCode.testRe();
//my_lexer.analyze();
return 0;
}