From 140234aef3d1c226e354780f39e8ac5114aa5ff0 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 10 Oct 2021 15:38:58 +0200 Subject: [PATCH] patterns: Fixed using declaration parsing --- plugins/libimhex/source/pattern_language/parser.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/libimhex/source/pattern_language/parser.cpp b/plugins/libimhex/source/pattern_language/parser.cpp index 8839a4035..5ec25a8bc 100644 --- a/plugins/libimhex/source/pattern_language/parser.cpp +++ b/plugins/libimhex/source/pattern_language/parser.cpp @@ -511,12 +511,13 @@ namespace hex::pl { auto originalPos = this->m_curr; parseNamespaceResolution(); bool isFunction = peek(SEPARATOR_ROUNDBRACKETOPEN); - this->m_curr = originalPos; if (isFunction) { + this->m_curr = originalPos; statement = parseFunctionCall(); } else { + this->m_curr = originalPos - 1; statement = parseFunctionVariableDecl(); } } @@ -749,7 +750,11 @@ namespace hex::pl { // using Identifier = (parseType) ASTNode* Parser::parseUsingDeclaration() { - auto name = getValue(-2).get(); + auto name = parseNamespaceResolution(); + + if (!MATCHES(sequence(OPERATOR_ASSIGNMENT))) + throwParseError("expected '=' after type name of using declaration"); + auto *type = dynamic_cast(parseType()); if (type == nullptr) throwParseError("invalid type used in variable declaration", -1); @@ -1110,7 +1115,7 @@ namespace hex::pl { std::vector Parser::parseStatements() { ASTNode *statement; - if (MATCHES(sequence(KEYWORD_USING, IDENTIFIER, OPERATOR_ASSIGNMENT))) + if (MATCHES(sequence(KEYWORD_USING, IDENTIFIER))) statement = parseUsingDeclaration(); else if (peek(IDENTIFIER)) { auto originalPos = this->m_curr;