mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 19:15:09 +00:00
LibJS: Add parsed parameters to FunctionDeclaration
This commit is contained in:
parent
83ea7bb9e7
commit
0e04e2cff0
1 changed files with 4 additions and 3 deletions
|
@ -245,9 +245,10 @@ NonnullOwnPtr<FunctionDeclaration> Parser::parse_function_declaration()
|
||||||
consume(TokenType::Function);
|
consume(TokenType::Function);
|
||||||
auto name = consume(TokenType::Identifier).value();
|
auto name = consume(TokenType::Identifier).value();
|
||||||
consume(TokenType::ParenOpen);
|
consume(TokenType::ParenOpen);
|
||||||
|
Vector<String> parameters;
|
||||||
while (match(TokenType::Identifier)) {
|
while (match(TokenType::Identifier)) {
|
||||||
// FIXME: actually add parameters to function
|
auto parameter = consume(TokenType::Identifier).value();
|
||||||
consume(TokenType::Identifier);
|
parameters.append(parameter);
|
||||||
if (match(TokenType::ParenClose)) {
|
if (match(TokenType::ParenClose)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -255,7 +256,7 @@ NonnullOwnPtr<FunctionDeclaration> Parser::parse_function_declaration()
|
||||||
}
|
}
|
||||||
consume(TokenType::ParenClose);
|
consume(TokenType::ParenClose);
|
||||||
auto body = parse_block_statement();
|
auto body = parse_block_statement();
|
||||||
return make<FunctionDeclaration>(name, move(body));
|
return make<FunctionDeclaration>(name, move(body), move(parameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullOwnPtr<VariableDeclaration> Parser::parse_variable_declaration()
|
NonnullOwnPtr<VariableDeclaration> Parser::parse_variable_declaration()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue