DmitrySoshnikov / regexp-tree

Regular expressions processor in JavaScript
MIT License
401 stars 43 forks source link

Compat transpiler: Implement Unicode property escapes #179

Open DmitrySoshnikov opened 5 years ago

DmitrySoshnikov commented 5 years ago

Example:

/\p{ASCII_Hex_Digit}/u

Compiles to:

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

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

mathiasbynens commented 5 years ago

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.

DmitrySoshnikov commented 5 years ago

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.

mathiasbynens commented 5 years ago

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.