Skip to content

Commit 3f45112

Browse files
committed
TM: Highlight path, fix integer literals, match generic params for variable/const.
1 parent 15f3f74 commit 3f45112

File tree

2 files changed

+49
-16
lines changed

2 files changed

+49
-16
lines changed

syntaxes/c3.tmLanguage.json

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
},
7272
{
7373
"match": "(?:_*[a-z][_a-zA-Z0-9]*)",
74-
"name": "meta.path.c3"
74+
"name": "meta.path.c3 entity.name.scope-resolution.c3"
7575
},
7676
{
7777
"include": "#generic_params"
@@ -103,7 +103,7 @@
103103
},
104104
{
105105
"match": "(?:_*[a-z][_a-zA-Z0-9]*)",
106-
"name": "meta.path.c3"
106+
"name": "meta.path.c3 entity.name.scope-resolution.c3"
107107
},
108108
{
109109
"match": ",",
@@ -865,8 +865,18 @@
865865
"name": "constant.language.c3"
866866
},
867867
{
868-
"match": "\\b(?:_*[A-Z][_A-Z0-9]*)\\b",
869-
"name": "variable.other.constant"
868+
"begin": "\\b(?:_*[A-Z][_A-Z0-9]*)\\b",
869+
"beginCaptures": {
870+
"0": {
871+
"name": "variable.other.constant.c3"
872+
}
873+
},
874+
"end": "(?=[^{\\s])|(?<=\\})",
875+
"patterns": [
876+
{
877+
"include": "#generic_params"
878+
}
879+
]
870880
}
871881
]
872882
},
@@ -918,7 +928,7 @@
918928
"match": "((?:_*[a-z][_a-zA-Z0-9]*))(::)",
919929
"captures": {
920930
"1": {
921-
"name": "meta.path.c3"
931+
"name": "meta.path.c3 entity.name.scope-resolution.c3"
922932
},
923933
"2": {
924934
"name": "meta.path.c3 punctuation.separator.scope-resolution.c3"
@@ -1027,7 +1037,7 @@
10271037
]
10281038
},
10291039
"integer_literal": {
1030-
"match": "\\b(?:[0-9](?:_?[0-9])*|0[xX][a-fA-F0-9](?:_?[a-fA-F0-9])*|0[oO][0-7](_?[0-7])*|0[bB][0-1](_?[0-1])*)(?:[ui](?:8|16|32|64|128)|[Uu][Ll]?|[Ll])?",
1040+
"match": "\\b(?:0[xX][a-fA-F0-9](?:_?[a-fA-F0-9])*|0[oO][0-7](_?[0-7])*|0[bB][0-1](_?[0-1])*|[0-9](?:_?[0-9])*)(?:[ui](?:8|16|32|64|128)|[Uu][Ll]?|[Ll])?",
10311041
"name": "constant.numeric.integer.c3"
10321042
},
10331043
"bytes_literal": {
@@ -1481,8 +1491,18 @@
14811491
]
14821492
},
14831493
"variable": {
1484-
"match": "(?<!#)\\$?\\b(?:_*[a-z][_a-zA-Z0-9]*)\\b",
1485-
"name": "variable.other.c3"
1494+
"begin": "(?<!#)\\$?\\b(?:_*[a-z][_a-zA-Z0-9]*)\\b",
1495+
"beginCaptures": {
1496+
"0": {
1497+
"name": "variable.other.c3"
1498+
}
1499+
},
1500+
"end": "(?=[^{\\s])|(?<=\\})",
1501+
"patterns": [
1502+
{
1503+
"include": "#generic_params"
1504+
}
1505+
]
14861506
},
14871507
"expression": {
14881508
"patterns": [

syntaxes/c3.tmLanguage.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ repository:
4343
- include: "#attribute"
4444
- include: "#path"
4545
- match: '{{IDENT}}'
46-
name: meta.path.c3
46+
name: meta.path.c3 entity.name.scope-resolution.c3
4747
- include: "#generic_params"
4848

4949
# Import
@@ -58,7 +58,7 @@ repository:
5858
- include: "#attribute"
5959
- include: "#path"
6060
- match: '{{IDENT}}'
61-
name: meta.path.c3
61+
name: meta.path.c3 entity.name.scope-resolution.c3
6262
- match: ','
6363
name: punctuation.separator.c3
6464

@@ -427,8 +427,15 @@ repository:
427427
patterns:
428428
- match: '\b(true|false|null)\b'
429429
name: constant.language.c3
430-
- match: '\b{{CONST}}\b'
431-
name: variable.other.constant
430+
# - match: '\b{{CONST}}\b'
431+
# name: variable.other.constant
432+
- begin: '\b{{CONST}}\b'
433+
beginCaptures: {
434+
0: { name: variable.other.constant.c3 }
435+
}
436+
end: '(?=[^{\s])|(?<=\})'
437+
patterns:
438+
- include: "#generic_params"
432439

433440
operators:
434441
patterns:
@@ -456,7 +463,7 @@ repository:
456463
path:
457464
match: '({{IDENT}})(::)'
458465
captures:
459-
1: { name: meta.path.c3 }
466+
1: { name: meta.path.c3 entity.name.scope-resolution.c3 }
460467
2: { name: meta.path.c3 punctuation.separator.scope-resolution.c3 }
461468

462469
literals:
@@ -514,7 +521,7 @@ repository:
514521
name: constant.numeric.float.c3
515522

516523
integer_literal:
517-
match: '\b(?:{{INT}}|0[xX]{{HINT}}|0[oO]{{OINT}}|0[bB]{{BINT}}){{INTTYPE}}?'
524+
match: '\b(?:0[xX]{{HINT}}|0[oO]{{OINT}}|0[bB]{{BINT}}|{{INT}}){{INTTYPE}}?'
518525
name: constant.numeric.integer.c3
519526

520527
bytes_literal:
@@ -753,8 +760,14 @@ repository:
753760
- include: "#expression"
754761

755762
variable:
756-
match: '(?<!#)\$?\b{{IDENT}}\b'
757-
name: variable.other.c3
763+
# match: '(?<!#)\$?\b{{IDENT}}\b'
764+
# name: variable.other.c3
765+
begin: '(?<!#)\$?\b{{IDENT}}\b'
766+
beginCaptures:
767+
0: { name: variable.other.c3 }
768+
end: '(?=[^{\s])|(?<=\})'
769+
patterns:
770+
- include: "#generic_params"
758771

759772
expression:
760773
patterns:

0 commit comments

Comments
 (0)