regexp-tree icon indicating copy to clipboard operation
regexp-tree copied to clipboard

Compat transpiler: Implement Unicode property escapes

Open DmitrySoshnikov opened this issue 6 years ago • 3 comments

Example:

/\p{ASCII_Hex_Digit}/u

Compiles to:

/[0-9A-Fa-f]/

See example in https://mothereff.in/regexpu (@mathiasbynens)

DmitrySoshnikov avatar May 19 '19 06:05 DmitrySoshnikov

Given the complexity and large amounts of Unicode data involved, would it make sense to re-use the regexpu-core implementation for this?

I keep it up to date whenever Unicode updates, as well as the Test262 tests and V8 implementation.

mathiasbynens avatar May 19 '19 17:05 mathiasbynens

Perhaps -- depending on how large this dependency is. Currently I try to keep regexp-tree with no/minumum number of dependencies on external libraries. The tool has transformation API, so it's kinda weird to involve a separate transformation API/parser/etc. I'll need to take a closer look.

DmitrySoshnikov avatar May 19 '19 19:05 DmitrySoshnikov

I think it makes sense to have this transpiler be a separate regexp-tree plugin, in a separate repo + npm package (regardless of your decision to re-use regexpu-core or to do something else), for the reasons you describe.

FYI, the raw data (based on the Unicode data) lives in https://github.com/mathiasbynens/regenerate-unicode-properties. If you decide not to reuse regexpu-core perhaps you could still use this data.

mathiasbynens avatar May 20 '19 01:05 mathiasbynens