Skip to content

Commit 4ee1344

Browse files
committed
fix & arg, ` after enum =, other tweaks
1 parent 2462992 commit 4ee1344

File tree

1 file changed

+98
-21
lines changed

1 file changed

+98
-21
lines changed

PowerShellSyntax.tmLanguage

Lines changed: 98 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,14 @@
599599
<key>include</key>
600600
<string>#commentBlock</string>
601601
</dict>
602+
<dict>
603+
<key>comment</key>
604+
<string>normally provided by command mode, but thats not available here</string>
605+
<key>match</key>
606+
<string>`\n</string>
607+
<key>name</key>
608+
<string>constant.character.escape.powershell</string>
609+
</dict>
602610
</array>
603611
</dict>
604612
<dict>
@@ -752,9 +760,9 @@
752760
</dict>
753761
<dict>
754762
<key>comment</key>
755-
<string>do,for,foreach,while: allow a `:label` that must start the statement; A `:label` before a loop looks just like a function, and its possible to put the loop keyword on a later line! Here we just see if a valid label appears to be the only useful thing on a single line</string>
763+
<string>do,for,foreach,switch,while: allow a `:label` that must start the statement; A `:label` before a loop looks just like a function, and its possible to put the loop keyword on a later line! Here we just see if a valid label appears to be the only useful thing on a single line</string>
756764
<key>match</key>
757-
<string>(?&gt;(:)([\p{L}_]\w*)(?![^\s{(,;&amp;|)}]))(?=(?&gt;(?:`\s|\s*&lt;#.*?#&gt;)*)\s*(?:(?i:do|for(?:each)?|while)(?![^\s{(,;&amp;|)}])|#|&lt;#.*$|`?$))</string>
765+
<string>(?&gt;(:)([\p{L}_]\w*)(?![^\s{(,;&amp;|)}]))(?=(?&gt;(?:`\s|\s*&lt;#.*?#&gt;)*)\s*(?:(?i:do|for(?:each)?|switch|while)(?![^\s{(,;&amp;|)}])|#|&lt;#.*$|`?$))</string>
758766
<key>captures</key>
759767
<dict>
760768
<key>1</key>
@@ -1014,9 +1022,20 @@
10141022
<key>comment</key>
10151023
<string>-parallel parameter can only be used in a workflow, consider using meta scopes, and an injection to properly catch this</string>
10161024
<key>match</key>
1017-
<string>(?i:[\x{2013}-\x{2015}-]parallel)</string>
1018-
<key>name</key>
1019-
<string>entity.name.parameter.foreach-parallel.powershell</string>
1025+
<string>(?i:[\x{2013}-\x{2015}-]parallel)(?:(:)?|(?![^\s{(,;&amp;|)}]))</string>
1026+
<key>beginCaptures</key>
1027+
<dict>
1028+
<key>1</key>
1029+
<dict>
1030+
<key>name</key>
1031+
<string>entity.name.parameter.foreach-parallel.powershell</string>
1032+
</dict>
1033+
<key>2</key>
1034+
<dict>
1035+
<key>name</key>
1036+
<string>punctuation.separator.parameter-value.powershell</string>
1037+
</dict>
1038+
</dict>
10201039
</dict>
10211040
<dict>
10221041
<key>include</key>
@@ -1815,15 +1834,26 @@
18151834
<array>
18161835
<dict>
18171836
<key>match</key>
1818-
<string>(?i:[\x{2013}-\x{2015}-](regex|wildcard|exact|casesensitive))</string>
1819-
<key>name</key>
1820-
<string>entity.name.parameter.switch-$0.powershell</string>
1837+
<string>((?i:[\x{2013}-\x{2015}-](regex|wildcard|exact|casesensitive)))(?:(:)?|(?![^\s{(,;&amp;|)}]))</string>
1838+
<key>captures</key>
1839+
<dict>
1840+
<key>1</key>
1841+
<dict>
1842+
<key>name</key>
1843+
<string>entity.name.parameter.switch-$2.powershell</string>
1844+
</dict>
1845+
<key>3</key>
1846+
<dict>
1847+
<key>name</key>
1848+
<string>punctuation.separator.parameter-value.powershell</string>
1849+
</dict>
1850+
</dict>
18211851
</dict>
18221852
<dict>
18231853
<key>comment</key>
18241854
<string>-file is special case, needs file argument, no condition expression</string>
18251855
<key>begin</key>
1826-
<string>((?i:[\x{2013}-\x{2015}-]file))(:)?</string>
1856+
<string>((?i:[\x{2013}-\x{2015}-]file))(?:(:)?|(?![^\s{(,;&amp;|)}]))</string>
18271857
<key>beginCaptures</key>
18281858
<dict>
18291859
<key>1</key>
@@ -2155,7 +2185,7 @@
21552185
<key>comment</key>
21562186
<string>-supportedcommand is special case, array of arguments</string>
21572187
<key>begin</key>
2158-
<string>((?i:[\x{2013}-\x{2015}-]supportedcommand))(:)?</string>
2188+
<string>((?i:[\x{2013}-\x{2015}-]supportedcommand))(?:(:)?|(?![^\s{(,;&amp;|)}]))</string>
21592189
<key>beginCaptures</key>
21602190
<dict>
21612191
<key>1</key>
@@ -2484,8 +2514,49 @@
24842514
<dict>
24852515
<key>comment</key>
24862516
<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>
2487-
<key>include</key>
2488-
<string>#argument_mode</string>
2517+
<key>begin</key>
2518+
<string>\G(?![,;&amp;|)}&lt;&gt;])</string>
2519+
<key>end</key>
2520+
<string>(?=.|$)</string>
2521+
<key>applyEndPatternLast</key>
2522+
<true/>
2523+
<key>patterns</key>
2524+
<array>
2525+
<dict>
2526+
<key>include</key>
2527+
<string>#advanceToToken</string>
2528+
</dict>
2529+
<dict>
2530+
<key>begin</key>
2531+
<string>(?&lt;=[\s&gt;]|\G|^)(?![\s#,;&amp;|)}&lt;&gt;]|&lt;#|$)</string>
2532+
<key>end</key>
2533+
<string>(?!\G)</string>
2534+
<key>name</key>
2535+
<string>meta.argument.invoke-or-source.powershell</string>
2536+
<key>patterns</key>
2537+
<array>
2538+
<dict>
2539+
<key>include</key>
2540+
<string>#argument</string>
2541+
</dict>
2542+
</array>
2543+
</dict>
2544+
</array>
2545+
</dict>
2546+
<dict>
2547+
<key>comment</key>
2548+
<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>
2549+
<key>begin</key>
2550+
<string>(?![\n;)}\]])</string>
2551+
<key>end</key>
2552+
<string>$(?=\n)|(?=[;)}\]])</string>
2553+
<key>patterns</key>
2554+
<array>
2555+
<dict>
2556+
<key>include</key>
2557+
<string>#argument_mode</string>
2558+
</dict>
2559+
</array>
24892560
</dict>
24902561
</array>
24912562
</dict>
@@ -2590,6 +2661,14 @@
25902661
<key>include</key>
25912662
<string>#command_name</string>
25922663
</dict>
2664+
<dict>
2665+
<key>comment</key>
2666+
<string>catch that which didn't match elsewhere</string>
2667+
<key>match</key>
2668+
<string>[^\s]</string>
2669+
<key>name</key>
2670+
<string>invalid.source.powershell</string>
2671+
</dict>
25932672
</array>
25942673
</dict>
25952674
<key>command_name</key>
@@ -2891,15 +2970,15 @@
28912970
<string>#operators</string>
28922971
</dict>
28932972
<dict>
2894-
<key>include</key>
2895-
<string>#notCode</string>
2896-
</dict>
2897-
<dict>
2898-
<key>match</key>
2973+
<key>ignore</key>
28992974
<string>`</string>
29002975
<key>name</key>
29012976
<string>invalid.character.escape.powershell</string>
29022977
</dict>
2978+
<dict>
2979+
<key>include</key>
2980+
<string>#notCode</string>
2981+
</dict>
29032982
</array>
29042983
</dict>
29052984
<key>operand</key>
@@ -6551,11 +6630,9 @@
65516630
<key>comment</key>
65526631
<string>when nothing else matches in usual tokenizing, consume it to prevent other patterns from striking in the middle of what might be a command name.</string>
65536632
<key>begin</key>
6554-
<string>(?=[^\[\s{(,;&amp;)}])</string>
6555-
<key>alternateBegin</key>
6556-
<string>(?=[^\x{2018}-\x{201B}"\x{201C}-\x{201E}\s\[(){},;&amp;|$@])|(?&lt;=\S)(?=[$@&lt;&gt;])</string>
6633+
<string>(?=[^\[\s{(,;&amp;|)}])</string>
65576634
<key>end</key>
6558-
<string>(?=[\s{(,;&amp;)}])</string>
6635+
<string>(?=[\s{(,;&amp;|)}])</string>
65596636
<key>contentName</key>
65606637
<string>invalid.source.powershell</string>
65616638
<key>patterns</key>

0 commit comments

Comments
 (0)