Skip to content

Commit

Permalink
Program execution by argument invocation list.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Sep 18, 2024
1 parent a1215c3 commit 0b3eda5
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/Zhivo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,22 @@
#include <iostream>
#include <stdexcept>

auto interpreter() -> int {
SymbolTable symbols;
auto printBanner() -> void {
std::cout << "Zhivo Programming Language" << std::endl;
}

auto interpreter(int argc, char** argv) -> int {
try {
Parser parser = Parser::fromFile("test.zhv");
parser.parse();
SymbolTable symbols;

for(int i = 1; i < argc; i++) {
Parser parser = Parser::fromFile(argv[i]);
parser.parse();

for(const auto& statement : parser.getGlobalStatements())
statement->visit(symbols);
}

for(const auto& statement : parser.getGlobalStatements())
statement->visit(symbols);
return 0;
}
catch(const LexicalAnalysisException& lexAnlExc) {
Expand Down Expand Up @@ -71,6 +78,10 @@ auto interpreter() -> int {
return 1;
}

decltype(interpreter()) main() {
return interpreter();
auto main(int argc, char** argv) -> int {
if(argc > 1)
return interpreter(argc, argv);

printBanner();
return 1;
}

0 comments on commit 0b3eda5

Please sign in to comment.