|
@@ -1315,6 +1315,12 @@ bool ECMA262Parser::parse_nonempty_class_ranges(Vector<CompareTypeAndValuePair>&
|
|
|
|
|
|
if (match(TokenType::HyphenMinus)) {
|
|
|
consume();
|
|
|
+ if (match(TokenType::RightBracket)) {
|
|
|
+ // Allow '-' as the last element in a charclass, even after an atom.
|
|
|
+ m_parser_state.lexer.back(2); // -]
|
|
|
+ m_parser_state.current_token = m_parser_state.lexer.next();
|
|
|
+ goto read_as_single_atom;
|
|
|
+ }
|
|
|
auto second_atom = read_class_atom();
|
|
|
if (!second_atom.has_value())
|
|
|
return false;
|
|
@@ -1336,6 +1342,8 @@ bool ECMA262Parser::parse_nonempty_class_ranges(Vector<CompareTypeAndValuePair>&
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+ read_as_single_atom:;
|
|
|
+
|
|
|
auto atom = first_atom.value();
|
|
|
|
|
|
if (atom.is_character_class) {
|