feat(frontend): 命令行添加IR和AST选择输出
This commit is contained in:
10
src/main.cpp
10
src/main.cpp
@@ -21,7 +21,9 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
auto antlr = ParseFileWithAntlr(opts.input);
|
||||
auto ast = BuildAst(antlr.tree);
|
||||
ast::PrintAST(*ast); // 调试 AST
|
||||
if (opts.emit_ast) {
|
||||
ast::PrintAST(*ast); // 调试 AST
|
||||
}
|
||||
if (!opts.ast_dot_output.empty()) {
|
||||
std::ofstream dot_out(opts.ast_dot_output);
|
||||
if (!dot_out) {
|
||||
@@ -34,8 +36,10 @@ int main(int argc, char** argv) {
|
||||
// 同学们可以在 irgen/ 目录下按提示自行完善或替换实现。
|
||||
auto module = GenerateIR(*ast);
|
||||
|
||||
ir::IRPrinter printer;
|
||||
printer.Print(*module);
|
||||
if (opts.emit_ir) {
|
||||
ir::IRPrinter printer;
|
||||
printer.Print(*module);
|
||||
}
|
||||
} catch (const std::exception& ex) {
|
||||
std::cerr << "error: " << ex.what() << "\n";
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user