diff --git a/src/Parser/Parser.cpp b/src/Parser/Parser.cpp index 407a256..84fa1e4 100644 --- a/src/Parser/Parser.cpp +++ b/src/Parser/Parser.cpp @@ -262,27 +262,30 @@ namespace MalachScript::Parser { return true; } bool Parser::ParseScope(std::vector& scope, const LexToken*& currentToken) { - if (currentToken->GetKind() == LexTokenKind::ColonColonSymbol) { + const auto* current = currentToken; + if (current->GetKind() == LexTokenKind::ColonColonSymbol) { scope.emplace_back(); - PROGRESS_TOKEN(currentToken); + PROGRESS_TOKEN(current); } Identifier identifier; - if (ParseIdentifier(identifier, currentToken)) { - const auto* n = currentToken->GetNext().get(); - currentToken = n; + if (ParseIdentifier(identifier, current)) { + PROGRESS_TOKEN(current); scope.push_back(identifier); + if (current->GetKind() != LexTokenKind::ColonColonSymbol){ + return false; + } } else { return false; } - while (currentToken != nullptr && currentToken->GetKind() == LexTokenKind::ColonColonSymbol) { - PROGRESS_TOKEN(currentToken); - const auto* n = currentToken; + while (current != nullptr && current->GetKind() == LexTokenKind::ColonColonSymbol) { + PROGRESS_TOKEN(current); + const auto* n = current; if (ParseIdentifier(identifier, n)) { PROGRESS_TOKEN(n); if (n->GetKind() == LexTokenKind::ColonColonSymbol) { - currentToken = n; + current = n; scope.push_back(identifier); } else { break; @@ -293,6 +296,7 @@ namespace MalachScript::Parser { } } // TODO: Handle generics in script class name. + currentToken = current; return true; }