fix(frontend): 修复部分实现
This commit is contained in:
11
src/main.cpp
11
src/main.cpp
@@ -1,10 +1,13 @@
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "frontend/AntlrDriver.h"
|
||||
#include "frontend/SyntaxTreePrinter.h"
|
||||
#include "ir/IR.h"
|
||||
#include "irgen/IRGen.h"
|
||||
#include "mir/MIR.h"
|
||||
#include "sem/Sema.h"
|
||||
#include "utils/CLI.h"
|
||||
#include "utils/Log.h"
|
||||
|
||||
@@ -19,10 +22,16 @@ int main(int argc, char** argv) {
|
||||
auto antlr = ParseFileWithAntlr(opts.input);
|
||||
bool need_blank_line = false;
|
||||
if (opts.emit_parse_tree) {
|
||||
std::cout << antlr.tree->toStringTree(antlr.parser.get()) << "\n";
|
||||
PrintSyntaxTree(antlr.tree, antlr.parser.get(), std::cout);
|
||||
need_blank_line = true;
|
||||
}
|
||||
|
||||
auto* comp_unit = dynamic_cast<SysYParser::CompUnitContext*>(antlr.tree);
|
||||
if (!comp_unit) {
|
||||
throw std::runtime_error("[main] 语法树根节点不是 compUnit");
|
||||
}
|
||||
RunSema(*comp_unit);
|
||||
|
||||
auto module = GenerateIR(antlr.tree);
|
||||
if (opts.emit_ir) {
|
||||
ir::IRPrinter printer;
|
||||
|
||||
Reference in New Issue
Block a user