call method
Implementation
AstNode call() {
AstNode expr = primary();
while (true) {
if (match([TokenType.leftParen])) {
expr = finishCall(expr);
} else if (match([TokenType.dot])) {
Token name =
consume(TokenType.identifier, "Expect property name after '.'.");
if (name.lexeme == 'length') {
expr = LengthAccess(expr);
} else {
expr = MemberAccess(expr, name);
}
} else if (match([TokenType.leftBracket])) {
AstNode index = expression();
consume(TokenType.rightBracket, "Expect ']' after index.");
expr = IndexAccess(expr, index);
} else {
break;
}
}
return expr;
}