mirror of
https://github.com/RGBCube/serenity
synced 2025-05-18 11:45:08 +00:00
LibJS: Distinguish between statement and declaration
This separates matching/parsing of statements and declarations and fixes a few edge cases where the parser would incorrectly accept a declaration where only a statement is allowed - for example: if (foo) const a = 1; for (var bar;;) function b() {} while (baz) class c {}
This commit is contained in:
parent
f8ae6fa713
commit
80bb62b9cc
4 changed files with 73 additions and 30 deletions
|
@ -60,6 +60,7 @@ public:
|
|||
NonnullRefPtr<FunctionNodeType> parse_function_node(u8 parse_options = FunctionNodeParseOptions::CheckForFunctionAndName);
|
||||
Vector<FunctionNode::Parameter> parse_function_parameters(int& function_length, u8 parse_options = 0);
|
||||
|
||||
NonnullRefPtr<Declaration> parse_declaration();
|
||||
NonnullRefPtr<Statement> parse_statement();
|
||||
NonnullRefPtr<BlockStatement> parse_block_statement();
|
||||
NonnullRefPtr<BlockStatement> parse_block_statement(bool& is_strict);
|
||||
|
@ -147,6 +148,7 @@ private:
|
|||
bool match_unary_prefixed_expression() const;
|
||||
bool match_secondary_expression(Vector<TokenType> forbidden = {}) const;
|
||||
bool match_statement() const;
|
||||
bool match_declaration() const;
|
||||
bool match_variable_declaration() const;
|
||||
bool match_identifier_name() const;
|
||||
bool match_property_key() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue