Skip to content

Commit 90a9649

Browse files
committed
Fix identifier end handling & ident itself can now use IDC and IDS! #72, #73
1 parent c387ea7 commit 90a9649

1 file changed

Lines changed: 30 additions & 36 deletions

File tree

ecmascript.sublime-syntax

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ variables:
2828
MAT_word_or_any_one_char: '\w+|\S'
2929
PLA_anything: '(?=[\S\s])'
3030

31-
# UNICODE PROPERTY CLASS SHIMS ###############################################
32-
ID_Continue: '{{ID_Start}}\p{Mn}\p{Mc}\p{Nd}\p{Pc}{{Other_ID_Continue}}'
33-
ID_Start: '\p{L}\p{Nl}{{Other_ID_Start}}'
34-
Other_ID_Continue: '··፩-፱᧚'
35-
Other_ID_Start: '℘℮゛゜'
36-
3731
# OTHER CHARACTER GROUPS #####################################################
3832
boxchars: '[─-╿▀-▟]+'
3933
whiteNoLine: '[\s&&[^\n\r]]+'
@@ -56,35 +50,35 @@ variables:
5650
keywordOther: >-
5751
Infinity | NaN | undefined
5852
reservedWords: >-
59-
{{keywordLanguage}}|
60-
{{keywordReserved}}|
61-
{{keywordLiteral}}|
62-
{{keywordOther}}
53+
(?:
54+
{{keywordLanguage}}|
55+
{{keywordReserved}}|
56+
{{keywordLiteral}}|
57+
{{keywordOther}}
58+
)
6359
6460
# IDENTIFIERS ################################################################
6561
identifier: >-
6662
(?x)
67-
(?! (?:{{reservedWords}})
68-
[^\$_‍‍{{ID_Continue}}] )
69-
(?<![{{ID_Continue}}])
63+
(?!{{reservedWords}}{{idEnd}})
64+
(?<![{{identifierContinueChars}}\\])
7065
{{identifierName}}
71-
identifierInitCap: '(?:\p{Lu}{{identifierPart}}){{idEnd}}'
66+
identifierInitCap: '(?:\p{Lu}{{identifierPart}}+){{idEnd}}'
7267
identifierInitCapStrict: >-
7368
(?x)
74-
(?! (?:{{reservedWords}})
75-
[^\$_‍‍{{ID_Continue}}] )
76-
(?<![{{ID_Continue}}])
69+
(?!{{reservedWords}}{{idEnd}})
70+
(?<![{{identifierContinueChars}}\\])
7771
{{identifierInitCap}}
7872
identifierAllCaps: '(?:[\p{Lu}\d_]{2,}|\p{Lu}){{idEnd}}'
7973
identifierAllCapsStrict: >-
8074
(?x)
81-
(?! (?:{{reservedWords}})
82-
[^\$_‍‍{{ID_Continue}}] )
83-
(?<![{{ID_Continue}}])
75+
(?!{{reservedWords}}{{idEnd}})
76+
(?<![{{identifierContinueChars}}\\])
8477
{{identifierAllCaps}}
85-
identifierName: '{{identifierStart}}{{identifierPart}}'
86-
identifierPart: '(?:[\$_‍‍{{ID_Continue}}]|{{unicodeEscape}})*' # ZWN?J after _
87-
identifierStart: '(?:[\$_{{ID_Start}}]|{{unicodeEscape}})'
78+
identifierName: '{{identifierStart}}{{identifierPart}}*'
79+
identifierContinueChars: '\p{IDS}$\x{200C}\x{200D}'
80+
identifierPart: '(?:[{{identifierContinueChars}}]|{{unicodeEscape}})'
81+
identifierStart: '(?:[\p{IDS}$_]|{{unicodeEscape}})'
8882
allThreeIDs: '({{identifierAllCaps}})|({{identifierInitCap}})|({{identifier}})'
8983
unicodeEscape: '\\u(?:\h{4}|\{\h+\})'
9084
jsxComponentIdentifier: '{{identifierInitCapStrict}}'
@@ -124,7 +118,7 @@ variables:
124118
hexNum: '(0[Xx])(?:\h+(?:_+\h+)*)(n)?'
125119

