mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 13:57:35 +00:00
parent
e2fa1b40c4
commit
491e4a8a3b
2 changed files with 12 additions and 0 deletions
|
@ -1315,6 +1315,12 @@ bool ECMA262Parser::parse_nonempty_class_ranges(Vector<CompareTypeAndValuePair>&
|
||||||
|
|
||||||
if (match(TokenType::HyphenMinus)) {
|
if (match(TokenType::HyphenMinus)) {
|
||||||
consume();
|
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();
|
auto second_atom = read_class_atom();
|
||||||
if (!second_atom.has_value())
|
if (!second_atom.has_value())
|
||||||
return false;
|
return false;
|
||||||
|
@ -1336,6 +1342,8 @@ bool ECMA262Parser::parse_nonempty_class_ranges(Vector<CompareTypeAndValuePair>&
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
read_as_single_atom:;
|
||||||
|
|
||||||
auto atom = first_atom.value();
|
auto atom = first_atom.value();
|
||||||
|
|
||||||
if (atom.is_character_class) {
|
if (atom.is_character_class) {
|
||||||
|
|
|
@ -485,6 +485,10 @@ TEST_CASE(ECMA262_parse)
|
||||||
"^hel(?<LO>l\\w).$",
|
"^hel(?<LO>l\\w).$",
|
||||||
"^[-a-zA-Z\\w\\s]+$",
|
"^[-a-zA-Z\\w\\s]+$",
|
||||||
"\\bhello\\B",
|
"\\bhello\\B",
|
||||||
|
"^[\\w+/_-]+[=]{0,2}$", // #4189
|
||||||
|
"^(?:[^<]*(<[\\w\\W]+>)[^>]*$|#([\\w\\-]*)$)", // #4189
|
||||||
|
"\\/", // #4189
|
||||||
|
"\\x", // Even invalid escapes are allowed if ~unicode.
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto& pattern : patterns) {
|
for (auto& pattern : patterns) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue