Skip to content

Commit 801df0d

Browse files
committed
TM: Fix function calls with generic args, named args, block precedence
1 parent 2eeee30 commit 801df0d

File tree

2 files changed

+46
-28
lines changed

2 files changed

+46
-28
lines changed

syntaxes/c3.tmLanguage.json

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,7 @@
13461346
"name": "punctuation.terminator.c3"
13471347
}
13481348
},
1349+
"name": "meta.declaration.c3",
13491350
"patterns": [
13501351
{
13511352
"match": "\\$(?:_*[A-Z][_A-Z0-9]*[a-z][_a-zA-Z0-9]*)",
@@ -1362,7 +1363,8 @@
13621363
"endCaptures": {
13631364
"0": {
13641365
"name": "punctuation.terminator.c3"
1365-
}
1366+
},
1367+
"name": "meta.declaration.c3"
13661368
},
13671369
"patterns": [
13681370
{
@@ -1384,6 +1386,7 @@
13841386
"name": "punctuation.terminator.c3"
13851387
}
13861388
},
1389+
"name": "meta.declaration.c3",
13871390
"patterns": [
13881391
{
13891392
"include": "#type"
@@ -1400,16 +1403,13 @@
14001403
{
14011404
"include": "#comments"
14021405
},
1403-
{
1404-
"include": "#generic_params"
1405-
},
14061406
{
14071407
"match": "(?<!#)\\$?\\b(?:_*[a-z][_a-zA-Z0-9]*)\\b",
1408-
"name": "variable.other.c3"
1408+
"name": "variable.other.declaration.c3"
14091409
},
14101410
{
14111411
"match": "\\b(?:_*[A-Z][_A-Z0-9]*)\\b",
1412-
"name": "variable.other.constant"
1412+
"name": "variable.other.constant.declaration.c3"
14131413
},
14141414
{
14151415
"include": "#attribute"
@@ -1579,10 +1579,10 @@
15791579
"include": "#declaration"
15801580
},
15811581
{
1582-
"include": "#expression"
1582+
"include": "#block"
15831583
},
15841584
{
1585-
"include": "#block"
1585+
"include": "#expression"
15861586
}
15871587
]
15881588
},
@@ -1634,9 +1634,6 @@
16341634
{
16351635
"include": "#brackets"
16361636
},
1637-
{
1638-
"include": "#expression_block"
1639-
},
16401637
{
16411638
"include": "#initializer_list"
16421639
},
@@ -1646,7 +1643,7 @@
16461643
]
16471644
},
16481645
"function_call": {
1649-
"begin": "([@#]?(?:_*[a-z][_a-zA-Z0-9]*))(?=\\s*\\((?!<))",
1646+
"begin": "([@#]?(?:_*[a-z][_a-zA-Z0-9]*)\\b)(?=\\s*(\\{.*\\})?\\s*\\()",
16501647
"beginCaptures": {
16511648
"1": {
16521649
"name": "entity.name.function.c3"
@@ -1659,6 +1656,9 @@
16591656
}
16601657
},
16611658
"patterns": [
1659+
{
1660+
"include": "#generic_params"
1661+
},
16621662
{
16631663
"begin": "\\(",
16641664
"beginCaptures": {
@@ -1673,13 +1673,24 @@
16731673
"include": "#comments"
16741674
},
16751675
{
1676-
"match": "(?<=[(\\s,])(\\.)([$#]?(?:_*[a-z][_a-zA-Z0-9]*))",
1676+
"match": "([$#]?(?:_*[a-z][_a-zA-Z0-9]*))\\s*(:(?!:))",
16771677
"captures": {
16781678
"1": {
1679-
"name": "punctuation.separator.c3"
1679+
"name": "variable.parameter.c3"
16801680
},
16811681
"2": {
1682+
"name": "punctuation.separator.c3"
1683+
}
1684+
}
1685+
},
1686+
{
1687+
"match": "(\\$(?:_*[A-Z][_A-Z0-9]*[a-z][_a-zA-Z0-9]*))\\s*(:(?!:))",
1688+
"captures": {
1689+
"1": {
16821690
"name": "variable.parameter.c3"
1691+
},
1692+
"2": {
1693+
"name": "punctuation.separator.c3"
16831694
}
16841695
}
16851696
},
@@ -1700,13 +1711,13 @@
17001711
"block": {
17011712
"patterns": [
17021713
{
1703-
"begin": "\\{(?!\\|)",
1714+
"begin": "\\{",
17041715
"beginCaptures": {
17051716
"0": {
17061717
"name": "meta.block.c3 punctuation.section.block.begin.c3"
17071718
}
17081719
},
1709-
"end": "(?<!\\|)\\}",
1720+
"end": "\\}",
17101721
"endCaptures": {
17111722
"0": {
17121723
"name": "meta.block.c3 punctuation.section.block.end.c3"
@@ -1893,7 +1904,7 @@
18931904
"name": "meta.block.c3 punctuation.section.block.end.c3"
18941905
}
18951906
},
1896-
"contentName": "meta.block.c3",
1907+
"contentName": "meta.block.c3 meta.initializer_list.c3",
18971908
"patterns": [
18981909
{
18991910
"include": "#expression"

syntaxes/c3.tmLanguage.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ repository:
691691
end: ;
692692
endCaptures:
693693
0: { name: punctuation.terminator.c3 }
694+
name: 'meta.declaration.c3'
694695
patterns:
695696
# CT type
696697
- match: '\${{TYPE}}'
@@ -700,6 +701,7 @@ repository:
700701
end: ;
701702
endCaptures:
702703
0: { name: punctuation.terminator.c3 }
704+
name: 'meta.declaration.c3'
703705
patterns:
704706
- include: "#type"
705707
- include: "#declaration_after_type"
@@ -708,18 +710,19 @@ repository:
708710
end: ;
709711
endCaptures:
710712
0: { name: punctuation.terminator.c3 }
713+
name: 'meta.declaration.c3'
711714
patterns:
712715
- include: "#type"
713716
- include: "#declaration_after_type"
714717

715718
declaration_after_type:
716719
patterns:
717720
- include: "#comments"
718-
- include: "#generic_params"
721+
#- include: "#generic_params"
719722
- match: '(?<!#)\$?\b{{IDENT}}\b'
720723
name: variable.other.c3
721724
- match: '\b{{CONST}}\b'
722-
name: variable.other.constant
725+
name: variable.other.constant.c3
723726
- include: "#attribute"
724727
- begin: \=
725728
beginCaptures:
@@ -801,8 +804,8 @@ repository:
801804
- include: "#control_statements"
802805

803806
- include: "#declaration"
804-
- include: "#expression"
805807
- include: "#block"
808+
- include: "#expression"
806809

807810
variable:
808811
match: '(?<!#)\$?\b{{IDENT}}\b'
@@ -829,19 +832,19 @@ repository:
829832

830833
- include: "#parens"
831834
- include: "#brackets"
832-
- include: "#expression_block"
833835
- include: "#initializer_list"
834836

835837
- include: "#punctuation"
836838

837839
function_call:
838-
begin: '([@#]?{{IDENT}})(?=\s*\((?!<))'
840+
begin: '([@#]?{{IDENT}}\b)(?=\s*(\{.*\})?\s*\()'
839841
beginCaptures:
840842
1: { name: entity.name.function.c3 }
841843
end: '\)'
842844
endCaptures:
843845
0: { name: meta.group.c3 punctuation.section.group.end.c3 }
844846
patterns:
847+
- include: "#generic_params"
845848
# Argument list
846849
- begin: \(
847850
beginCaptures:
@@ -851,21 +854,25 @@ repository:
851854
patterns:
852855
- include: "#comments"
853856
# Named argument
854-
- match: '(?<=[(\s,])(\.)([$#]?{{IDENT}})'
857+
- match: '([$#]?{{IDENT}})\s*(:(?!:))'
855858
captures:
856-
1: { name: punctuation.separator.c3 }
857-
2: { name: variable.parameter.c3 }
859+
1: { name: variable.parameter.c3 }
860+
2: { name: punctuation.separator.c3 }
861+
- match: '(\${{TYPE}})\s*(:(?!:))' # TODO I forget if this is even valid
862+
captures:
863+
1: { name: variable.parameter.c3 }
864+
2: { name: punctuation.separator.c3 }
858865
- include: "#expression"
859866
- include: "#punctuation"
860867
- match: ';'
861868
name: punctuation.separator.c3
862869

863870
block:
864871
patterns:
865-
- begin: \{(?!\|)
872+
- begin: \{
866873
beginCaptures:
867874
0: { name: meta.block.c3 punctuation.section.block.begin.c3 }
868-
end: (?<!\|)\}
875+
end: \}
869876
endCaptures:
870877
0: { name: meta.block.c3 punctuation.section.block.end.c3 }
871878
contentName: meta.block.c3
@@ -956,6 +963,6 @@ repository:
956963
end: \}
957964
endCaptures:
958965
0: { name: meta.block.c3 punctuation.section.block.end.c3 }
959-
contentName: meta.block.c3
966+
contentName: meta.block.c3 meta.initializer_list.c3
960967
patterns:
961968
- include: "#expression"

0 commit comments

Comments
 (0)