diff --git a/src/Parser/Lexer.cpp b/src/Parser/Lexer.cpp index fc5fe9e..7685f29 100644 --- a/src/Parser/Lexer.cpp +++ b/src/Parser/Lexer.cpp @@ -6,7 +6,7 @@ #include "Lexer.hpp" Lexer::Lexer(string scriptString, class Script* script) { - this -> ScriptString = std::move(scriptString); + this -> _scriptString = std::move(scriptString); this -> ScriptData = script; this -> Position = 0; } @@ -18,6 +18,8 @@ vector Lexer::Lex() { auto nextKind = next -> GetKind(); if (nextKind != TokenKind::WhiteSpace) tokens.push_back(next); + else + delete next; if (nextKind == TokenKind::EndOfFile) break; } @@ -25,9 +27,9 @@ vector Lexer::Lex() { } char Lexer::Peek(){ - if (Lexer::Position > this -> ScriptString.length()) + if (Lexer::Position > this -> _scriptString.length()) return '\0'; - return this -> ScriptString[Lexer::Position]; + return this -> _scriptString[Lexer::Position]; } char Lexer::Next(){ @@ -164,7 +166,7 @@ IToken * Lexer::LexIdentifierOrKeyword() { } } - string s = this -> ScriptString.substr(start, end - start + 1); + string s = this -> _scriptString.substr(start, end - start + 1); switch (const_hash(s.c_str())){ case const_hash("and"): return new SimpleToken(TokenKind::AndKeyword, start, 3); case const_hash("break"): return new SimpleToken(TokenKind::BreakKeyword, start, 5); @@ -222,7 +224,7 @@ IToken* Lexer::LexString(char c){ return new SimpleToken(TokenKind::BadToken, start, end -start + 1); } - string s = this -> ScriptString.substr(start + 1, end - start); + string s = this -> _scriptString.substr(start + 1, end - start); stringstream stream; for (int i = 0; i < s.size(); i++){ c = s[i]; diff --git a/src/Parser/Lexer.hpp b/src/Parser/Lexer.hpp index a489420..dc1045f 100644 --- a/src/Parser/Lexer.hpp +++ b/src/Parser/Lexer.hpp @@ -8,7 +8,7 @@ using namespace std; class Lexer { - string ScriptString; + string _scriptString; #ifdef TESTS_BUILD public: #endif @@ -17,8 +17,8 @@ public: char Next(); IToken* LexNext(char c); IToken* LexNumber(char c); - IToken *LexIdentifierOrKeyword(); - IToken *LexString(char c); + IToken* LexIdentifierOrKeyword(); + IToken* LexString(char c); public: Script* ScriptData;