Skip to content

Commit

Permalink
Global symbol table thread clearing on main source file implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Sep 24, 2024
1 parent 9882320 commit 7a70731
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Zhivo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <ast/ASTNodeException.hpp>
#include <ast/TerminativeSignal.hpp>
#include <core/Runtime.hpp>
#include <core/SymbolTable.hpp>
#include <parser/LexicalAnalysisException.hpp>
#include <parser/Parser.hpp>
Expand All @@ -31,9 +32,8 @@ auto printBanner() -> void {
}

auto interpreter(int argc, char** argv) -> int {
SymbolTable symbols;
try {
SymbolTable symbols;

for(int i = 1; i < argc; i++) {
Parser parser = Parser::fromFile(argv[i]);
parser.parse();
Expand All @@ -42,42 +42,50 @@ auto interpreter(int argc, char** argv) -> int {
statement->visit(symbols);
}

symbols.waitForThreads();
return 0;
}
catch(const ASTNodeException& nodeExc) {
symbols.waitForThreads();
std::cerr << "[\u001b[1;31mRuntime Error\u001b[0m]: "
<< "\u001b[3;37m" << nodeExc.what() << "\u001b[0m"
<< std::endl << " "
<< nodeExc.getAddress()->toString() << std::endl;
}
catch(const LexicalAnalysisException& lexAnlExc) {
symbols.waitForThreads();
std::cerr << "[\u001b[1;31mLexical Error\u001b[0m]:" << std::endl
<< "\t" << lexAnlExc.what() << std::endl;
}
catch(const ParserException& parserExc) {
symbols.waitForThreads();
std::cerr << "[\u001b[1;31mParser Error\u001b[0m]: \u001b[3;37m"
<< parserExc.what() << "\u001b[0m" << std::endl;
std::cerr << " " <<
parserExc.getAddress()->toString() << std::endl;
}
catch(const TerminativeBreakSignal& breakExc) {
symbols.waitForThreads();
std::cerr << "[\u001b[1;31mRuntime Error\u001b[0m]: "
<< "\u001b[3;37mInvalid break statement signal caught.\u001b[0m"
<< std::endl << " "
<< breakExc.getAddress().toString() << std::endl;
}
catch(const TerminativeContinueSignal& continueExc) {
symbols.waitForThreads();
std::cerr << "[\u001b[1;31mRuntime Error\u001b[0m]: "
<< "\u001b[3;37mInvalid continue statement signal caught.\u001b[0m"
<< std::endl << " "
<< continueExc.getAddress().toString() << std::endl;
}
catch(const TerminativeReturnSignal& retExc) {
symbols.waitForThreads();
std::cerr << "\u001b[0;93m"
<< retExc.getObject().toString()
<< "\u001b[0m" << std::endl;
}
catch(const std::exception& exc) {
symbols.waitForThreads();
std::cerr << "[\u001b[1;31mRuntime Error\u001b[0m]: \u001b[3;37m"
<< exc.what() << "\u001b[0m" << std::endl;
}
Expand Down

0 comments on commit 7a70731

Please sign in to comment.