LibJS: Parse CallExpression arguments

This commit is contained in:
Andreas Kling 2020-03-12 19:35:23 +01:00
parent 25db856134
commit 92d1014051
Notes: sideshowbarker 2024-07-19 08:20:29 +09:00

View file

@ -191,13 +191,24 @@ NonnullOwnPtr<Expression> Parser::parse_secondary_expression(NonnullOwnPtr<Expre
NonnullOwnPtr<CallExpression> Parser::parse_call_expression(NonnullOwnPtr<Expression> lhs)
{
// FIXME: allow arguments
consume(TokenType::ParenOpen);
NonnullOwnPtrVector<Expression> arguments;
for (;;) {
if (match_expression()) {
arguments.append(parse_expression());
if (!match(TokenType::Comma))
break;
consume();
}
}
consume(TokenType::ParenClose);
// FIXME: Allow lhs expression instead of just a string
if (lhs->is_identifier()) {
return make<CallExpression>(static_cast<Identifier*>(lhs.ptr())->string());
return make<CallExpression>(static_cast<Identifier*>(lhs.ptr())->string(), move(arguments));
}
m_has_errors = true;