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
commit 07679e347c
Notes: sideshowbarker 2024-07-19 08:14:55 +09:00
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();