mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
LibRegex: Consider named capture groups as normal capture groups too
This commit is contained in:
committed by
Andreas Kling
parent
be0182d049
commit
1bdc1cf77e
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user