summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Parser.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-03-13 13:40:24 +0000
committerAndreas Kling <kling@serenityos.org>2020-03-13 20:16:01 +0100
commit0e04e2cff05a7c4fc3664c634e527313e656d15d (patch)
treeb7c8ce3927f69b32d148a1a13901d764e7cf457b /Libraries/LibJS/Parser.cpp
parent83ea7bb9e73f91de2cc4940f384414be61eaafd0 (diff)
downloadserenity-0e04e2cff05a7c4fc3664c634e527313e656d15d.zip
LibJS: Add parsed parameters to FunctionDeclaration
Diffstat (limited to 'Libraries/LibJS/Parser.cpp')
-rw-r--r--Libraries/LibJS/Parser.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/Libraries/LibJS/Parser.cpp b/Libraries/LibJS/Parser.cpp
index 0be2fb3bb0..ebbae3c475 100644
--- a/Libraries/LibJS/Parser.cpp
+++ b/Libraries/LibJS/Parser.cpp
@@ -245,9 +245,10 @@ NonnullOwnPtr<FunctionDeclaration> Parser::parse_function_declaration()
consume(TokenType::Function);
auto name = consume(TokenType::Identifier).value();
consume(TokenType::ParenOpen);
+ Vector<String> parameters;
while (match(TokenType::Identifier)) {
- // FIXME: actually add parameters to function
- consume(TokenType::Identifier);
+ auto parameter = consume(TokenType::Identifier).value();
+ parameters.append(parameter);
if (match(TokenType::ParenClose)) {
break;
}
@@ -255,7 +256,7 @@ NonnullOwnPtr<FunctionDeclaration> Parser::parse_function_declaration()
}
consume(TokenType::ParenClose);
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()