-
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: skip ascii symbol in process #31
fix: skip ascii symbol in process #31
Conversation
It would be good to have a test with |
@nicolo-ribaudo Good question! This PR does not touch Currently, every items in CharacterClass is added to a single regenerate set so that we can perform possible code range concatenations. However, the regenerate lacks of the token information: i.e. the |
Did you see #16? |
Sorry I didn't see #16 before. What's happening in #16 is that However, when |
I'm okay with making But let’s keep the behavior for other ASCII symbols (in particular, non-printable ones) as-is. |
rewrite-pattern.js
Outdated
@@ -256,6 +256,10 @@ const processTerm = (item, regenerateOptions, groups) => { | |||
break; | |||
case 'value': | |||
const codePoint = item.codePoint; | |||
if (item.kind === "symbol" && codePoint >= 0x20 && codePoint <= 0x7E) { |
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.
Let's keep this as codePoint == 0x2D
, since many ascii symbols must be escaped: [
, {
, |
, +
, ?
, *
, $
, ...
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.
Escaped character, i.e. \[
is identifier
kind instead of symbol
kind. If regjsparser
parses it safely as symbol
, we don't have to escape it.
This is how /\{/
will be parsed:
{
"type": "value",
"kind": "identifier",
"codePoint": 123,
"range": [
0,
2
],
"raw": "\\{"
}
9afeddb
to
a710f04
Compare
The CI error is fixed in #81. |
@JLHwung could you rebase? |
a710f04
to
572314f
Compare
572314f
to
e7739a1
Compare
In this PR we skip the
processItem
when it is asymbol
-kind and has code point within ASCII range.This fix will prevent
-
transpiled as\\x2D
when it is not in character class. Besides that, it should speed up a little bit since ASCII symbols are pretty common.