Skip to content

Commit 3c5ee21

Browse files
committed
Patched isCombiningMark to check Unicode space manually rather than relying on java.lang.Character.
1 parent 7d2ea29 commit 3c5ee21

File tree

6 files changed

+25
-4
lines changed

6 files changed

+25
-4
lines changed

bazel-bin

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/home/christian/.cache/bazel/_bazel_christian/104d3f45ba5206b8827c9e2fc4354936/execroot/com_google_javascript_jscomp/bazel-out/k8-fastbuild/bin

bazel-closure-compiler

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/home/christian/.cache/bazel/_bazel_christian/104d3f45ba5206b8827c9e2fc4354936/execroot/com_google_javascript_jscomp

bazel-out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/home/christian/.cache/bazel/_bazel_christian/104d3f45ba5206b8827c9e2fc4354936/execroot/com_google_javascript_jscomp/bazel-out

bazel-testlogs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/home/christian/.cache/bazel/_bazel_christian/104d3f45ba5206b8827c9e2fc4354936/execroot/com_google_javascript_jscomp/bazel-out/k8-fastbuild/testlogs

src/com/google/javascript/jscomp/parsing/parser/Scanner.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.javascript.jscomp.parsing.parser.util.SourcePosition;
2424
import com.google.javascript.jscomp.parsing.parser.util.SourceRange;
2525
import java.util.ArrayList;
26+
import java.lang.Character;
2627
import javax.annotation.Nullable;
2728

2829
/**
@@ -901,11 +902,24 @@ private static boolean isIdentifierStart(char ch) {
901902
| (ch >= 0x03B1 & ch <= 0x03C9); // Greek lowercase letters
902903
}
903904

904-
/**
905-
Implement ECMAScript grammar for isIdentifierPart.
906-
*/
905+
// Check if char is Unicode Category "Combining spacing mark (Mc)"
906+
// This list is not exhaustive!
907+
@SuppressWarnings("ShortCircuitBoolean") // Intentional to minimize branches in this code
907908
private static boolean isCombiningMark(char ch) {
908-
return Character.getType(ch) == Character.NON_SPACING_MARK;
909+
return (
910+
// 0300-036F
911+
(0x0300 <= ch & ch <= 0x036F) |
912+
// 1AB0–1AFF
913+
(0x1AB0 <= ch & ch <= 0x1AFF) |
914+
// 1DC0–1DFF
915+
(0x1DC0 <= ch & ch <= 0x1DFF) |
916+
// 20D0–20FF
917+
(0x20D0 <= ch & ch <= 0x20FF) |
918+
// FE20–FE2F
919+
(0xFE20 <= ch & ch <= 0xFE2F)
920+
);
921+
// TODO (ctjl): Implement in a more reliable and future-proofed way, i.e.:
922+
// return Character.getType(ch) == Character.NON_SPACING_MARK;
909923
}
910924

911925
// TODO (ctjl): Implement

test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var bar = {
2+
: "foo"
3+
};

0 commit comments

Comments
 (0)