From c7947f56ceb6c2c8500788c138ec16d4902b7690 Mon Sep 17 00:00:00 2001 From: Nathanne Isip Date: Sun, 15 Sep 2024 10:23:49 +0800 Subject: [PATCH] Terminative signal and exception handling on main source file implementation. --- src/Zhivo.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Zhivo.cpp b/src/Zhivo.cpp index 7621d9a..176c01f 100644 --- a/src/Zhivo.cpp +++ b/src/Zhivo.cpp @@ -16,8 +16,11 @@ * along with Zhivo. If not, see . */ +#include #include +#include #include +#include #include #include @@ -33,8 +36,28 @@ auto interpreter() -> int { statement->visit(symbols); return 0; } + catch(const LexicalAnalysisException& lexAnlExc) { + std::cerr << "[LEXANL]: " << lexAnlExc.what() << std::endl; + } + catch(const ParserException& parserExc) { + std::cerr << "[PARSER]: " << parserExc.what() << std::endl; + std::cerr << " " << + parserExc.getAddress()->toString() << std::endl; + } + catch(const TerminativeReturnSignal& retExc) { + std::cerr << "[OBJECT]: " << + retExc.getObject().toString() << std::endl; + } + catch(const TerminativeBreakSignal& breakExc) { + std::cerr << "[RUNTIME]: " << + "Invalid break statement signal caught." << std::endl; + } + catch(const TerminativeContinueSignal& continueExc) { + std::cerr << "[RUNTIME]: " << + "Invalid break statement signal caught." << std::endl; + } catch(const std::exception& exc) { - std::cerr << "Caught exception: " << exc.what() << std::endl; + std::cerr << "[RUNTIME]: " << exc.what() << std::endl; } return 1;