oxc-project / oxc

⚓ A collection of JavaScript tools written in Rust.
https://oxc.rs
MIT License
12.19k stars 440 forks source link

regular_expression: Improve ES2025 proposal-duplicate-named-capturing-groups logic #6358

Open leaysgur opened 2 months ago

leaysgur commented 2 months ago

Done in #6847 , but there is room for performance improvement.

Original issue > https://github.com/tc39/proposal-duplicate-named-capturing-groups Spec text is not updated yet, ongoing PR may be helpful. 👉🏻 https://github.com/tc39/ecma262/pull/2721 For now, `/(?.)(?.)/` is invalid syntax, name `a` is duplicated. With this change, we can use the same name if they are splitted by `|` and in the same `Disjunction` like `/(?.)|(?.)/`. But it still not allowed in some cases like `/(?|(?))/`, `/(?(?)|)/`, `/((?)|(?))(?)/`, etc... You need to track nesting level and `|` to mange scope. ### TODOs - [ ] Update count capturing parens logic to allow duplicates in certain cases - https://github.com/oxc-project/oxc/blob/aa7718ab7bf0544b21564658a919307022f8824a/crates/oxc_regular_expression/src/body_parser/state.rs#L51 - No need to change parser main logic - [ ] Update README - https://github.com/oxc-project/oxc/blob/aa7718ab7bf0544b21564658a919307022f8824a/crates/oxc_regular_expression/README.md - [ ] Update local tests - https://github.com/oxc-project/oxc/blob/aa7718ab7bf0544b21564658a919307022f8824a/crates/oxc_regular_expression/src/body_parser/mod.rs - [ ] Enable conformance tests - https://github.com/oxc-project/oxc/blob/aa7718ab7bf0544b21564658a919307022f8824a/tasks/coverage/src/test262/mod.rs#L103-L104
preyneyv commented 1 week ago

I'd like to take a stab at this!

Boshen commented 1 week ago

@preyneyv You may continue with https://github.com/oxc-project/oxc/pull/6847