mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:57:43 +00:00
LibJS: Parse slashes after reserved identifiers correctly
Previously we were unable to parse code like `yield/2` because `/2` was parsed as a regex. At the same time `for (a in / b/)` was parsed as a division. This is solved by defaulting to division in the lexer, but calling `force_slash_as_regex()` from the parser whenever an IdentifierName is parsed as a ReservedWord.
This commit is contained in:
parent
b0bd1e5eb5
commit
a2efecac03
6 changed files with 65 additions and 25 deletions
|
@ -244,6 +244,7 @@ private:
|
|||
void expected(char const* what);
|
||||
void syntax_error(DeprecatedString const& message, Optional<Position> = {});
|
||||
Token consume();
|
||||
Token consume_and_allow_division();
|
||||
Token consume_identifier();
|
||||
Token consume_identifier_reference();
|
||||
Token consume(TokenType type);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue