int main(int argc, char **argv) { if (argc == 1) { curr_filename = "<stdin>"; yyin = stdin; yyparse(); } else { for (int i = 1; i < argc; ++i) { curr_filename = argv[i]; yyin = std::fopen(argv[i], "r"); if (yyin) { yyparse(); std::fclose(yyin); } else { utility::print_error(argv[i], "cannot be opened"); } } } if (yynerrs > 0) { std::cerr << "Compilation halted due to lexical or syntax errors.\n"; exit(1); } SemanticAnalyzer semant; semant.install_basic(ast_root); if (!semant.validate_inheritance(ast_root->classes)) { std::cerr << "Compilation halted due to inheritance errors.\n"; exit(1); } if (!semant.type_check(ast_root)) { std::cerr << "Compilation halted due to type errors.\n"; exit(1); } AstNodeDisplayer print(std::cout, AstNodeDisplayer::DISPLAYNONBASIC); ast_root->accept(print); std::ofstream out("output.s"); AstNodeCodeGenerator codegen(semant.get_inherit_graph(), out); ast_root->accept(codegen); return 0; }