forked from ppxf25tqu/nudt-compiler-cpp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
678 B
30 lines
678 B
#include <exception>
|
|
#include <iostream>
|
|
|
|
#include "frontend/AntlrDriver.h"
|
|
#include "frontend/AstBuilder.h"
|
|
#include "ir/IR.h"
|
|
#include "irgen/IRGen.h"
|
|
#include "sem/Sema.h"
|
|
#include "utils/CLI.h"
|
|
#include "utils/Log.h"
|
|
#include "ast/AstNodes.h"
|
|
|
|
int main(int argc, char** argv) {
|
|
try {
|
|
auto opts = ParseCLI(argc, argv);
|
|
auto antlr = ParseFileWithAntlr(opts.input);
|
|
auto ast = BuildAst(antlr.tree);
|
|
ast::PrintAST(*ast); // 调试 AST
|
|
ast = RunSema(std::move(ast));
|
|
auto module = GenerateIR(*ast);
|
|
|
|
ir::IRPrinter printer;
|
|
printer.Print(*module);
|
|
} catch (const std::exception& ex) {
|
|
LOG_ERROR(ex.what());
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|