1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:47:34 +00:00

LibJS: Fix small issues in parser

- Fix some places where escaped keywords are (not) allowed.
- Be more strict about parameters for functions with 'use strict'.
- Fix that expressions statements allowed functions and classes.
- Fix that class expressions were not allowed.
- Added a new next_token() method for checking the look ahead.
- Fix that continue labels could jump to non iterating targets.
- Fix that generator functions cannot be declared in if statements.
This commit is contained in:
davidot 2021-08-28 17:04:37 +02:00 committed by Linus Groh
parent 8a7ce4eea3
commit 3b6a8d1d53
2 changed files with 66 additions and 41 deletions

View file

@ -58,7 +58,7 @@ public:
NonnullRefPtr<Statement> parse_statement(AllowLabelledFunction allow_labelled_function = AllowLabelledFunction::No);
NonnullRefPtr<BlockStatement> parse_block_statement();
NonnullRefPtr<BlockStatement> parse_block_statement(bool& is_strict, bool error_on_binding = false);
NonnullRefPtr<BlockStatement> parse_block_statement(bool& is_strict, bool function_with_non_simple_parameter_list = false);
NonnullRefPtr<ReturnStatement> parse_return_statement();
NonnullRefPtr<VariableDeclaration> parse_variable_declaration(bool for_loop_variable_declaration = false);
NonnullRefPtr<Statement> parse_for_statement();
@ -180,6 +180,8 @@ private:
void discard_saved_state();
Position position() const;
Token next_token();
void check_identifier_name_for_assignment_validity(StringView, bool force_strict = false);
bool try_parse_arrow_function_expression_failed_at_position(const Position&) const;
@ -245,7 +247,7 @@ private:
Vector<Vector<FunctionNode::Parameter>&> function_parameters;
HashTable<StringView> labels_in_scope;
HashMap<StringView, bool> labels_in_scope;
bool strict_mode { false };
bool allow_super_property_lookup { false };
bool allow_super_constructor_call { false };