Skip to content

Commit d208cea

Browse files
committed
Better syntax
1 parent 4fa3493 commit d208cea

18 files changed

+1932
-35
lines changed

DataWeave.YAML-tmLanguage

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ repository:
6464
end: (?=\-\>)
6565
patterns:
6666
- include: '#types'
67-
- begin: (?<!\.|\$)\b(matches)\s+
67+
- begin: (?<!\.|\$)\b(matches)\b
6868
beginCaptures:
6969
'1': {name: keyword.control.matches.dw}
7070
end: (?=\-\>)
@@ -187,9 +187,9 @@ repository:
187187
- name: support.function.dw
188188
match: \s(match)\s(?!\{)
189189
- name: support.function.dw
190-
match: (?<!case)\s*(matches)\s
190+
match: (?<!case)\s*\b(matches)\b
191191
- name: support.function.dw
192-
match: \s(abs|avg|ceil|contains|distinctBy|endsWith|filter|find|flatten|floor|groupBy|isBlank|isDecimal|isEmpty|isEven|isInteger|isLeapYear|isOdd|joinBy|log|lower|map|mapObject|max|maxBy|min|minBy|mod|native|now|orderBy|orderBy|pluck|pluck|pow|random|read|readUrl|reduce|reduce|replace|round|scan|sizeOf|splitBy|sqrt|startsWith|sum|to|trim|typeOf|unzip|upper|with|write|zip)\s
192+
match: \b(abs|avg|ceil|contains|distinctBy|endsWith|filter|find|flatten|floor|groupBy|isBlank|isDecimal|isEmpty|isEven|isInteger|isLeapYear|isOdd|joinBy|log|lower|map|mapObject|max|maxBy|min|minBy|mod|native|now|orderBy|orderBy|pluck|pluck|pow|random|read|readUrl|reduce|reduce|replace|round|scan|sizeOf|splitBy|sqrt|startsWith|sum|to|trim|typeOf|unzip|upper|with|write|zip)\b
193193
- name: keyword.reserved.dw
194194
match: \b(throw|do|for|yield|enum|private|async)\b
195195
- name: keyword.control.dw
@@ -228,10 +228,13 @@ repository:
228228

229229
using-statement:
230230
name: using-statement.expr.dw
231-
begin: (?<!\.|\$)\b(using\s*)\(
231+
begin: (?<!\.|\$)\b(using)\s*(\()
232232
beginCaptures:
233233
'1': {name: keyword.control.using.dw}
234-
end: \)
234+
'2': {name: punctuation.definitions.begin.dw}
235+
end: (\))
236+
endCaptures:
237+
'1': {name: punctuation.definitions.end.dw}
235238
patterns:
236239
- match: ((?:\+\+|\-\-|[A-Za-z])(?:[a-zA-Z0-9_]*))(\s*=)
237240
captures:
@@ -370,8 +373,12 @@ repository:
370373
match: \w+
371374

372375
paren-expression:
373-
begin: \(
374-
end: \)
376+
begin: (\()
377+
beginCaptures:
378+
'1': {name: punctuation.expression.begin.dw}
379+
end: (\))
380+
endCaptures:
381+
'1': {name: punctuation.expression.end.dw}
375382
patterns:
376383
- include: '#expressions'
377384

@@ -384,10 +391,24 @@ repository:
384391
patterns:
385392
- include: '#qstring-single'
386393
- include: '#qstring-double'
394+
- include: '#qstring-backtick'
387395
- include: '#template'
388396

397+
qstring-backtick:
398+
begin: '`'
399+
beginCaptures:
400+
'0': { name: string.quoted.double.dw punctuation.definition.string.begin.dw }
401+
end: '`'
402+
endCaptures:
403+
'0': { name: string.quoted.double.dw punctuation.definition.string.end.dw }
404+
patterns:
405+
- include: '#template-substitution-element'
406+
- include: '#string-character-escape'
407+
- match: ([^`])
408+
name: string.template.dw
409+
389410
template:
390-
begin: '([$[:alpha:]][_$[:alnum:]]*)\s*?(`)'
411+
begin: '([$[:alpha:]][_$[:alnum:]]*)\s*(`)'
391412
beginCaptures:
392413
'1': { name: support.function.dw }
393414
'2': { name: string.template.dw punctuation.definition.string.template.begin.dw }
@@ -471,7 +492,7 @@ repository:
471492
- begin: \(
472493
beginCaptures:
473494
'1': {name: keyword.operator.tuple.dw}
474-
end: (\)\s*->)
495+
end: (\)\s*\-\>)
475496
patterns:
476497
- include: '#types'
477498
- include: '#parameters'

DataWeave.tmLanguage

Lines changed: 82 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
</dict>
189189
<dict>
190190
<key>begin</key>
191-
<string>(?&lt;!\.|\$)\b(matches)\s+</string>
191+
<string>(?&lt;!\.|\$)\b(matches)\b</string>
192192
<key>beginCaptures</key>
193193
<dict>
194194
<key>1</key>
@@ -563,13 +563,13 @@
563563
<key>name</key>
564564
<string>support.function.dw</string>
565565
<key>match</key>
566-
<string>(?&lt;!case)\s*(matches)\s</string>
566+
<string>(?&lt;!case)\s*\b(matches)\b</string>
567567
</dict>
568568
<dict>
569569
<key>name</key>
570570
<string>support.function.dw</string>
571571
<key>match</key>
572-
<string>\s(abs|avg|ceil|contains|distinctBy|endsWith|filter|find|flatten|floor|groupBy|isBlank|isDecimal|isEmpty|isEven|isInteger|isLeapYear|isOdd|joinBy|log|lower|map|mapObject|max|maxBy|min|minBy|mod|native|now|orderBy|orderBy|pluck|pluck|pow|random|read|readUrl|reduce|reduce|replace|round|scan|sizeOf|splitBy|sqrt|startsWith|sum|to|trim|typeOf|unzip|upper|with|write|zip)\s</string>
572+
<string>\b(abs|avg|ceil|contains|distinctBy|endsWith|filter|find|flatten|floor|groupBy|isBlank|isDecimal|isEmpty|isEven|isInteger|isLeapYear|isOdd|joinBy|log|lower|map|mapObject|max|maxBy|min|minBy|mod|native|now|orderBy|orderBy|pluck|pluck|pow|random|read|readUrl|reduce|reduce|replace|round|scan|sizeOf|splitBy|sqrt|startsWith|sum|to|trim|typeOf|unzip|upper|with|write|zip)\b</string>
573573
</dict>
574574
<dict>
575575
<key>name</key>
@@ -680,17 +680,30 @@
680680
<key>name</key>
681681
<string>using-statement.expr.dw</string>
682682
<key>begin</key>
683-
<string>(?&lt;!\.|\$)\b(using\s*)\(</string>
683+
<string>(?&lt;!\.|\$)\b(using)\s*(\()</string>
684684
<key>beginCaptures</key>
685685
<dict>
686686
<key>1</key>
687687
<dict>
688688
<key>name</key>
689689
<string>keyword.control.using.dw</string>
690690
</dict>
691+
<key>2</key>
692+
<dict>
693+
<key>name</key>
694+
<string>punctuation.definitions.begin.dw</string>
695+
</dict>
691696
</dict>
692697
<key>end</key>
693-
<string>\)</string>
698+
<string>(\))</string>
699+
<key>endCaptures</key>
700+
<dict>
701+
<key>1</key>
702+
<dict>
703+
<key>name</key>
704+
<string>punctuation.definitions.end.dw</string>
705+
</dict>
706+
</dict>
694707
<key>patterns</key>
695708
<array>
696709
<dict>
@@ -1095,9 +1108,25 @@
10951108
<key>paren-expression</key>
10961109
<dict>
10971110
<key>begin</key>
1098-
<string>\(</string>
1111+
<string>(\()</string>
1112+
<key>beginCaptures</key>
1113+
<dict>
1114+
<key>1</key>
1115+
<dict>
1116+
<key>name</key>
1117+
<string>punctuation.expression.begin.dw</string>
1118+
</dict>
1119+
</dict>
10991120
<key>end</key>
1100-
<string>\)</string>
1121+
<string>(\))</string>
1122+
<key>endCaptures</key>
1123+
<dict>
1124+
<key>1</key>
1125+
<dict>
1126+
<key>name</key>
1127+
<string>punctuation.expression.end.dw</string>
1128+
</dict>
1129+
</dict>
11011130
<key>patterns</key>
11021131
<array>
11031132
<dict>
@@ -1125,16 +1154,60 @@
11251154
<key>include</key>
11261155
<string>#qstring-double</string>
11271156
</dict>
1157+
<dict>
1158+
<key>include</key>
1159+
<string>#qstring-backtick</string>
1160+
</dict>
11281161
<dict>
11291162
<key>include</key>
11301163
<string>#template</string>
11311164
</dict>
11321165
</array>
11331166
</dict>
1167+
<key>qstring-backtick</key>
1168+
<dict>
1169+
<key>begin</key>
1170+
<string>`</string>
1171+
<key>beginCaptures</key>
1172+
<dict>
1173+
<key>0</key>
1174+
<dict>
1175+
<key>name</key>
1176+
<string>string.quoted.double.dw punctuation.definition.string.begin.dw</string>
1177+
</dict>
1178+
</dict>
1179+
<key>end</key>
1180+
<string>`</string>
1181+
<key>endCaptures</key>
1182+
<dict>
1183+
<key>0</key>
1184+
<dict>
1185+
<key>name</key>
1186+
<string>string.quoted.double.dw punctuation.definition.string.end.dw</string>
1187+
</dict>
1188+
</dict>
1189+
<key>patterns</key>
1190+
<array>
1191+
<dict>
1192+
<key>include</key>
1193+
<string>#template-substitution-element</string>
1194+
</dict>
1195+
<dict>
1196+
<key>include</key>
1197+
<string>#string-character-escape</string>
1198+
</dict>
1199+
<dict>
1200+
<key>match</key>
1201+
<string>([^`])</string>
1202+
<key>name</key>
1203+
<string>string.template.dw</string>
1204+
</dict>
1205+
</array>
1206+
</dict>
11341207
<key>template</key>
11351208
<dict>
11361209
<key>begin</key>
1137-
<string>([$[:alpha:]][_$[:alnum:]]*)\s*?(`)</string>
1210+
<string>([$[:alpha:]][_$[:alnum:]]*)\s*(`)</string>
11381211
<key>beginCaptures</key>
11391212
<dict>
11401213
<key>1</key>
@@ -1392,7 +1465,7 @@
13921465
</dict>
13931466
</dict>
13941467
<key>end</key>
1395-
<string>(\)\s*-&gt;)</string>
1468+
<string>(\)\s*\-\&gt;)</string>
13961469
<key>patterns</key>
13971470
<array>
13981471
<dict>

tests/baselines/dynamic-attr.baseline.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ Grammar: DataWeave.tmLanguage
1212
^^
1313
meta.attributes.dw keyword.operator.attributes.dw
1414
^
15-
meta.attributes.dw
15+
meta.attributes.dw punctuation.expression.begin.dw
1616
^^^^
1717
meta.attributes.dw variable.other.dw
1818
^^
1919
meta.attributes.dw meta.selector.data-weave
2020
^
21-
meta.attributes.dw
21+
meta.attributes.dw punctuation.expression.end.dw
2222
^
2323
meta.attributes.dw punctuation.separator.comma.dw
2424
^

tests/baselines/function_call_selector.baseline.txt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,30 @@ Grammar: DataWeave.tmLanguage
1818
meta.directive.var.dw keyword.operator.assignment.dw
1919
^^^^^^^
2020
variable.other.dw
21+
^
22+
punctuation.expression.begin.dw
23+
^
24+
punctuation.expression.end.dw
2125
^
2226
meta.selector.data-weave
2327
^^^^
2428
meta.selector.data-weave meta.object.member.dw
2529
^^^
2630
keyword.other.dw
31+
^
32+
punctuation.expression.begin.dw
2733
^^^^^^^
2834
variable.other.dw
35+
^
36+
punctuation.expression.begin.dw
37+
^
38+
punctuation.expression.end.dw
2939
^
3040
meta.selector.data-weave
3141
^^^
3242
meta.selector.data-weave meta.object.member.dw
33-
^^^^^^^^^^
34-
support.function.dw
43+
^^^^^^^^
44+
support.function.dw
3545
^
3646
string.quoted.double.dw punctuation.definition.string.begin.dw
3747
^
@@ -69,4 +79,6 @@ Grammar: DataWeave.tmLanguage
6979
^
7080
string.quoted.double.dw
7181
^
72-
string.quoted.double.dw punctuation.definition.string.end.dw
82+
string.quoted.double.dw punctuation.definition.string.end.dw
83+
^
84+
punctuation.expression.end.dw

0 commit comments

Comments
 (0)