Skip to content

Commit 734825e

Browse files
committed
TM: remote function body scope, include all statements at top level
1 parent d36da88 commit 734825e

File tree

2 files changed

+36
-78
lines changed

2 files changed

+36
-78
lines changed

syntaxes/c3.tmLanguage.json

Lines changed: 20 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"patterns": [
1111
{
1212
"include": "#top_level"
13+
},
14+
{
15+
"include": "#statements"
1316
}
1417
],
1518
"repository": {
@@ -151,7 +154,7 @@
151154
"include": "#attribute"
152155
},
153156
{
154-
"begin": "\\=",
157+
"begin": "=",
155158
"beginCaptures": {
156159
"0": {
157160
"name": "keyword.operator.assignment.c3"
@@ -202,7 +205,7 @@
202205
"include": "#attribute"
203206
},
204207
{
205-
"begin": "\\=",
208+
"begin": "=",
206209
"beginCaptures": {
207210
"0": {
208211
"name": "keyword.operator.assignment.c3"
@@ -327,7 +330,7 @@
327330
"include": "#comments"
328331
},
329332
{
330-
"begin": "\\=",
333+
"begin": "=",
331334
"beginCaptures": {
332335
"0": {
333336
"name": "keyword.operator.assignment.c3"
@@ -417,7 +420,7 @@
417420
"include": "#attribute"
418421
},
419422
{
420-
"begin": "\\=",
423+
"begin": "=",
421424
"beginCaptures": {
422425
"0": {
423426
"name": "keyword.operator.assignment.c3"
@@ -495,7 +498,7 @@
495498
]
496499
},
497500
{
498-
"begin": "\\=",
501+
"begin": "=",
499502
"beginCaptures": {
500503
"0": {
501504
"name": "keyword.operator.assignment.c3"
@@ -582,7 +585,7 @@
582585
"function_header": {
583586
"patterns": [
584587
{
585-
"include": "#type"
588+
"include": "#type_no_generics"
586589
},
587590
{
588591
"match": "\\.",
@@ -596,7 +599,7 @@
596599
},
597600
"function": {
598601
"begin": "(?=\\b(fn|macro)\\b)",
599-
"end": "(?<=\\})|(?=[;,)])",
602+
"end": "(?=[={;])",
600603
"patterns": [
601604
{
602605
"begin": "\\b(fn|macro)\\b",
@@ -648,41 +651,6 @@
648651
"include": "#attribute"
649652
}
650653
]
651-
},
652-
{
653-
"begin": "\\{",
654-
"beginCaptures": {
655-
"0": {
656-
"name": "meta.function.c3 meta.block.c3 punctuation.section.block.begin.c3"
657-
}
658-
},
659-
"end": "\\}",
660-
"endCaptures": {
661-
"0": {
662-
"name": "meta.function.c3 meta.block.c3 punctuation.section.block.end.c3"
663-
}
664-
},
665-
"contentName": "meta.function.c3 meta.block.c3",
666-
"patterns": [
667-
{
668-
"include": "#statements"
669-
}
670-
]
671-
},
672-
{
673-
"begin": "\\=>",
674-
"beginCaptures": {
675-
"0": {
676-
"name": "meta.function.c3 keyword.declaration.function.arrow.c3"
677-
}
678-
},
679-
"end": "(?=[;,){])",
680-
"contentName": "meta.function.c3",
681-
"patterns": [
682-
{
683-
"include": "#expression"
684-
}
685-
]
686654
}
687655
]
688656
},
@@ -902,11 +870,15 @@
902870
"operators": {
903871
"patterns": [
904872
{
905-
"match": "\\+\\=|-\\=|\\*\\=|/\\=|%\\=|&\\=|\\|\\=|\\^\\=|>>\\=|<<\\=",
873+
"match": "=>",
874+
"name": "keyword.declaration.function.arrow.c3"
875+
},
876+
{
877+
"match": "\\+=|-=|\\*=|/=|%=|&=|\\|=|\\^=|>>=|<<=",
906878
"name": "keyword.operator.assignment.augmented.c3"
907879
},
908880
{
909-
"match": "<\\=|>\\=|\\=\\=|<|>|\\!\\=",
881+
"match": "<=|>=|==|<|>|\\!=",
910882
"name": "keyword.operator.comparison.c3"
911883
},
912884
{
@@ -930,7 +902,7 @@
930902
"name": "keyword.operator.arithmetic.c3"
931903
},
932904
{
933-
"match": "\\=",
905+
"match": "=",
934906
"name": "keyword.operator.assignment.c3"
935907
},
936908
{
@@ -1405,7 +1377,7 @@
14051377
"include": "#attribute"
14061378
},
14071379
{
1408-
"begin": "\\=",
1380+
"begin": "=",
14091381
"beginCaptures": {
14101382
"0": {
14111383
"name": "keyword.operator.assignment.c3"
@@ -1791,7 +1763,7 @@
17911763
"include": "#attribute"
17921764
},
17931765
{
1794-
"begin": "\\=",
1766+
"begin": "=",
17951767
"beginCaptures": {
17961768
"0": {
17971769
"name": "keyword.operator.assignment.c3"
@@ -1869,7 +1841,7 @@
18691841
"name": "keyword.operator.variadic.c3"
18701842
},
18711843
{
1872-
"begin": "\\=",
1844+
"begin": "=",
18731845
"beginCaptures": {
18741846
"0": {
18751847
"name": "keyword.operator.assignment.c3"

syntaxes/c3.tmLanguage.yml

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ scopeName: source.c3
1010

1111
patterns:
1212
- include: "#top_level"
13+
- include: "#statements"
1314

1415
repository:
1516
top_level:
@@ -83,7 +84,7 @@ repository:
8384
patterns:
8485
- include: "#comments"
8586
- include: "#attribute"
86-
- begin: \=
87+
- begin: '='
8788
beginCaptures:
8889
0: { name: keyword.operator.assignment.c3 }
8990
end: (?=;)
@@ -104,7 +105,7 @@ repository:
104105
patterns:
105106
- include: "#comments"
106107
- include: "#attribute"
107-
- begin: \=
108+
- begin: '='
108109
beginCaptures:
109110
0: { name: keyword.operator.assignment.c3 }
110111
end: (?=;)
@@ -164,7 +165,7 @@ repository:
164165
contentName: meta.enum.body.c3 meta.block.c3
165166
patterns:
166167
- include: "#comments"
167-
- begin: \=
168+
- begin: '='
168169
beginCaptures:
169170
0: { name: keyword.operator.assignment.c3 }
170171
end: (?=,)
@@ -207,7 +208,7 @@ repository:
207208
patterns:
208209
- include: "#comments"
209210
- include: "#attribute"
210-
- begin: \=
211+
- begin: '='
211212
beginCaptures:
212213
0: { name: keyword.operator.assignment.c3 }
213214
end: (?=;)
@@ -243,7 +244,7 @@ repository:
243244
contentName: meta.attrdef.parameters.c3 meta.group.c3
244245
patterns:
245246
- include: "#parameters"
246-
- begin: \=
247+
- begin: '='
247248
beginCaptures:
248249
0: { name: keyword.operator.assignment.c3 }
249250
end: (?=;)
@@ -286,15 +287,15 @@ repository:
286287

287288
function_header:
288289
patterns:
289-
- include: "#type"
290+
- include: "#type_no_generics"
290291
- match: '\.'
291292
name: punctuation.accessor.c3
292293
- match: '\@?{{IDENT}}'
293294
name: entity.name.function.c3
294295

295296
function:
296297
begin: (?=\b(fn|macro)\b)
297-
end: (?<=\})|(?=[;,)])
298+
end: (?=[={;])
298299
patterns:
299300
# Before parameters
300301
- begin: \b(fn|macro)\b
@@ -322,23 +323,6 @@ repository:
322323
patterns:
323324
- include: "#comments"
324325
- include: "#attribute"
325-
# Function body
326-
- begin: \{
327-
beginCaptures:
328-
0: { name: meta.function.c3 meta.block.c3 punctuation.section.block.begin.c3 }
329-
end: \}
330-
endCaptures:
331-
0: { name: meta.function.c3 meta.block.c3 punctuation.section.block.end.c3 }
332-
contentName: meta.function.c3 meta.block.c3
333-
patterns:
334-
- include: "#statements"
335-
- begin: \=>
336-
beginCaptures:
337-
0: { name: meta.function.c3 keyword.declaration.function.arrow.c3 }
338-
end: '(?=[;,){])'
339-
contentName: meta.function.c3
340-
patterns:
341-
- include: "#expression"
342326

343327
structlike:
344328
begin: '(?=\b(?:(struct|bitstruct)|(union))\b)'
@@ -448,9 +432,11 @@ repository:
448432

449433
operators:
450434
patterns:
451-
- match: '\+\=|-\=|\*\=|/\=|%\=|&\=|\|\=|\^\=|>>\=|<<\='
435+
- match: '=>'
436+
name: keyword.declaration.function.arrow.c3
437+
- match: '\+=|-=|\*=|/=|%=|&=|\|=|\^=|>>=|<<='
452438
name: keyword.operator.assignment.augmented.c3
453-
- match: '<\=|>\=|\=\=|<|>|\!\='
439+
- match: '<=|>=|==|<|>|\!='
454440
name: keyword.operator.comparison.c3
455441
- match: '\.\.\.'
456442
name: keyword.operator.variadic.c3
@@ -462,7 +448,7 @@ repository:
462448
name: keyword.operator.arithmetic.c3
463449
- match: '\+|\-|/|%|\||\^|~'
464450
name: keyword.operator.arithmetic.c3
465-
- match: '\='
451+
- match: '='
466452
name: keyword.operator.assignment.c3
467453
- match: '!|\?[?:]?|\*|&|:'
468454
name: keyword.operator.c3
@@ -719,7 +705,7 @@ repository:
719705
- match: '\b{{CONST}}\b'
720706
name: variable.other.constant.c3
721707
- include: "#attribute"
722-
- begin: \=
708+
- begin: '='
723709
beginCaptures:
724710
0: { name: keyword.operator.assignment.c3 }
725711
end: (?=;)
@@ -910,7 +896,7 @@ repository:
910896
- include: "#comments"
911897
- include: "#attribute"
912898
# CT type parameter with default value
913-
- begin: '\='
899+
- begin: '='
914900
beginCaptures:
915901
0 : { name: keyword.operator.assignment.c3 }
916902
end: '(?=[;,)])'
@@ -947,7 +933,7 @@ repository:
947933
- match: '\.\.\.'
948934
name: keyword.operator.variadic.c3
949935
# Parameter with default value
950-
- begin: '\='
936+
- begin: '='
951937
beginCaptures:
952938
0 : { name: keyword.operator.assignment.c3 }
953939
end: '(?=[;,)])'

0 commit comments

Comments
 (0)