From 967be9e750221ab2ab783f95df79bb26d290a45e Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:07:58 +0200 Subject: add: added projects --- tiger-compiler/src/tc.cc | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tiger-compiler/src/tc.cc (limited to 'tiger-compiler/src/tc.cc') diff --git a/tiger-compiler/src/tc.cc b/tiger-compiler/src/tc.cc new file mode 100644 index 0000000..0453714 --- /dev/null +++ b/tiger-compiler/src/tc.cc @@ -0,0 +1,53 @@ +/** + ** \file tc.cc + ** \brief The compiler driver. + */ + +#include +#include +#include +#include +#include + +#include + +int main(int argc, char** argv) +{ + program_name = argv[0]; + + try + { + task_timer.start(); + task_timer.push("rest"); + + filename = task::TaskRegister::instance().parse_arg(argc, argv); + task_error().exit_on_error(); + + // If `help', `usage' or `version' is called, just exit. + if (filename == nullptr) + return 0; + + if (task::TaskRegister::instance().nb_of_task_to_execute_get() == 0) + task::TaskRegister::instance().enable_task("parse"); + + task::TaskRegister::instance().execute(); + task_timer << task::TaskRegister::instance().timer_get(); + task_error().exit_on_error(); + } + + // Required to enable stack unwinding. + catch (const std::invalid_argument& e) + { + return 64; + } + catch (const std::runtime_error& e) + { + if (e.what() != std::string("")) + std::cerr << e.what() << '\n'; + } + catch (const misc::error& e) + { + std::cerr << e; + return e.status_get_value(); + } +} -- cgit v1.2.3