Skip to content

Commit 8b3499e

Browse files
committed
change declaration keywords to keyword.declaration
improve redirects that are commands support PowerShell 7 bigint suffix, binary numeric constants. Optimize `operand`, use `operand` in hashtable. Additional reserved redirection.
1 parent 207c665 commit 8b3499e

File tree

1 file changed

+60
-30
lines changed

1 file changed

+60
-30
lines changed

PowerShellSyntax.tmLanguage

Lines changed: 60 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<key>0</key>
5656
<dict>
5757
<key>name</key>
58-
<string>keyword.other.class.powershell</string>
58+
<string>keyword.declaration.class.powershell</string>
5959
</dict>
6060
</dict>
6161
<key>end</key>
@@ -398,7 +398,7 @@
398398
<key>1</key>
399399
<dict>
400400
<key>name</key>
401-
<string>keyword.other.enum.powershell</string>
401+
<string>keyword.declaration.enum.powershell</string>
402402
</dict>
403403
</dict>
404404
<key>end</key>
@@ -651,7 +651,7 @@
651651
<key>0</key>
652652
<dict>
653653
<key>name</key>
654-
<string>keyword.other.$0.powershell</string>
654+
<string>keyword.declaration.$0.powershell</string>
655655
</dict>
656656
</dict>
657657
<key>end</key>
@@ -2617,7 +2617,7 @@
26172617
<key>comment</key>
26182618
<string>Next token needs to be an operand for the operator, not the actual command, but an expression or unquoted expandable string that describes the command's name.</string>
26192619
<key>begin</key>
2620-
<string>\G(?![,;&amp;|)}&lt;&gt;])</string>
2620+
<string>\G(?![,;&amp;|)}&lt;&gt;])|\G(?=&lt;|[1-6]&gt;&amp;[12]|\*&gt;&amp;1|[1-6*]?&gt;&gt;?)</string>
26212621
<key>end</key>
26222622
<string>(?=.|$)</string>
26232623
<key>applyEndPatternLast</key>
@@ -2628,6 +2628,14 @@
26282628
<key>include</key>
26292629
<string>#advanceToToken</string>
26302630
</dict>
2631+
<dict>
2632+
<key>comment</key>
2633+
<string>at the begining of a command name, `&lt;`, `&gt;` or `&gt;&gt;` are the entire command name.</string>
2634+
<key>match</key>
2635+
<string>(?:&lt;|[1-6]&gt;&amp;[12]|\*&gt;&amp;1|[1-6*]?&gt;&gt;?)</string>
2636+
<key>name</key>
2637+
<string>entity.name.function.powershell</string>
2638+
</dict>
26312639
<dict>
26322640
<key>begin</key>
26332641
<string>(?&lt;=[\s&gt;]|\G|^)(?![\s#,;&amp;|)}&lt;&gt;]|&lt;#|$)</string>
@@ -2666,7 +2674,7 @@
26662674
<key>comment</key>
26672675
<string>could be a numeric constant or a limited list of unary operators, that we should switch to expression mode</string>
26682676
<key>begin</key>
2669-
<string>(?=[\d.,!+\x{2013}-\x{2015}-])</string>
2677+
<string>(?=[.,!+\x{2013}-\x{2015}-]|\d(?!&gt;&amp;[12]))</string>
26702678
<key>end</key>
26712679
<string>(?=[\n;)}\]])</string>
26722680
<key>patterns</key>
@@ -2807,7 +2815,7 @@
28072815
<key>comment</key>
28082816
<string>at the begining of a command name, `&lt;`, `&gt;` or `&gt;&gt;` are the entire command name.</string>
28092817
<key>match</key>
2810-
<string>\G(?:&lt;|&gt;&gt;?)</string>
2818+
<string>\G(?:&lt;|\*&gt;&amp;1|\*?&gt;&gt;?|[1-6]&gt;&amp;[12])</string>
28112819
<key>name</key>
28122820
<string>entity.name.function.powershell</string>
28132821
</dict>
@@ -2881,7 +2889,7 @@
28812889
<key>comment</key>
28822890
<string>could be variable reference, if it doesn't have member reference, its the start of an unquoted expandable string</string>
28832891
<key>begin</key>
2884-
<string>(?=\$(?!\())</string>
2892+
<string>(?=\$[{\w:$^?])</string>
28852893
<key>end</key>
28862894
<string>(?=.|$)</string>
28872895
<key>applyEndPatternLast</key>
@@ -2966,6 +2974,14 @@
29662974
</dict>
29672975
</dict>
29682976
</dict>
2977+
<dict>
2978+
<key>comment</key>
2979+
<string>splatting cannot have members and certain characters following, including no line comment</string>
2980+
<key>match</key>
2981+
<string>@(?![$^?:\w])</string>
2982+
<key>name</key>
2983+
<string>invalid.splat.powershell</string>
2984+
</dict>
29692985
<dict>
29702986
<key>include</key>
29712987
<string>#unquotedArgument</string>
@@ -3021,7 +3037,7 @@
30213037
<key>1</key>
30223038
<dict>
30233039
<key>name</key>
3024-
<string>keyword.control.powershell</string>
3040+
<string>keyword.control.verbatim-argument.powershell</string>
30253041
</dict>
30263042
</dict>
30273043
<key>end</key>
@@ -3032,7 +3048,7 @@
30323048
<key>match</key>
30333049
<string>[^"\x{201C}-\x{201E}]+?</string>
30343050
<key>name</key>
3035-
<string>string.unquoted.powershell</string>
3051+
<string>string.unquoted.verbatim-argument.powershell</string>
30363052
</dict>
30373053
<dict>
30383054
<key>begin</key>
@@ -3143,10 +3159,6 @@
31433159
<key>include</key>
31443160
<string>#redirection</string>
31453161
</dict>
3146-
<dict>
3147-
<key>include</key>
3148-
<string>#type</string>
3149-
</dict>
31503162
<dict>
31513163
<key>comment</key>
31523164
<string>normally operands win matches first, but numeric constant and operators share common first characters, and their matching needs to be alternated such that after any operand matches, a check for operators should occur before a numeric value is checked for again. Operators needs to have first priority of a match after a numeric constant.</string>
@@ -3187,6 +3199,10 @@
31873199
<key>include</key>
31883200
<string>#operators_preUnary</string>
31893201
</dict>
3202+
<dict>
3203+
<key>include</key>
3204+
<string>#type</string>
3205+
</dict>
31903206
<dict>
31913207
<key>include</key>
31923208
<string>#variable</string>
@@ -4450,7 +4466,7 @@
44504466
<key>3</key>
44514467
<dict>
44524468
<key>name</key>
4453-
<string>storage.modifier.long.powershell</string>
4469+
<string>storage.modifier.powershell</string>
44544470
</dict>
44554471
<key>4</key>
44564472
<dict>
@@ -4459,7 +4475,7 @@
44594475
</dict>
44604476
</dict>
44614477
<key>begin</key>
4462-
<string>([+\x{2013}-\x{2015}-]?(?:\d+(?i:(?:\.\d*)?((?:e[+\x{2013}-\x{2015}-]?\d+)?([lsy]|u[lsy]?))|(?!\.(?!\.)))|(?:\.\d+)\g&lt;2&gt;))((?i:[kmgtp]b))?(?=[\s{(,;&amp;|)}#\]&lt;&gt;.!+%*/=\x{2013}-\x{2015}-])</string>
4478+
<string>([+\x{2013}-\x{2015}-]?(?:\d+(?i:(?:\.\d*)?((?:e[+\x{2013}-\x{2015}-]?\d+)?([lsyn]|u[lsy]?))|(?!\.(?!\.)))|(?:\.\d+)\g&lt;2&gt;))((?i:[kmgtp]b))?(?=[\s{(,;&amp;|)}#\]&lt;&gt;.!+%*/=\x{2013}-\x{2015}-])</string>
44634479
<key>end</key>
44644480
<string>(?=.|$)</string>
44654481
<key>applyEndPatternLast</key>
@@ -4483,7 +4499,7 @@
44834499
<key>2</key>
44844500
<dict>
44854501
<key>name</key>
4486-
<string>storage.modifier.long.powershell</string>
4502+
<string>storage.modifier.powershell</string>
44874503
</dict>
44884504
<key>3</key>
44894505
<dict>
@@ -4492,7 +4508,7 @@
44924508
</dict>
44934509
</dict>
44944510
<key>begin</key>
4495-
<string>([+\x{2013}-\x{2015}-]?0(?i:x\h+(u?[lsy]?)?))((?i:[kmgtp]b))?(?=[\s{(,;&amp;|)}#\]&lt;&gt;.!+%*/=\x{2013}-\x{2015}-])</string>
4511+
<string>([+\x{2013}-\x{2015}-]?0(?i:x\h+(n|u?[lsy]?)?))((?i:[kmgtp]b))?(?=[\s{(,;&amp;|)}#\]&lt;&gt;.!+%*/=\x{2013}-\x{2015}-])</string>
44964512
<key>end</key>
44974513
<string>(?=.|$)</string>
44984514
<key>applyEndPatternLast</key>
@@ -4544,7 +4560,7 @@
45444560
<key>name</key>
45454561
<string>invalid.numeric-constant.powershell</string>
45464562
<key>match</key>
4547-
<string>([\x{2013}-\x{2015}-]\.(?i:(?:e[+\x{2013}-\x{2015}-]?\d+)?(?:[dlsy]|u[lsy]?)?))((?i:[kmgtp]b))?(?=[\s{(,;&amp;|)}#\]&lt;&gt;.!+%*/=\x{2013}-\x{2015}-])</string>
4563+
<string>([\x{2013}-\x{2015}-]\.(?i:(?:e[+\x{2013}-\x{2015}-]?\d+)?(?:[dlsyn]|u[lsy]?)?))((?i:[kmgtp]b))?(?=[\s{(,;&amp;|)}#\]&lt;&gt;.!+%*/=\x{2013}-\x{2015}-])</string>
45484564
</dict>
45494565
<dict>
45504566
<key>captures</key>
@@ -4555,13 +4571,18 @@
45554571
<string>constant.numeric.binary.powershell</string>
45564572
</dict>
45574573
<key>2</key>
4574+
<dict>
4575+
<key>name</key>
4576+
<string>storage.modifier.powershell</string>
4577+
</dict>
4578+
<key>3</key>
45584579
<dict>
45594580
<key>name</key>
45604581
<string>constant.language.powershell</string>
45614582
</dict>
45624583
</dict>
4563-
<key>comment</key>
4564-
<string>([+\x{2013}-\x{2015}-]?0(?i:b[01_]+l?))((?i:[kmgtp]b))?(?=[\s{(,;&amp;|)}#\]&lt;&gt;.!+%*/=\x{2013}-\x{2015}-])</string>
4584+
<key>match</key>
4585+
<string>([+\x{2013}-\x{2015}-]?0(?i:b[01]+([dn]|u?[lsy]?)?))((?i:[kmgtp]b))?(?=[\s{(,;&amp;|)}#\]&lt;&gt;.!+%*/=\x{2013}-\x{2015}-])</string>
45654586
</dict>
45664587
</array>
45674588
<key>repository</key>
@@ -4636,7 +4657,7 @@
46364657
<key>3</key>
46374658
<dict>
46384659
<key>name</key>
4639-
<string>storage.modifier.long.powershell</string>
4660+
<string>storage.modifier.powershell</string>
46404661
</dict>
46414662
<key>4</key>
46424663
<dict>
@@ -4645,7 +4666,7 @@
46454666
</dict>
46464667
</dict>
46474668
<key>match</key>
4648-
<string>((?:\d+(?i:(?:\.\d*)?((?:e[+\x{2013}-\x{2015}-]?\d+)?([lsy]|u[lsy]?))|(?!\.(?!\.)))|(?:\.\d+)\g&lt;2&gt;))((?i:[kmgtp]b))?(?=[\s{(,;&amp;|)}])</string>
4669+
<string>((?:\d+(?i:(?:\.\d*)?((?:e[+\x{2013}-\x{2015}-]?\d+)?([lsyn]|u[lsy]?))|(?!\.(?!\.)))|(?:\.\d+)\g&lt;2&gt;))((?i:[kmgtp]b))?(?=[\s{(,;&amp;|)}])</string>
46494670
</dict>
46504671
<dict>
46514672
<key>captures</key>
@@ -4658,7 +4679,7 @@
46584679
<key>2</key>
46594680
<dict>
46604681
<key>name</key>
4661-
<string>storage.modifier.long.powershell</string>
4682+
<string>storage.modifier.powershell</string>
46624683
</dict>
46634684
<key>3</key>
46644685
<dict>
@@ -4667,7 +4688,7 @@
46674688
</dict>
46684689
</dict>
46694690
<key>match</key>
4670-
<string>(0(?i:x\h+(u?[lsy]?)?))((?i:[kmgtp]b))?(?=[\s{(,;&amp;|)}])</string>
4691+
<string>(0(?i:x\h+(n|u?[lsy]?)?))((?i:[kmgtp]b))?(?=[\s{(,;&amp;|)}])</string>
46714692
</dict>
46724693
<dict>
46734694
<key>captures</key>
@@ -4700,13 +4721,18 @@
47004721
<string>constant.numeric.binary.powershell</string>
47014722
</dict>
47024723
<key>2</key>
4724+
<dict>
4725+
<key>name</key>
4726+
<string>storage.modifier.powershell</string>
4727+
</dict>
4728+
<key>3</key>
47034729
<dict>
47044730
<key>name</key>
47054731
<string>constant.language.powershell</string>
47064732
</dict>
47074733
</dict>
4708-
<key>comment</key>
4709-
<string>(0(?i:b[01_]+l?))((?i:[kmgtp]b))?(?=[\s{(,;&amp;|)}])</string>
4734+
<key>match</key>
4735+
<string>(0(?i:b[01]+(n|u?[lsy]?)?))((?i:[kmgtp]b))?(?=[\s{(,;&amp;|)}])</string>
47104736
</dict>
47114737
</array>
47124738
</dict>
@@ -6324,17 +6350,21 @@
63246350
<string>entity.name.variable.property.powershell</string>
63256351
</dict>
63266352
<dict>
6327-
<key>include</key>
6353+
<key>comment</key>
63286354
<string>#type</string>
63296355
</dict>
63306356
<dict>
6331-
<key>include</key>
6357+
<key>comment</key>
63326358
<string>#variable</string>
63336359
</dict>
63346360
<dict>
6335-
<key>include</key>
6361+
<key>comment</key>
63366362
<string>#quotedStrings_Members</string>
63376363
</dict>
6364+
<dict>
6365+
<key>include</key>
6366+
<string>#operand</string>
6367+
</dict>
63386368
<dict>
63396369
<key>begin</key>
63406370
<string>(=)\n?</string>
@@ -7304,7 +7334,7 @@
73047334
</dict>
73057335
<dict>
73067336
<key>match</key>
7307-
<string>&lt;(?!#)</string>
7337+
<string>&lt;(?!#)|[1-6]&gt;&amp;2</string>
73087338
<key>name</key>
73097339
<string>invalid.reserved.redirection.powershell</string>
73107340
</dict>

0 commit comments

Comments
 (0)