use standard schema

This commit is contained in:
2024-08-24 01:41:32 +00:00
parent 2168e402d3
commit b903a8d7e9
2 changed files with 3 additions and 2 deletions

View File

@ -13,7 +13,7 @@ build:
# 运行目标,运行生成的可执行文件 # 运行目标,运行生成的可执行文件
run: run:
@cd $(BUILD_DIR) && ./zmxcc /dev/stdin -o /dev/null 2>/dev/null @cd $(BUILD_DIR) && ./zmxcc /dev/stdin -o /dev/stdout 2>/dev/null
# 清理目标 # 清理目标
clean: clean:

View File

@ -22,11 +22,12 @@ int main(int argc, char **argv) {
auto input_file = program.get<std::string>("input"); auto input_file = program.get<std::string>("input");
auto output_file = program.get<std::string>("output"); auto output_file = program.get<std::string>("output");
std::ifstream fin(input_file); std::ifstream fin(input_file);
std::ofstream fout(output_file);
std::shared_ptr<Program_ASTNode> ast; std::shared_ptr<Program_ASTNode> ast;
try { try {
SemanticCheck(fin, ast); SemanticCheck(fin, ast);
auto IR = BuildIR(ast); auto IR = BuildIR(ast);
IR->RecursivePrint(std::cout); IR->RecursivePrint(fout);
} catch (const SemanticError &err) { } catch (const SemanticError &err) {
std::cout << err.what() << std::endl; std::cout << err.what() << std::endl;
return err.GetErrorCode(); return err.GetErrorCode();