diff --git a/src/Parser/Lexer.cpp b/src/Parser/Lexer.cpp index b0f3003..e765ca4 100644 --- a/src/Parser/Lexer.cpp +++ b/src/Parser/Lexer.cpp @@ -60,7 +60,7 @@ IToken* Lexer::LexNext(char c){ if (isalpha(c)){ return LexIdentifierOrKeyword(c); } - this -> ScriptData->Diagnostics.LogError(DiagnosticCode::UnexpectedCharacter, this -> Position - 1, 1); + this -> ScriptData -> Diagnostics -> LogError(DiagnosticCode::UnexpectedCharacter, this -> Position - 1, 1); return new SimpleToken(TokenKind::BadToken, this -> Position - 1, 1); } } diff --git a/src/Parser/Parser.cpp b/src/Parser/Parser.cpp index 83a3006..f8a77e5 100644 --- a/src/Parser/Parser.cpp +++ b/src/Parser/Parser.cpp @@ -111,7 +111,7 @@ ParsedExpression *Parser::ParsePrimaryExpression(IToken *current) { case TokenKind ::TrueKeyword: return new LiteralBoolExpression(current); case TokenKind ::FalseKeyword: return new LiteralBoolExpression(current); default: - this -> ScriptData -> Diagnostics.LogError(DiagnosticCode::UnexpectedToken, current->GetStartPosition(), current->GetLength()); + this -> ScriptData -> Diagnostics -> LogError(DiagnosticCode::UnexpectedToken, current->GetStartPosition(), current->GetLength()); return new BadExpression(current->GetStartPosition(), current->GetLength()); } } diff --git a/src/Script.cpp b/src/Script.cpp index 01eb0c8..7a7e3a3 100644 --- a/src/Script.cpp +++ b/src/Script.cpp @@ -11,6 +11,10 @@ Script Script::Create(string script) { return s; } +Script::~Script() { + delete this -> Diagnostics; +} + void Script::Parse(string script) { auto lexer = Lexer(std::move(script), this); auto lexResult = lexer.Lex(); @@ -21,3 +25,4 @@ void Script::Parse(string script) { } lexResult.clear(); } + diff --git a/src/Script.hpp b/src/Script.hpp index 5b1bff4..6e661c6 100644 --- a/src/Script.hpp +++ b/src/Script.hpp @@ -10,12 +10,16 @@ using namespace std; class Script { - explicit Script() = default; + explicit Script(){ + Diagnostics = new class Diagnostics(); + }; void Parse(string script); public: static Script Create(string script); - Diagnostics Diagnostics; + Diagnostics* Diagnostics; + + ~Script(); };