diff --git a/mx b/mx new file mode 100755 index 0000000..f98e188 Binary files /dev/null and b/mx differ diff --git a/main.cpp b/src/main.cpp similarity index 90% rename from main.cpp rename to src/main.cpp index ad5012f..4850ead 100644 --- a/main.cpp +++ b/src/main.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -51,18 +52,19 @@ struct var { } }; +string logList; + class Logger { private: bool isDebug = false; - string log; void writeToLog(string type, string in) { - log += type + ": " + in + "\n"; + logList += type + ": " + in + "\n"; } public: string getLog() { - return log; + return logList; } void toggleDebugPrint() { isDebug = !isDebug; @@ -205,24 +207,36 @@ class Parser { tokens.push_back(semi); } } + vector getTokens() { + return tokens; + } }; class Interpreter { private: vector tokens; + Logger log; int tokenIndex = 0; Token consume() { - return tokens[tokenIndex++]; + return tokens.at(tokenIndex++); } Token peek(int index = 1) { - return tokens[tokenIndex + index]; + return tokens.at(tokenIndex + index); } public: void interpret(vector tokenList) { tokens = tokenList; + log.debug("Alright we got " + to_string(tokens.size()) + " tokens"); while (tokenIndex < tokens.size()) { - + Token currentToken = consume(); + int peekAhead = 1; + vector currentInstruction; + while (peek(peekAhead).keyword != keywords::SEMICOLON) { + raise(SIGINT); + currentInstruction.push_back(peek(peekAhead)); + peekAhead ++; + } } } }; @@ -244,5 +258,7 @@ int main(int argc, char* argv[]) { } parser.parseLines(file, log); parser.processLines(); + Interpreter interpreter; + interpreter.interpret(parser.getTokens()); return 0; }