-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
37 lines (36 loc) · 955 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
29
30
31
32
33
34
35
36
37
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include "processor/processor.h"
int main(int argc, char** argv)
{
if (argc != 2)
{
std::cerr << "bfc64 must be launched with 1 argument being a source file!" << std::endl;
return 1;
}
std::ifstream source;
std::ofstream outputFile;
source.open(argv[1]);
outputFile.open("a.asm");
if (!source.is_open() || !outputFile.is_open())
{
std::cerr << "Failed to open file!" << std::endl;
return 1;
}
std::cerr << "Starting bfc64 v.0" << std::endl;
try
{
std::string output = compiler(optimize(parseSourceFile(source)));
outputFile << output;
outputFile.close();
std::cout << "Wrote result to a.asm" << std::endl << "Done!" << std::endl;
}
catch (std::runtime_error e)
{
std::cerr << e.what() << std::endl;
return 1;
}
}