Skip to content

Commit

Permalink
Terminative signal and exception handling on main source file impleme…
Browse files Browse the repository at this point in the history
…ntation.
  • Loading branch information
nthnn committed Sep 15, 2024
1 parent bbc0955 commit c7947f5
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/Zhivo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
* along with Zhivo. If not, see <https://www.gnu.org/licenses/>.
*/

#include <ast/TerminativeSignal.hpp>
#include <core/SymbolTable.hpp>
#include <parser/LexicalAnalysisException.hpp>
#include <parser/Parser.hpp>
#include <parser/ParserException.hpp>

#include <iostream>
#include <stdexcept>
Expand All @@ -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;
Expand Down

0 comments on commit c7947f5

Please sign in to comment.