1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:38:12 +00:00

LibJS: Parse FunctionExpressions

FunctionExpression is mostly like FunctionDeclaration, except the name
is optional. Share the parsing logic in parse_function_node<NodeType>.

This allows us to do nice things like:

    document.addEventListener("DOMContentLoaded", function() {
        alert("Hello friends!");
    });
This commit is contained in:
Andreas Kling 2020-03-19 11:52:56 +01:00
parent b1b4c9844e
commit 07679e347c
3 changed files with 21 additions and 5 deletions

View file

@ -43,10 +43,12 @@ public:
NonnullRefPtr<Program> parse_program();
template<typename FunctionNodeType>
NonnullRefPtr<FunctionNodeType> parse_function_node();
NonnullRefPtr<Statement> parse_statement();
NonnullRefPtr<BlockStatement> parse_block_statement();
NonnullRefPtr<ReturnStatement> parse_return_statement();
NonnullRefPtr<FunctionDeclaration> parse_function_declaration();
NonnullRefPtr<VariableDeclaration> parse_variable_declaration();
NonnullRefPtr<ForStatement> parse_for_statement();