1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:57:45 +00:00

LibRegex: Consider named capture groups as normal capture groups too

This commit is contained in:
AnotherTest 2021-04-05 06:25:57 +04:30 committed by Andreas Kling
parent be0182d049
commit 1bdc1cf77e
2 changed files with 6 additions and 1 deletions

View file

@ -1692,6 +1692,7 @@ bool ECMA262Parser::parse_capture_group(ByteCode& stack, size_t& match_length_mi
if (consume("<")) {
++m_parser_state.named_capture_groups_count;
auto group_index = ++m_parser_state.capture_groups_count; // Named capture groups count as normal capture groups too.
auto name = read_capture_group_specifier();
if (name.is_empty()) {
@ -1707,12 +1708,15 @@ bool ECMA262Parser::parse_capture_group(ByteCode& stack, size_t& match_length_mi
consume(TokenType::RightParen, Error::MismatchingParen);
stack.insert_bytecode_group_capture_left(name);
stack.insert_bytecode_group_capture_left(group_index);
stack.append(move(capture_group_bytecode));
stack.insert_bytecode_group_capture_right(name);
stack.insert_bytecode_group_capture_right(group_index);
match_length_minimum += length;
m_parser_state.named_capture_group_minimum_lengths.set(name, length);
m_parser_state.capture_group_minimum_lengths.set(group_index, length);
return true;
}