-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix case-insensitive set operations #104
Conversation
Can we do some sort of minification? i.e. if there is the |
To do the minification for all unicode codepoints we will need the regexpu-core/scripts/case-mappings.js Lines 100 to 113 in f745fbe
which matches uppercase to lowercase (loosely speaking). This mapping is not yet exposed as data. Currently we only have map from character to its unicode case-insensitive equivalents: we don't know which one is "lowercase" and thus should be minified to. If we expose this mapping, then I can just implement the |
In spec, caseFold refers to mapping uppercase letter to the lowercase, here we are actually adding case equivalents to any given set of characters, such that they map to the same character via scf(). To avoid confusion, rename caseFold to caseEquivalents.
This PR is ready for preview. I plan to cut a new minor release (because of #98) after this PR gets merged. |
|
||
ESCAPE_CHARS_UNICODESET_IGNORE_CASE[upper] = { | ||
toCode() { | ||
return 'UNICODE_IV_SET.clone().remove(' + ESCAPE_CHARS_UNICODESET_IGNORE_CASE[lower].toCode() + ')'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we override the toCode
prototype method for a much smaller output.
…F to nested class
The matches are already tested in unicode-set.js
Thanks! |
Fixes #103.
In this PR we applied
scf()
on the class set operand before doing any set operations.We also maintain the
config.modifiersData
even when we are not transforming modifiers, as more and more features will depend on this context data.In this PR we add unicode case equivalents before we are computing the intersection / substraction. The spec appliesMaybeSimpleCaseFolding
to every character (loosely like toLowerCase) while we are actually adding unicode case equivalents to every character. I think there is an equivalence relationship between the canonical form (e.g.k
) and the set of its case equivalents (e.g.{k, K, \u212A}
), so the regex behaviour should not be changed.The cons is that we are generating longer than necessary output when the matcher set contains both uppercase / lowercase letters within the i modifier.