LibRegex: Make the optimizer understand references and capture groups

Otherwise the fork in patterns like `(1+)\1` would be (incorrectly)
optimized away.
This commit is contained in:
Ali Mohammad Pur 2021-09-15 14:31:55 +04:30 committed by Ali Mohammad Pur
commit 741886a4c4
Notes: sideshowbarker 2024-07-18 03:56:56 +09:00
2 changed files with 23 additions and 2 deletions

View file

@ -898,6 +898,10 @@ TEST_CASE(optimizer_atomic_groups)
// Alternative fuse
Tuple { "(abcfoo|abcbar|abcbaz).*x"sv, "abcbarx"sv, true },
Tuple { "(a|a)"sv, "a"sv, true },
// ForkReplace shouldn't be applied where it would change the semantics
Tuple { "(1+)\\1"sv, "11"sv, true },
Tuple { "(1+)1"sv, "11"sv, true },
Tuple { "(1+)0"sv, "10"sv, true },
};
for (auto& test : tests) {