mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +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)
|
||||
{
|
||||
// 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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue