-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
37 lines (26 loc) · 977 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 <boost/program_options.hpp>
#include <iostream>
#include "codegen.h"
#include "compiler.h"
#include "options.h"
#include "parser.h"
int main(int argc, char** argv) {
using namespace Tobsterlang;
auto options = Options::parse(argc, argv);
if (options.variables.count("help")) {
std::cout << options.description << std::endl;
return 0;
}
auto input_file = options.variables["input"].as<std::string>();
auto tree = Parser::parse(input_file);
Codegen codegen;
auto module = codegen.generate(tree);
std::string object_file =
options.variables.count("output")
? options.variables["output"].as<std::string>()
: "./" + std::string(module->getName().data()) + ".o";
auto optimization_level = Options::get_optimization_level(
options.variables["optimization"].as<std::string>());
Compiler::compile(std::move(module), object_file, optimization_level);
return 0;
}