126120
# LOOKAHEADS #################################################################
127-
idEnd: '(?=[^\$_‍‍{{ID_Continue}}]|$)'
121+
idEnd: '(?=[^{{identifierContinueChars}}\\]|$)'
128122

129123
# SYNTAX DIRECTIVES ##########################################################
130124
syntaxDirectiveHead: '(\s*syntax\s*:\s*)'
@@ -2580,22 +2574,22 @@ contexts:
25802574
# totally reasonable to scope them as such since this odd fact is just a bit
25812575
# of legacy bs. In modern implementions they can’t be redefined (although
25822576
# the assignment is itself a legal operation, fun fact).
2583-
- match: 'NaN(?![{{ID_Continue}}])'
2577+
- match: 'NaN(?!{{identifierPart}})'
25842578
scope: constant.language.nan.es
25852579
set: ae_AFTER_VALUE
2586-
- match: 'null(?![{{ID_Continue}}])'
2580+
- match: 'null(?!{{identifierPart}})'
25872581
scope: constant.language.null.es
25882582
set: ae_AFTER_VALUE
2589-
- match: 'true(?![{{ID_Continue}}])'
2583+
- match: 'true(?!{{identifierPart}})'
25902584
scope: constant.language.boolean.true.es
25912585
set: ae_AFTER_VALUE
2592-
- match: 'false(?![{{ID_Continue}}])'
2586+
- match: 'false(?!{{identifierPart}})'
25932587
scope: constant.language.boolean.false.es
25942588
set: ae_AFTER_VALUE
2595-
- match: 'Infinity(?![{{ID_Continue}}])'
2589+
- match: 'Infinity(?!{{identifierPart}})'
25962590
scope: constant.language.infinity.es
25972591
set: ae_AFTER_VALUE
2598-
- match: 'undefined(?![{{ID_Continue}}])'
2592+
- match: 'undefined(?!{{identifierPart}})'
25992593
scope: constant.language.undefined.es
26002594
set: ae_AFTER_VALUE
26012595

@@ -3334,22 +3328,22 @@ contexts:
33343328
scope: keyword.operator.assignment.augmented.bitwise.shift.right.es
33353329
set: assignmentExpression_NO_IN
33363330
ae_NO_IN_LITERAL_VALUES:
3337-
- match: 'NaN(?![{{ID_Continue}}])'
3331+
- match: 'NaN(?!{{identifierPart}})'
33383332
scope: constant.language.nan.es
33393333
set: ae_NO_IN_AFTER_VALUE
3340-
- match: 'null(?![{{ID_Continue}}])'
3334+
- match: 'null(?!{{identifierPart}})'
33413335
scope: constant.language.null.es
33423336
set: ae_NO_IN_AFTER_VALUE
3343-
- match: 'true(?![{{ID_Continue}}])'
3337+
- match: 'true(?!{{identifierPart}})'
33443338
scope: constant.language.boolean.true.es
33453339
set: ae_NO_IN_AFTER_VALUE
3346-
- match: 'false(?![{{ID_Continue}}])'
3340+
- match: 'false(?!{{identifierPart}})'
33473341
scope: constant.language.boolean.false.es
33483342
set: ae_NO_IN_AFTER_VALUE
3349-
- match: 'Infinity(?![{{ID_Continue}}])'
3343+
- match: 'Infinity(?!{{identifierPart}})'
33503344
scope: constant.language.infinity.es
33513345
set: ae_NO_IN_AFTER_VALUE
3352-
- match: 'undefined(?![{{ID_Continue}}])'
3346+
- match: 'undefined(?!{{identifierPart}})'
33533347
scope: constant.language.undefined.es
33543348
set: ae_NO_IN_AFTER_VALUE
33553349
ae_NO_IN_NUMBERS:

0 commit comments

Comments
 (0)