mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:17:42 +00:00
LibJS: Parse CallExpression arguments
This commit is contained in:
parent
25db856134
commit
92d1014051
1 changed files with 13 additions and 2 deletions
|
@ -191,13 +191,24 @@ NonnullOwnPtr<Expression> Parser::parse_secondary_expression(NonnullOwnPtr<Expre
|
||||||
|
|
||||||
NonnullOwnPtr<CallExpression> Parser::parse_call_expression(NonnullOwnPtr<Expression> lhs)
|
NonnullOwnPtr<CallExpression> Parser::parse_call_expression(NonnullOwnPtr<Expression> lhs)
|
||||||
{
|
{
|
||||||
// FIXME: allow arguments
|
|
||||||
consume(TokenType::ParenOpen);
|
consume(TokenType::ParenOpen);
|
||||||
|
|
||||||
|
NonnullOwnPtrVector<Expression> arguments;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
if (match_expression()) {
|
||||||
|
arguments.append(parse_expression());
|
||||||
|
if (!match(TokenType::Comma))
|
||||||
|
break;
|
||||||
|
consume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
consume(TokenType::ParenClose);
|
consume(TokenType::ParenClose);
|
||||||
|
|
||||||
// FIXME: Allow lhs expression instead of just a string
|
// FIXME: Allow lhs expression instead of just a string
|
||||||
if (lhs->is_identifier()) {
|
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;
|
m_has_errors = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue