Add location for member in MemberAccess ASTNode

This commit is contained in:
Marenz
2022-06-29 18:37:09 +02:00
parent 4d8a14b653
commit ee710eadd4
6 changed files with 24 additions and 5 deletions
+5 -2
View File
@@ -1897,7 +1897,9 @@ ASTPointer<Expression> Parser::parseLeftHandSideExpression(
{
advance();
nodeFactory.markEndPosition();
expression = nodeFactory.createNode<MemberAccess>(expression, expectIdentifierTokenOrAddress());
SourceLocation memberLocation = currentLocation();
ASTPointer<ASTString> memberName = expectIdentifierTokenOrAddress();
expression = nodeFactory.createNode<MemberAccess>(expression, std::move(memberName), std::move(memberLocation));
break;
}
case Token::LParen:
@@ -2335,7 +2337,8 @@ ASTPointer<Expression> Parser::expressionFromIndexAccessStructure(
Identifier const& identifier = dynamic_cast<Identifier const&>(*_iap.path[i]);
expression = nodeFactory.createNode<MemberAccess>(
expression,
make_shared<ASTString>(identifier.name())
make_shared<ASTString>(identifier.name()),
identifier.location()
);
}
for (auto const& index: _iap.indices)