Skip to content

Commit

Permalink
Example/test usage for Parser class in main source file.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Sep 12, 2024
1 parent 1d7ca6f commit e7c6a03
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Zhivo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <core/SymbolTable.hpp>

#include <parser/LexicalAnalysisException.hpp>
#include <parser/Parser.hpp>
#include <parser/Token.hpp>
#include <parser/Tokenizer.hpp>

Expand Down Expand Up @@ -307,6 +308,16 @@ auto interpreter() -> int {
}

decltype(interpreter()) main() {
SymbolTable symbols;

Parser parser = Parser::fromFile("test.zhv");
parser.parse();

for(const auto& statement : parser.getGlobalStatements()) {
DynamicObject object = statement->visit(symbols);
std::cout << "Result: " << object.toString() << std::endl;
}

try {
return interpreter();
}
Expand Down

0 comments on commit e7c6a03

Please sign in to comment.