LibJS: Parse CallExpression arguments
This commit is contained in:
parent
25db856134
commit
92d1014051
Notes:
sideshowbarker
2024-07-19 08:20:29 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/92d10140515
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
Reference in a new issue