forked from ksundberg/CS6300
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
46 lines (43 loc) · 1.01 KB
/
Copy pathmain.cpp
File metadata and controls
46 lines (43 loc) · 1.01 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
#include "FrontEnd/FrontEnd.hpp"
#include "Optimizations/Optimizer.hpp"
#include "BackEnd/BackEnd.hpp"
#include <string>
#include <iostream>
int main(int argc, char* argv[])
{
try
{
std::string outFile = "out.asm";
std::string inFile = "in.cpsl";
if (argc < 2) return EXIT_FAILURE;
if (argv[1] == std::string("-o"))
{
outFile = argv[2];
inFile = argv[3];
}
else
{
inFile = argv[1];
}
auto program = cs6300::parseCPSL(inFile);
auto optimized = cs6300::optimizer(program);
auto intermediate =
std::make_shared<cs6300::IntermediateRepresentationProgram>(optimized);
intermediate->main = cs6300::optimizer(intermediate->main);
for (auto&& f : intermediate->functions)
{
f.second = cs6300::optimizer(f.second);
}
cs6300::writeMIPS(intermediate, outFile);
}
catch (std::exception& e)
{
std::cout << "Error: " << e.what();
return EXIT_FAILURE;
}
catch (...)
{
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}