diff --git a/PowerShellSyntax.tmLanguage b/PowerShellSyntax.tmLanguage
index 327a2cf..505e898 100644
--- a/PowerShellSyntax.tmLanguage
+++ b/PowerShellSyntax.tmLanguage
@@ -13,50 +13,21 @@
patterns
- begin
- <#
- beginCaptures
-
- 0
-
- name
- punctuation.definition.comment.block.begin.powershell
-
-
- end
- #>
- endCaptures
-
- 0
-
- name
- punctuation.definition.comment.block.end.powershell
-
-
+ match
+ [2-6]>&1|[1-6]?>>?
name
- comment.block.powershell
- patterns
-
-
- include
- #commentEmbeddedDocs
-
-
+ keyword.operator.redirection.powershell
match
- [2-6]>&1|>>|>|<<|<|>|>\||[1-6]>|[1-6]>>
+ <(?!#)
name
- keyword.operator.redirection.powershell
+ invalid.reserved.redirection.powershell
include
#commands
-
- include
- #commentLine
-
include
#variable
@@ -69,10 +40,6 @@
include
#function
-
- include
- #attribute
-
include
#UsingDirective
@@ -85,186 +52,99 @@
include
#hashtable
-
- include
- #doubleQuotedString
-
include
#scriptblock
- comment
- Needed to parse stuff correctly in 'argument mode'. (See about_parsing.)
include
- #doubleQuotedStringEscapes
+ #numericConstant
begin
- (?<!')'
- beginCaptures
-
- 0
-
- name
- punctuation.definition.string.begin.powershell
-
-
+ (?=@\()
end
- '(?!')
- endCaptures
-
- 0
-
- name
- punctuation.definition.string.end.powershell
-
-
- name
- string.quoted.single.powershell
+ (?!.\G)
+ applyEndPatternLast
+
patterns
- match
- ''
+ begin
+ (@)(\()
+ beginCaptures
+
+ 1
+
+ name
+ keyword.other.array.begin.powershell
+
+ 2
+
+ name
+ punctuation.section.group.begin.powershell
+
+
+ end
+ \)
+ endCaptures
+
+ 0
+
+ name
+ punctuation.section.group.end.powershell
+
+
name
- constant.character.escape.powershell
-
-
-
-
- begin
- \@"(?=$)
- end
- ^"@
- name
- string.quoted.double.heredoc.powershell
- patterns
-
-
- include
- #variableNoProperty
-
-
- include
- #doubleQuotedStringEscapes
-
-
- include
- #interpolation
+ meta.group.array-expression.powershell
+ patterns
+
+
+ include
+ $self
+
+
-
-
-
- begin
- \@'(?=$)
- end
- ^'@
- name
- string.quoted.single.heredoc.powershell
- patterns
-
- match
- ''
- name
- constant.character.escape.powershell
+ begin
+ (?<=\))(?=\.(?!\.)|::|\[)
+ end
+ (?=[^\s\p{L}]|\n)
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #accessors
+
+
+ match
+ [^\s\W]+
+
+
include
- #numericConstant
-
-
- begin
- (@)(\()
- beginCaptures
-
- 1
-
- name
- keyword.other.array.begin.powershell
-
- 2
-
- name
- punctuation.section.group.begin.powershell
-
-
- end
- \)
- endCaptures
-
- 0
-
- name
- punctuation.section.group.end.powershell
-
-
- name
- meta.group.array-expression.powershell
- patterns
-
-
- include
- $self
-
-
-
-
- begin
- (\$)(\()
- beginCaptures
-
- 1
-
- name
- punctuation.definition.variable.powershell
-
- 2
-
- name
- punctuation.section.group.begin.powershell
-
-
- comment
- TODO: move to repo; make recursive.
- end
- \)
- endCaptures
-
- 0
-
- name
- punctuation.section.group.end.powershell
-
-
- name
- meta.group.complex.subexpression.powershell
- patterns
-
-
- include
- $self
-
-
+ #interpolation
match
- (\b(([A-Za-z0-9\-_\.]+)\.(?i:exe|com|cmd|bat))\b)
+ (\b(([\p{L}0-9_\.!%^&+=][\p{L}0-9_\.!@#%^&+=-]*)\.(?i:exe|com|cmd|bat))\b)
name
support.function.powershell
match
- (?<!\w|-|\.)((?i:begin|break|catch|continue|data|default|define|do|dynamicparam|else|elseif|end|exit|finally|for|from|if|in|inlinescript|parallel|param|process|return|sequence|switch|throw|trap|try|until|var|while)|%|\?)(?!\w)
+ (?<!\w|-|\.)((?i:begin|break|catch|continue|data|default|define|do|dynamicparam|else|elseif|end|exit|finally|for|from|if|in|inlinescript|parallel|param|process|return|sequence|switch|throw|trap|try|until|var|while)\b(?![\/.-]))
name
keyword.control.powershell
match
- (?<!\w|-|[^\)]\.)((?i:(foreach|where)(?!-object))|%|\?)(?!\w)
+ (?<!\w|-|[^\)]\.)((?i:(foreach|where)\b(?![\/.-])))
name
keyword.control.powershell
@@ -280,296 +160,695 @@
end
- $
+ $|(?=\|)
patterns
match
- .+
+ [^"\x{201C}-\x{201E}]+?
name
string.unquoted.powershell
+
+ begin
+ (?:["\x{201C}-\x{201E}])
+ beginCaptures
+
+ 0
+
+ name
+ punctuation.definition.string.begin.powershell
+
+
+ end
+ (?:["\x{201C}-\x{201E}])|$
+ applyEndPatternLast
+
+ endCaptures
+
+ 0
+
+ name
+ punctuation.definition.string.end.powershell
+
+
+ name
+ string.quoted.double.powershell
+
comment
This should be moved to the repository at some point.
- comment
- This should only be relevant inside a class but will require a rework of how classes are matched. This is a temp fix.
- match
- (?<!\w)((?i:hidden|static))(?!\w)
- name
- storage.modifier.powershell
-
-
- captures
+ begin
+ (?<![\w-])((?i:class))(?=\s)
+ beginCaptures
1
name
- storage.type.powershell
-
- 2
-
- name
- entity.name.function
-
-
- comment
- capture should be entity.name.type, but it doesn't provide a good color in the default schema.
- match
- (?<!\w|-)((?i:class)|%|\?)(?:\s)+((?:\p{L}|\d|_|-|)+)\b
-
-
- match
- (?<!\w)-(?i:is(?:not)?|as)\b
- name
- keyword.operator.comparison.powershell
-
-
- match
- (?<!\w)-(?i:[ic]?(?:eq|ne|[gl][te]|(?:not)?(?:like|match|contains|in)|replace))(?!\p{L})
- name
- keyword.operator.comparison.powershell
-
-
- match
- (?<!\w)-(?i:join|split)(?!\p{L})|!
- name
- keyword.operator.unary.powershell
-
-
- match
- (?<!\w)-(?i:and|or|not|xor)(?!\p{L})|!
- name
- keyword.operator.logical.powershell
-
-
- match
- (?<!\w)-(?i:band|bor|bnot|bxor|shl|shr)(?!\p{L})
- name
- keyword.operator.bitwise.powershell
-
-
- match
- (?<!\w)-(?i:f)(?!\p{L})
- name
- keyword.operator.string-format.powershell
-
-
- match
- [+%*/-]?=|[+/*%-]
- name
- keyword.operator.assignment.powershell
-
-
- match
- \|{2}|&{2}|;
- name
- punctuation.terminator.statement.powershell
-
-
- match
- &|(?<!\w)\.(?= )|`|,|\|
- name
- keyword.operator.other.powershell
-
-
- comment
- This is very imprecise, is there a syntax for 'must come after...'
- match
- (?<!\s|^)\.\.(?=\-?\d|\(|\$)
- name
- keyword.operator.range.powershell
-
-
- repository
-
- commentLine
-
- begin
- (?<![`\\-])#
- captures
-
- 0
-
- name
- punctuation.definition.comment.powershell
+ keyword.other.class.powershell
end
- $\n?
- name
- comment.line.powershell
+ (?=[^\s])|(?<=})
+ applyEndPatternLast
+
patterns
- include
- #commentEmbeddedDocs
-
-
- include
- #RequiresDirective
-
-
-
- attribute
-
- begin
- (\[)\s*\b(?i)(cmdletbinding|alias|outputtype|parameter|validatenotnull|validatenotnullorempty|validatecount|validateset|allownull|allowemptycollection|allowemptystring|validatescript|validaterange|validatepattern|validatelength)\b
- beginCaptures
-
- 1
-
- name
- punctuation.section.bracket.begin.powershell
-
- 2
-
- name
- support.function.attribute.powershell
-
-
- end
- (\])
- endCaptures
-
- 1
-
- name
- punctuation.section.bracket.end.powershell
+ begin
+ (?<![\w-])([\p{L}_]\w*)
+ beginCaptures
+
+ 1
+
+ name
+ entity.name.type.class.powershell
+
+
+ end
+ (?=[^\s])|(?<=})
+ applyEndPatternLast
+
+ patterns
+
+
+ begin
+ :
+ beginCaptures
+
+ 0
+
+ name
+ punctuation.separator.colon.powershell
+
+
+ end
+ (?=[^\s:])|(?<=})
+ applyEndPatternLast
+
+ patterns
+
+
+ begin
+ (?<![\w-])(?!`)([\p{L}_`][\w`+]*(?:\.\g<1>?)?)
+ beginCaptures
+
+ 0
+
+ patterns
+
+
+ include
+ #type_keywords
+
+
+ match
+ [^\.]+
+ name
+ entity.other.inherited-class.powershell
+
+
+ match
+ \.
+ name
+ punctuation.accessor.type.powershell
+
+
+
+
+ end
+ (?=[^\s])|(?<=})
+ applyEndPatternLast
+
+ patterns
+
+
+ begin
+ ,
+ beginCaptures
+
+ 0
+
+ name
+ punctuation.separator.comma.powershell
+
+
+ end
+ (?=[^\s:])|(?<=})
+ applyEndPatternLast
+
+ patterns
+
+
+ begin
+ (?<![\w-])(?!`)([\p{L}_`][\w`+]*(?:\.\g<1>?)?)
+ beginCaptures
+
+ 0
+
+ patterns
+
+
+ include
+ #type_keywords
+
+
+ match
+ [^\.]+
+ name
+ entity.other.inherited-class.powershell
+
+
+ match
+ \.
+ name
+ punctuation.accessor.type.powershell
+
+
+
+
+ end
+ (?=[^\s])|(?<=})
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #notCode
+
+
+
+
+ include
+ #notCode
+
+
+
+
+ include
+ #notCode
+
+
+
+
+ include
+ #notCode
+
+
+
+
+ include
+ #notCode
+
+
-
- name
- meta.attribute.powershell
- patterns
-
begin
- \(
+ {
beginCaptures
0
name
- punctuation.section.group.begin.powershell
+ punctuation.section.braces.begin.powershell
end
- \)
+ }
endCaptures
0
name
- punctuation.section.group.end.powershell
+ punctuation.section.braces.end.powershell
+ name
+ meta.class.powershell
patterns
- include
- #variable
-
-
- include
- #variableNoProperty
-
-
- include
- #hashtable
+ match
+ (?<![\w-])((?i:hidden|static))(?=\s)
+ name
+ storage.modifier.powershell
- include
- #scriptblock
+ begin
+ (?<![\w-])([\p{L}_]\w*)(?=\s*\()
+ beginCaptures
+
+ 1
+
+ name
+ entity.name.function.powershell
+
+
+ end
+ (?<=[;}])
+ name
+ meta.method.powershell
+ patterns
+
+
+ begin
+ :
+ beginCaptures
+
+ 0
+
+ name
+ punctuation.separator.colon.powershell
+
+
+ end
+ (?=[;{])
+ patterns
+
+
+ begin
+ (?i:base)
+ beginCaptures
+
+ 0
+
+ name
+ variable.language.super.powershell
+
+
+ end
+ (?=[;{])
+ patterns
+
+
+ include
+ #invocationParameterSet
+
+
+
+
+
+
+ include
+ #invocationParameterSet
+
+
+ include
+ $self
+
+
include
- #doubleQuotedStringEscapes
+ $self
+
+
+
+ include
+ #notCode
+
+
+
+
+ begin
+ (?<![\w-])((?i:enum))(?=\s)
+ beginCaptures
+
+ 1
+
+ name
+ keyword.other.enum.powershell
+
+
+ end
+ (?=[^\s])|(?<=})
+ applyEndPatternLast
+
+ patterns
+
+
+ begin
+ (?<![\w-])([\p{L}_]\w*)
+ beginCaptures
+
+ 1
- include
- #doubleQuotedString
+ name
+ entity.name.type.enum.powershell
+
+ end
+ (?=[^\s])|(?<=})
+ applyEndPatternLast
+
+ patterns
+
- include
- #type
+ comment
+ optional user specified type, PowerShell Core >= 6.2.0
+ begin
+ :
+ beginCaptures
+
+ 0
+
+ name
+ punctuation.separator.colon.powershell
+
+
+ end
+ (?=[^\s:])|(?<=})
+ applyEndPatternLast
+
+ patterns
+
+
+ begin
+ (?<![\w-])(?!`)([\p{L}_`][\w`+]*(?:\.\g<1>?)?)
+ beginCaptures
+
+ 0
+
+ patterns
+
+
+ include
+ #type_keywords
+
+
+ match
+ [^\.]+
+ name
+ storage.type.powershell
+
+
+ match
+ \.
+ name
+ punctuation.accessor.type.powershell
+
+
+
+
+ end
+ (?=[^\s])|(?<=})
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #notCode
+
+
+
+
+ include
+ #notCode
+
+
include
- #numericConstant
+ #notCode
+
+
+
+ begin
+ {
+ beginCaptures
+
+ 0
- include
- #doubleQuotedString
+ name
+ punctuation.section.braces.begin.powershell
+
+ end
+ }
+ endCaptures
+
+ 0
- include
- $self
+ name
+ punctuation.section.braces.end.powershell
+
+ name
+ meta.enumeration.powershell
+ patterns
+
match
- (?i)\b(mandatory|valuefrompipeline|valuefrompipelinebypropertyname|valuefromremainingarguments|position|parametersetname|defaultparametersetname|supportsshouldprocess|supportspaging|positionalbinding|helpuri|confirmimpact|helpmessage)\b(?:\s+)?(=)?
- captures
-
- 1
-
- name
- variable.parameter.attribute.powershell
-
- 2
-
- name
- keyword.operator.assignment.powershell
-
-
+ ;
+ name
+ punctuation.terminator.statement.powershell
begin
- (?<!')'
+ (?<![\w-])([\p{L}_]\w*)
beginCaptures
- 0
+ 1
name
- punctuation.definition.string.begin.powershell
+ entity.name.variable.enum-member.powershell
end
- '(?!')
- endCaptures
-
- 0
-
- name
- punctuation.definition.string.end.powershell
-
-
- name
- string.quoted.single.powershell
+ (?<=;)|(?=[}\n])
patterns
- match
- ''
- name
- constant.character.escape.powershell
+ begin
+ =
+ beginCaptures
+
+ 0
+
+ name
+ keyword.operator.assignment.enum-member.powershell
+
+
+ end
+ (?<=;)|(?=[}\n])
+ patterns
+
+
+ include
+ $self
+
+
+
+
+ include
+ #notCode
+
+ include
+ #notCode
+
+
+ include
+ #notCode
+
- commands
- patterns
-
-
- comment
+ include
+ #operators
+
+
+ include
+ #quotedStrings_Members
+
+
+ include
+ #notCode
+
+
+ comment
+ Needed to parse stuff correctly in 'argument mode'. (See about_parsing.)
+ include
+ #argumentModeEscapes
+
+
+ repository
+
+ commentBlock
+
+ begin
+ <#
+ beginCaptures
+
+ 0
+
+ name
+ punctuation.definition.comment.block.begin.powershell
+
+
+ end
+ #>
+ endCaptures
+
+ 0
+
+ name
+ punctuation.definition.comment.block.end.powershell
+
+
+ name
+ comment.block.powershell
+ patterns
+
+
+ include
+ #commentEmbeddedDocs
+
+
+
+ commentLine
+
+ begin
+ (#)#*
+ captures
+
+ 1
+
+ name
+ punctuation.definition.comment.powershell
+
+
+ end
+ $(?=(\n)?)
+ endCaptures
+
+ 1
+
+ name
+ comment.line.powershell
+
+
+ name
+ comment.line.powershell
+ patterns
+
+
+ include
+ #commentEmbeddedDocs
+
+
+ include
+ #RequiresDirective
+
+
+
+ argumentModeEscapes
+
+ patterns
+
+
+ match
+ `(?:[`0abefnrtv"\x{201C}-\x{201E}'\x{2018}-\x{201B}$@#\n])
+ name
+ constant.character.escape.powershell
+
+
+ include
+ #unicodeEscape
+
+
+ match
+ `
+ name
+ invalid.character.escape.powershell
+
+
+
+ attribute
+
+ begin
+ (?i:(?:(?:cmdletbinding|alias|flags|outputtype|parameter|validate(?:not(?:null(?:orempty)?)|count|set|script|range|pattern|length)|allow(?:null|empty(?:collection|string))|supportswildcards)(?=\())|ordered)
+ beginCaptures
+
+ 0
+
+ name
+ support.function.attribute.powershell
+
+
+ end
+ (?!\G\()
+ name
+ meta.attribute.powershell
+ patterns
+
+
+ begin
+ \(
+ beginCaptures
+
+ 0
+
+ name
+ punctuation.section.group.begin.powershell
+
+
+ end
+ \)
+ endCaptures
+
+ 0
+
+ name
+ punctuation.section.group.end.powershell
+
+
+ patterns
+
+
+ match
+ (?i)\b(mandatory|valuefrom(?:pipeline(?:bypropertyname)?|remainingarguments)|position|(?:default)?parametersetname|supports(?:shouldprocess|paging)|positionalbinding|help(?:uri|message)|confirmimpact|ignorecase)\b
+ captures
+
+ 1
+
+ name
+ variable.parameter.attribute.powershell
+
+ 2
+
+ name
+ keyword.operator.assignment.powershell
+
+
+
+
+ include
+ $self
+
+
+
+
+
+ commands
+
+ patterns
+
+
+ comment
Verb-Noun pattern:
match
- (?:(\p{L}|\d|_|-|\\|\:)*\\)?\b(?i:Add|Approve|Assert|Backup|Block|Build|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Deploy|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Mount|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Write)\-.+?(?:\.(?i:exe|cmd|bat|ps1))?\b
+ (?:(\p{L}|\d|_|-|\\|:)*\\)?\b(?i:Add|Approve|Assert|Backup|Block|Build|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Deploy|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Mount|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Write)-.+?(?:\.(?i:exe|cmd|bat|ps1))?\b
name
support.function.powershell
@@ -626,7 +905,7 @@
match
- ^(?i:(?:\s?|#)+(\.)(COMPONENT|DESCRIPTION|EXAMPLE|EXTERNALHELP|FORWARDHELPCATEGORY|FORWARDHELPTARGETNAME|FUNCTIONALITY|INPUTS|LINK|NOTES|OUTPUTS|REMOTEHELPRUNSPACE|ROLE|SYNOPSIS))
+ (?:^|\G)(?i:\s*(\.)(COMPONENT|DESCRIPTION|EXAMPLE|EXTERNALHELP|FORWARDHELP(?:CATEGORY|TARGETNAME)|FUNCTIONALITY|INPUTS|LINK|NOTES|OUTPUTS|REMOTEHELPRUNSPACE|ROLE|SYNOPSIS))(?:\s*$)
name
comment.documentation.embedded.powershell
@@ -650,172 +929,1116 @@
match
- (?i:\s?(\.)(PARAMETER|FORWARDHELPTARGETNAME|FORWARDHELPCATEGORY|REMOTEHELPRUNSPACE|EXTERNALHELP)\s+([a-z0-9-_]+))
+ (?:^|\G)(?i:\s*(\.)(PARAMETER|FORWARDHELP(?:CATEGORY|TARGETNAME)|REMOTEHELPRUNSPACE|EXTERNALHELP)\s+([\w-]+))
name
comment.documentation.embedded.powershell
- doubleQuotedStringEscapes
+ unicodeEscape
+ comment
+ `u{xxxx} added in PowerShell 6.0
patterns
match
- `[0abnfrvt"'$`]
+ `u\{(?:(?:10)?([0-9a-fA-F]){,4}|0?\g<1>{1,5})}
name
constant.character.escape.powershell
match
- ""
+ `u(?:\{[0-9a-fA-F]{,6}.)?
name
- constant.character.escape.powershell
+ invalid.character.escape.powershell
- function
+ doubleQuotedStringEscapes
- begin
- ^(?:\s*+)(?i)(function|filter|configuration|workflow)\s+(?:(global|local|script|private):)?((?:\p{L}|\d|_|-|\.)+)
- beginCaptures
-
- 0
+ patterns
+
+ match
+ `(?:[`0abefnrtv"\x{201C}-\x{201E}$])
name
- meta.function.powershell
+ constant.character.escape.powershell
- 1
- name
- storage.type.powershell
+ include
+ #unicodeEscape
- 2
+ match
+ `
name
- storage.modifier.scope.powershell
+ invalid.character.escape.powershell
- 3
+ match
+ (?:["\x{201C}-\x{201E}]){2}
name
- entity.name.function.powershell
-
-
- end
- (?=\{|\()
- patterns
-
-
- include
- #commentLine
+ constant.character.escape.powershell
- interpolatedStringContent
+ doubleQuotedHereStringEscapes
- begin
- \(
- beginCaptures
-
- 0
-
- name
- punctuation.section.group.begin.powershell
-
-
- contentName
- interpolated.simple.source.powershell
- end
- \)
- endCaptures
-
- 0
-
- name
- punctuation.section.group.end.powershell
-
-
patterns
- include
- $self
+ match
+ `(?:[`0abefnrtv"\x{201C}-\x{201E}'\x{2018}-\x{201B}$])
+ name
+ constant.character.escape.powershell
include
- #interpolation
+ #unicodeEscape
- include
- #interpolatedStringContent
+ match
+ `
+ name
+ invalid.character.escape.powershell
- interpolation
+ function
begin
- (\$)(\()
+ (?<![\w-])((?i:function|filter|configuration|workflow))(?=\s)
beginCaptures
1
name
- punctuation.definition.variable.powershell
-
- 2
-
- name
- punctuation.section.group.begin.powershell
+ keyword.other.function.powershell
- contentName
- interpolated.complex.source.powershell
end
- \)
- endCaptures
-
- 0
-
- name
- punctuation.section.group.end.powershell
-
-
+ (?=[//s])|(?<=})
+ applyEndPatternLast
+
patterns
- include
- $self
-
-
- include
- #interpolation
-
-
- include
- #interpolatedStringContent
-
-
-
- numericConstant
+ begin
+ (?<![\w-])(?:(global|local|script|private)(:))?(?:(?=[^`"\x{201C}-\x{201E}'\x{2018}-\x{201B}{\(|&<>@#\s]|`(?!\s))|(?<=:)(?=[`"\x{201C}-\x{201E}'\x{2018}-\x{201B}<>@#]))
+ beginCaptures
+
+ 1
+
+ name
+ storage.modifier.scope.powershell
+
+ 2
+
+ name
+ punctuation.separator.colon.powershell
+
+
+ end
+ (?=[//s])|(?<=})
+ applyEndPatternLast
+
+ patterns
+
+
+ begin
+ \G
+ end
+ (?=[(){}|,;&\s])
+ applyEndPatternLast
+
+ contentName
+ entity.name.function.powershell
+ patterns
+
+
+ include
+ #unquotedStrings_text
+
+
+
+
+ begin
+ (?<!\G)(?<!})
+ end
+ (?=[//s])|(?<=})
+ applyEndPatternLast
+
+ patterns
+
+
+ begin
+ {
+ beginCaptures
+
+ 0
+
+ name
+ punctuation.section.braces.begin.powershell
+
+
+ end
+ }
+ endCaptures
+
+ 0
+
+ name
+ punctuation.section.braces.end.powershell
+
+
+ name
+ meta.function.powershell
+ patterns
+
+
+ include
+ $self
+
+
+
+
+ include
+ #invocationParameterSet
+
+
+ include
+ #notCode
+
+
+ comment
+ #commentLine
+
+
+ comment
+ (?<!})[^\s{}()]+
+
+
+
+
+
+
+ include
+ #notCode
+
+
+
+ invocationParameterSet
+
+ begin
+ \(
+ beginCaptures
+
+ 0
+
+ name
+ punctuation.section.group.begin.powershell
+
+
+ name
+ meta.parameters.powershell
+ end
+ \)
+ endCaptures
+
+ 0
+
+ name
+ punctuation.section.group.end.powershell
+
+
+ patterns
+
+
+ begin
+ =
+ beginCaptures
+
+ 0
+
+ name
+ keyword.operator.assignment.enum-member.powershell
+
+
+ end
+ (?<=,)|(?=[)\n])
+ patterns
+
+
+ include
+ $self
+
+
+
+
+ match
+ ,
+ name
+ punctuation.separator.comma.powershell
+
+
+ include
+ #variableNoProperty
+
+
+ include
+ #type
+
+
+ include
+ #notCode
+
+
+
+ interpolatedStringContent
+
+ begin
+ (?=\()
+ end
+ (?!.\G)
+ applyEndPatternLast
+
+ patterns
+
+
+ begin
+ \(
+ beginCaptures
+
+ 0
+
+ name
+ punctuation.section.group.begin.powershell
+
+
+ name
+ interpolated.simple.source.powershell
+ end
+ \)
+ endCaptures
+
+ 0
+
+ name
+ punctuation.section.group.end.powershell
+
+
+ patterns
+
+
+ include
+ $self
+
+
+
+
+ begin
+ (?<=\))(?=\.(?!\.)|::|\[)
+ end
+ (?=[^\s\p{L}]|\n)
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #accessors
+
+
+ match
+ [^\s\W]+
+
+
+
+
+
+ interpolation
+
+ begin
+ (?=\$\()
+ end
+ (?!.\G)
+ applyEndPatternLast
+
+ patterns
+
+
+ begin
+ (\$)(\()
+ beginCaptures
+
+ 1
+
+ name
+ keyword.other.subexpression.powershell
+
+ 2
+
+ name
+ punctuation.section.group.begin.powershell
+
+
+ name
+ meta.group.complex.subexpression.powershell
+ end
+ \)
+ endCaptures
+
+ 0
+
+ name
+ punctuation.section.group.end.powershell
+
+
+ patterns
+
+
+ include
+ $self
+
+
+
+
+ begin
+ (?<=\))(?=\.(?!\.)|::|\[)
+ end
+ (?=[^\s\p{L}]|\n)
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #accessors
+
+
+ match
+ [^\s\W]+
+
+
+
+
+
+ stringInterpolation
+
+ begin
+ (\$)(\()
+ beginCaptures
+
+ 1
+
+ name
+ keyword.other.subexpression.powershell
+
+ 2
+
+ name
+ punctuation.section.group.begin.powershell
+
+
+ name
+ meta.embedded.subexpression.powershell
+ contentName
+ interpolated.complex.source.powershell
+ end
+ \)
+ endCaptures
+
+ 0
+
+ name
+ punctuation.section.group.end.powershell
+
+
+ patterns
+
+
+ include
+ $self
+
+
+
+ numericConstant
+
+ patterns
+
+
+ beginCaptures
+
+ 1
+
+ name
+ constant.numeric.integer.powershell
+
+ 3
+
+ name
+ keyword.other.powershell
+
+
+ begin
+ (?:(?<!\w)|\G)([+\x{2013}-\x{2015}-]?(?:[0-9]+(?i:(?![ed]|\.(?!\.))|(?:\.[0-9]*)?((?:(?i:e)[+\x{2013}-\x{2015}-]?[0-9]+)?l))|(?:\.[0-9]+)\g<2>))((?i:[kmgtp]b)?)(?!\w)
+ end
+ (?!.\G)
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #operators
+
+
+ include
+ #commentBlock
+
+
+ include
+ #commentLine
+
+
+
+
+ beginCaptures
+
+ 1
+
+ name
+ constant.numeric.hex.powershell
+
+ 2
+
+ name
+ keyword.other.powershell
+
+
+ begin
+ (?:(?<!\w)|\G)([+\x{2013}-\x{2015}-]?0(?i:x[0-9a-f_]+l?))((?i:[kmgtp]b)?)(?!\w)
+ end
+ (?!.\G)
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #operators
+
+
+ include
+ #commentBlock
+
+
+ include
+ #commentLine
+
+
+
+
+ beginCaptures
+
+ 1
+
+ name
+ constant.numeric.decimal.powershell
+
+ 2
+
+ name
+ keyword.other.powershell
+
+
+ begin
+ (?:(?<!\w)|\G)([+\x{2013}-\x{2015}-]?(?:(?:[0-9]+)|(?=\.[0-9]))(?:\.[0-9]*)?(?i:(?:e[+\x{2013}-\x{2015}-]?[0-9]+)?(?!l)d?))((?i:[kmgtp]b)?)(?!\w)
+ end
+ (?!.\G)
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #operators
+
+
+ include
+ #commentBlock
+
+
+ include
+ #commentLine
+
+
+
+
+ captures
+
+ 1
+
+ name
+ constant.numeric.binary.powershell
+
+ 2
+
+ name
+ keyword.other.powershell
+
+
+ comment
+ (?:(?<!\w)|\G)([+\x{2013}-\x{2015}-]?0(?i:b[01_]+l?))((?i:[kmgtp]b)?)(?!\w)
+
+
+
+ scriptblock
+
+ begin
+ (?={)
+ end
+ (?!.\G)
+ applyEndPatternLast
+
+ patterns
+
+
+ begin
+ {
+ beginCaptures
+
+ 0
+
+ name
+ punctuation.section.braces.begin.powershell
+
+
+ end
+ }
+ endCaptures
+
+ 0
+
+ name
+ punctuation.section.braces.begin.powershell
+
+
+ name
+ meta.scriptblock.powershell
+ patterns
+
+
+ include
+ $self
+
+
+
+
+ begin
+ (?<=})(?=\.(?!\.)|::|\[)
+ end
+ (?=[^\s\p{L}]|\n)
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #accessors
+
+
+ match
+ [^\s\W]+
+
+
+
+
+
+ type
+
+ comment
+ This is used by both type attribute references, attribute references need to be moved here
+ begin
+ (?=\[)
+ end
+ (?!.\G)
+ applyEndPatternLast
+
+ patterns
+
+
+ begin
+ \[
+ beginCaptures
+
+ 0
+
+ name
+ punctuation.section.bracket.begin.powershell
+
+
+ end
+ ]
+ endCaptures
+
+ 0
+
+ name
+ punctuation.section.bracket.end.powershell
+
+
+ applyEndPatternLast
+
+ name
+ meta.type-reference.powershell
+ patterns
+
+
+ match
+ (?i:ref)(?=\])
+ name
+ storage.modifier.powershell
+
+
+ include
+ #attribute
+
+
+ include
+ #type_SubType
+
+
+ match
+ [^\s\W]+
+
+
+
+
+ begin
+ (?<=])(?=\.(?!\.)|::|\[)
+ beginCaptures
+
+ 0
+
+ name
+ punctuation.section.bracket.end.powershell
+
+
+ end
+ (?=[^\s\p{L}]|\n)
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #accessors
+
+
+ include
+ #type
+
+
+ match
+ [^\s\W]+
+
+
+
+
+
+ type_SubType
+
+ patterns
+
+
+ begin
+ (\[)
+ beginCaptures
+
+ 0
+
+ name
+ punctuation.section.bracket.begin.powershell
+
+
+ end
+ (])|(?>[^\s\p{L},])
+ endCaptures
+
+ 0
+
+ name
+ punctuation.section.bracket.end.powershell
+
+
+ applyEndPatternLast
+
+ name
+ meta.type-reference.powershell
+ patterns
+
+
+ include
+ #type_SubType
+
+
+ match
+ (?<!])[^\s\[\]+]+
+
+
+
+
+ begin
+ ((?<![\w-])([\p{L}_]\w*(?:\.\g<2>?)?)(?:`+\d+)?(?:\++\g<1>)?)
+ beginCaptures
+
+ 0
+
+ patterns
+
+
+ include
+ #type_keywords
+
+
+ match
+ [^\.+]+
+ name
+ storage.type.powershell
+
+
+ match
+ \.
+ name
+ punctuation.accessor.type.powershell.powershell
+
+
+ match
+ \+
+ name
+ keyword.operator.type.powershell
+
+
+
+
+ end
+ (?=[^\s])|(?<=])
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #type_SubType
+
+
+ match
+ (?<!])[^\s\[\]+]+
+
+
+
+
+ include
+ #commentBlock
+
+
+ include
+ #commentLine
+
+
+
+ type_keywords
+
+ comment
+ primitive types and base classes often used
+ patterns
+
+
+ comment:
+ [short], [ushort], [uint], [ulong] added PowerShell Core 6.2;
+ match
+ (?<![\w-])(?i:type|void|switch|(?:ps(?:custom)?)?object|hashtable|string|single|float|double|decimal|s?byte|bool(?:ean)?|char|valuetype|datetime|array|u?int(?:32|16|64)|u?int|u?long|u?short)(?!\w)
+ name
+ keyword.type.powershell
+
+
+ match
+ (?<![\w-])(?i:system|math|text|convert|regex|xml)(?!\w)
+ name
+ support.class.powershell
+
+
+
+ accessors
+
+ patterns
+
+
+ begin
+ \G(?:\.(?!\.)|(?<!:)::)
+ beginCaptures
+
+ 0
+
+ name
+ punctuation.accessor.powershell
+
+
+ end
+ (?=[^\s\p{L}]|\n)
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #members
+
+
+ include
+ #commentLine
+
+
+ include
+ #commentBlock
+
+
+ include
+ [^\s\W]+
+
+
+ comment
+ consume spaces and comments and line ends until the next token appears
+ begin
+ \G(?<=\.|::)(?!\S)
+ end
+ (?=.)
+ applyEndPatternLast
+
+ patterns
+
+
+ match
+ \s+
+
+
+ include
+ #commentLine
+
+
+ include
+ #commentBlock
+
+
+
+
+
+
+ begin
+ (?=\[)
+ end
+ (?!.\G)
+ applyEndPatternLast
+
+ patterns
+
+
+ begin
+ \[
+ beginCaptures
+
+ 0
+
+ name
+ punctuation.section.bracket.begin.powershell
+
+
+ end
+ ]
+ endCaptures
+
+ 0
+
+ name
+ punctuation.section.bracket.end.powershell
+
+
+ name
+ meta.index.powershell
+ patterns
+
+
+ include
+ $self
+
+
+
+
+ begin
+ (?<=])(?=\.(?!\.)|::|\[)
+ end
+ (?=[^\s\p{L}]|\n)
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #accessors
+
+
+ match
+ [^\s\W]+
+
+
+
+
+
+
+ include
+ #commentLine
+
+
+ include
+ #commentBlock
+
+
+
+ members
+
+ patterns
+
+
+ match
+ (?<!\w-)((?i:(foreach|where)(?=[\({])))
+ name
+ support.function.powershell
+
+
+ match
+ [\p{L}_]\w*(?=\()
+ captures
+
+ 0
+
+ name
+ variable.function.powershell
+
+
+
+
+ begin
+ [\p{L}_]\w*(?=\.(?!\.)|::|\[)
+ end
+ (?=[^\s\p{L}]|\n)
+ applyEndPatternLast
+
+ beginCaptures
+
+ 0
+
+ name
+ variable.other.object.property.powershell
+
+
+ patterns
+
+
+ include
+ #accessors
+
+
+ match
+ [^\s\W]+
+
+
+
+
+ begin
+ [\p{L}_]\w*
+ end
+ (?=[^\s\p{L}]|\n)
+ beginCaptures
+
+ 0
+
+ name
+ variable.other.property.powershell
+
+
+ patterns
+
+
+ include
+ #commentLine
+
+
+ include
+ #commentBlock
+
+
+ include
+ [^\s\W]+
+
+
+
+
+ include
+ #quotedStrings_Members
+
+
+
+ variable_inner
+ comment
+ seperate the parts of the variable name and scope them
patterns
+
+ match
+ [$@][^:]*:$
+ name
+ invalid.character.variable.powershell
+
+
+ captures
+
+ 1
+
+ name
+ constant.language.powershell
+
+ 2
+
+ name
+ punctuation.definition.variable.powershell
+
+
+ comment
+ These are special constants.
+ match
+ (([$@])(?i:(:?(?:False|Null|True)))\b)
+
captures
1
name
- constant.numeric.hex.powershell
+ variable.language.builtin.powershell
2
name
- keyword.other.powershell
+ punctuation.definition.variable.powershell
+ comment
+ These are the other built-in constants.
match
- (?<!\w)([-+]?0(?:x|X)[0-9a-fA-F_]+(?:U|u|L|l|UL|Ul|uL|ul|LU|Lu|lU|lu)?)((?i:[kmgtp]b)?)\b
+ (([$@])(?i:(:?(?:Error|ExecutionContext|Host|Home|PID|PsHome|PsVersionTable|ShellID)\b)))
captures
@@ -823,16 +2046,16 @@
1
name
- constant.numeric.integer.powershell
+ variable.language.builtin.powershell
2
name
- keyword.other.powershell
+ punctuation.definition.variable.powershell
match
- (?<!\w)([-+]?(?:[0-9_]+)?\.[0-9_]+(?:(?:e|E)[0-9]+)?(?:F|f|D|d|M|m)?)((?i:[kmgtp]b)?)\b
+ (([$@])(?i:((?:[$^?])|:\?|:?(?:_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This)\b)))
captures
@@ -840,775 +2063,1226 @@
1
name
- constant.numeric.octal.powershell
+ variable.language.powershell
2
name
- keyword.other.powershell
+ punctuation.definition.variable.powershell
+
+
+ comment
+ Style preference variables as language variables so that they stand out.
+ match
+ (([$@])(?i:(:?(?:ConfirmPreference|DebugPreference|ErrorActionPreference|ErrorView|FormatEnumerationLimit|MaximumAliasCount|MaximumDriveCount|MaximumErrorCount|MaximumFunctionCount|MaximumHistoryCount|MaximumVariableCount|OFS|OutputEncoding|ProgressPreference|PsCulture|PSDebugContext|PSDefaultParameterValues|PSEmailServer|PSItem|PSModuleAutoloadingPreference|PSSenderInfo|PSSessionApplicationName|PSSessionConfigurationName|PSSessionOption|VerbosePreference|WarningPreference|WhatIfPreference)\b)))
+
+
+ captures
+
+ 1
+
+ name
+ punctuation.definition.variable.powershell
+
+ 2
+
+ patterns
+
+
+ include
+ #variable_scopeOrDrive
+
+
match
- (?<!\w)([-+]?0(?:b|B)[01_]+(?:U|u|L|l|UL|Ul|uL|ul|LU|Lu|lU|lu)?)((?i:[kmgtp]b)?)\b
+ (?:([$@])(?:(?>([\w][\w?]*:|:)?)([\w](?:[\w?]|(?<!:):(?!:))*|[$?^:])))
+ name
+ variable.other.readwrite.powershell
+
+
+
+ variable_scopeOrDrive
+
+ patterns
+
+
+ match
+ ((?i:global|local|private|script|using|workflow))(`)?(:)
+ captures
+
+ 1
+
+ name
+ storage.modifier.scope.powershell
+
+ 2
+
+ name
+ invalid.character.escape.powershell
+
+ 3
+
+ name
+ punctuation.separator.colon.powershell
+
+
+ match
+ (?i:(alias|Cert|Env|Function|HKCU|HKLM|Variable|WSMan))(`)?(:)
captures
1
- name
- constant.numeric.integer.powershell
+ name
+ keyword.type.drive:powershell
+
+ 2
+
+ name
+ invalid.character.escape.powershell
+
+ 3
+
+ name
+ punctuation.separator.colon.powershell
+
+
+
+
+ comment
+ Unknown drive
+ begin
+ (?=.)
+ end
+ :
+ endCaptures
+
+ 0
+
+ name
+ punctuation.separator.colon.powershell
+
+
+ name
+ storage.type.drive.powershell
+ patterns
+
+
+ match
+ `(?:[`0abefnrtv{}\n])
+ name
+ constant.character.escape.powershell
+
+
+ include
+ #unicodeEscape
+
+
+
+
+
+ variable_bracketed
+
+ begin
+ (?=\$\{)
+ end
+ (?!.\G)
+ applyEndPatternLast
+
+ patterns
+
+
+ begin
+ (\$)(\{)
+ beginCaptures
+
+ 1
+
+ name
+ punctuation.definition.variable.powershell
+
+ 2
+
+ name
+ punctuation.definition.variable.braces.begin.powershell
+
+
+ end
+ }
+ endCaptures
+
+ 0
+
+ name
+ punctuation.definition.variable.braces.end.powershell
+
+
+ name
+ variable.other.readwrite.powershell
+ patterns
+
+
+ comment
+ this captures up to the first colon, and then matches up the capture
+ match
+ \G(?:(?:[^`{}:]|`[`{}]?+)+:|:)
+ captures
+
+ 0
+
+ patterns
+
+
+ include
+ #variable_scopeOrDrive
+
+
+
+
+
+
+ match
+ `(?:[`0abefnrtv{}\n])
+ name
+ constant.character.escape.powershell
+
+
+ include
+ #unicodeEscape
+
+
+ match
+ `
+ name
+ invalid.character.escape.powershell
+
+
+ match
+ {
+ name
+ invalid.character.powershell
+
+
+
+
+ begin
+ (?<=})(?=\.(?!\.)|::|\[)
+ end
+ (?=[^\s\p{L}]|\n)
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #accessors
+
+
+ match
+ [^\s\W]+
+
+
+
+
+
+ variableNoProperty_bracketed
+
+ begin
+ (?=\$\{)
+ end
+ (?!.\G)
+ applyEndPatternLast
+
+ patterns
+
+
+ begin
+ (\$)(\{)
+ beginCaptures
+
+ 1
+
+ name
+ punctuation.definition.variable.powershell
+
+ 2
+
+ name
+ punctuation.definition.variable.braces.begin.powershell
+
+
+ end
+ }
+ endCaptures
+
+ 0
+
+ name
+ punctuation.definition.variable.braces.end.powershell
+
+
+ name
+ variable.other.readwrite.powershell
+ patterns
+
+
+ comment
+ this captures up to the first colon, and then matches up the capture
+ match
+ \G(?:(?:[^`{}:]|`[`{}]?+)+:|:)
+ captures
+
+ 0
+
+ patterns
+
+
+ include
+ #variable_scopeOrDrive
+
+
+
+
+
+
+ match
+ `(?:[`0abefnrtv{}\n])
+ name
+ constant.character.escape.powershell
+
+
+ include
+ #unicodeEscape
+
+
+ match
+ `
+ name
+ invalid.character.escape.powershell
+
+
+ match
+ {
+ name
+ invalid.character.powershell
+
+
+
+
+
+ variable
+
+ patterns
+
+
+ begin
+ (?=\$(?:(?>[\w][\w?]*:|:)?(?:[\w](?:[\w?]|:(?!:))*|:(?!:))|[$?^:]|\{))
+ end
+ (?!.\G)
+ applyEndPatternLast
+
+ patterns
+
+
+ begin
+ \$(?:(?>[\w][\w?]*:|:)?(?:[\w](?:[\w?]|:(?!:))*|:(?!:))|[$?^:])(?=\.(?!\.)|::|\[)
+ beginCaptures
+
+ 0
+
+ patterns
+
+
+ include
+ #variable_inner
+
+
+
+
+ end
+ (?=[^\s\p{L}]|\n)
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #accessors
+
+
+ match
+ [^\s\W]+
+
+
+
+
+ begin
+ \$(?:(?>[\w][\w?]*:|:)?(?:[\w](?:[\w?]|:(?!:))*|:(?!:))|[$?^:])
+ end
+ (?!.\G)
+ applyEndPatternLast
+
+ captures
+
+ 0
+
+ patterns
+
+
+ include
+ #variable_inner
+
+
+
+
- 2
- name
- keyword.other.powershell
+ include
+ #variable_bracketed
-
- match
- (?<!\w)([-+]?[0-9_]+(?:e|E)(?:[0-9_])?+(?:F|f|D|d|M|m)?)((?i:[kmgtp]b)?)\b
+
+ comment
+ splatting cannot have members and certain characters following, including no line comment
+ match
+ (?>@(?:(?>[\w][\w?]*:|:)?(?:[\w](?:[\w?]|:(?!:))*|:(?!:))|[$?^:]))(?![~`!@#$%^*<>\]\\/"\x{201C}-\x{201E}'\x{2018}-\x{201B}+-])
captures
- 1
-
- name
- constant.numeric.integer.powershell
-
- 2
+ 0
- name
- keyword.other.powershell
+ patterns
+
+
+ include
+ #variable_inner
+
+
- match
- (?<!\w)([-+]?[0-9_]+\.(?:e|E)(?:[0-9_])?+(?:F|f|D|d|M|m)?)((?i:[kmgtp]b)?)\b
+
+
+ variableNoProperty
+
+ begin
+ (?=\$(?:(?>[\w][\w?]*:|:)?(?:[\w](?:[\w?]|:(?!:))*|:(?!:))|[$?^:]|\{))
+ end
+ (?!.\G)
+ applyEndPatternLast
+
+ patterns
+
+ begin
+ \$(?:(?>[\w][\w?]*:|:)?(?:[\w](?:[\w?]|:(?!:))*|:(?!:))|[$?^:])
+ end
+ (?!.\G)
+ applyEndPatternLast
+
captures
- 1
-
- name
- constant.numeric.integer.powershell
-
- 2
+ 0
- name
- keyword.other.powershell
+ patterns
+
+
+ include
+ #variable_inner
+
+
- match
- (?<!\w)([-+]?[0-9_]+[\.]?(?:F|f|D|d|M|m))((?i:[kmgtp]b)?)\b
- captures
-
- 1
-
- name
- constant.numeric.integer.powershell
-
- 2
-
- name
- keyword.other.powershell
-
-
- match
- (?<!\w)([-+]?[0-9_]+[\.]?(?:U|u|L|l|UL|Ul|uL|ul|LU|Lu|lU|lu)?)((?i:[kmgtp]b)?)\b
+ include
+ #variableNoProperty_bracketed
+ name
+ meta.embedded.interpolated.powershell
- scriptblock
+ UsingDirective
- begin
- \{
- beginCaptures
+ match
+ (?<!\w)(?i:(using))\s+(?i:(namespace|module))\s+(?i:((?:\w+(?:\.)?)+))
+ captures
- 0
+ 1
name
- punctuation.section.braces.begin.powershell
+ keyword.control.using.powershell
-
- end
- \}
- endCaptures
-
- 0
+ 2
name
- punctuation.section.braces.end.powershell
+ keyword.other.powershell
-
- name
- meta.scriptblock.powershell
- patterns
-
+ 3
- include
- $self
+ name
+ variable.parameter.powershell
-
+
- type
+ RequiresDirective
begin
- \[
+ (?<=#)(?i:(requires))\s
beginCaptures
0
name
- punctuation.section.bracket.begin.powershell
+ keyword.control.requires.powershell
end
- \]
- endCaptures
-
- 0
+ $
+ name
+ meta.requires.powershell
+ patterns
+
+ match
+ \-(?i:Modules|PSSnapin|RunAsAdministrator|ShellId|Version)
name
- punctuation.section.bracket.end.powershell
+ keyword.other.powershell
-
- patterns
-
match
- (?!\d+|\.)(?:\p{L}|\p{N}|\.)+
+ (?<!-)\b\p{L}+|\d+(?:\.\d+)*
name
- storage.type.powershell
+ variable.parameter.powershell
include
- $self
+ #hashtable
- variable
+ hashtable
+ begin
+ (?=@\{)
+ end
+ (?!.\G)
+ applyEndPatternLast
+
patterns
- captures
-
- 0
-
- name
- constant.language.powershell
-
- 1
-
- name
- punctuation.definition.variable.powershell
-
-
- comment
- These are special constants.
- match
- (\$)(?i:(False|Null|True))\b
-
-
- captures
+ begin
+ (@)(\{)
+ beginCaptures
- 0
-
- name
- support.constant.variable.powershell
-
1
name
- punctuation.definition.variable.powershell
+ keyword.other.hashtable.begin.powershell
- 3
+ 2
name
- variable.other.member.powershell
+ punctuation.section.braces.begin.powershell
- comment
- These are the other built-in constants.
- match
- (\$)(?i:(Error|ExecutionContext|Host|Home|PID|PsHome|PsVersionTable|ShellID))((?:\.(?:\p{L}|\d|_)+)*\b)?\b
-
-
- captures
+ end
+ \}
+ endCaptures
0
name
- support.constant.automatic.powershell
-
- 1
-
- name
- punctuation.definition.variable.powershell
-
- 3
-
- name
- variable.other.member.powershell
+ punctuation.section.braces.end.powershell
- comment
- Automatic variables are not constants, but they are read-only. In monokai (default) color schema support.variable doesn't have color, so we use constant.
- match
- (\$)(?i:(\$|\^|\?|_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This))((?:\.(?:\p{L}|\d|_)+)*\b)?\b
-
-
- captures
-
- 0
+ name
+ meta.hashtable.powershell
+ patterns
+
+ match
+ \b(\w+)(?=\s*=)
name
- variable.language.powershell
+ entity.name.variable.property.powershell
- 1
- name
- punctuation.definition.variable.powershell
+ comment
+ #scriptblock
- 3
- name
- variable.other.member.powershell
+ include
+ $self
-
- comment
- Style preference variables as language variables so that they stand out.
- match
- (\$)(?i:(ConfirmPreference|DebugPreference|ErrorActionPreference|ErrorView|FormatEnumerationLimit|MaximumAliasCount|MaximumDriveCount|MaximumErrorCount|MaximumFunctionCount|MaximumHistoryCount|MaximumVariableCount|OFS|OutputEncoding|ProgressPreference|PsCulture|PSDebugContext|PSDefaultParameterValues|PSEmailServer|PSItem|PSModuleAutoloadingPreference|PSSenderInfo|PSSessionApplicationName|PSSessionConfigurationName|PSSessionOption|VerbosePreference|WarningPreference|WhatIfPreference))((?:\.(?:\p{L}|\d|_)+)*\b)?\b
+
- captures
-
- 0
-
- name
- variable.other.readwrite.powershell
-
- 1
-
- name
- punctuation.definition.variable.powershell
-
- 2
+ begin
+ (?<=\})(?=\.(?!\.)|::|\[)
+ end
+ (?=[^\s\p{L}]|\n)
+ applyEndPatternLast
+
+ patterns
+
- name
- storage.modifier.scope.powershell
+ include
+ #accessors
- 4
- name
- variable.other.member.powershell
+ match
+ [^\s\W]+
-
- match
- (?i:(\$|@)(global|local|private|script|using|workflow):((?:\p{L}|\d|_)+))((?:\.(?:\p{L}|\d|_)+)*\b)?
+
-
- captures
-
- 0
-
- name
- variable.other.readwrite.powershell
-
- 1
-
- name
- punctuation.definition.variable.powershell
-
- 2
-
- name
- punctuation.section.braces.begin.powershell
-
- 3
+
+
+ quotedStrings_Members
+
+ begin
+ (?=@?(['\x{2018}-\x{201B}"\x{201C}-\x{201E}]))(?:(?<!@\g<1>)|\s*$)
+ end
+ (?!.\G)
+ applyEndPatternLast
+
+ patterns
+
+
+ begin
+ ['\x{2018}-\x{201B}]
+ beginCaptures
+
+ 0
name
- storage.modifier.scope.powershell
+ punctuation.definition.string.begin.powershell
- 5
+
+ end
+ ['\x{2018}-\x{201B}]
+ applyEndPatternLast
+
+ endCaptures
+
+ 0
name
- punctuation.section.braces.end.powershell
+ punctuation.definition.string.end.powershell
- 6
+
+ name
+ string.quoted.single.powershell
+ patterns
+
+ match
+ ['\x{2018}-\x{201B}]{2}
name
- variable.other.member.powershell
+ constant.character.escape.powershell
-
- match
- (?i:(\$)(\{)(global|local|private|script|using|workflow):([^}]*[^}`])(\}))((?:\.(?:\p{L}|\d|_)+)*\b)?
+
- captures
-
- 0
+ begin
+ @(?:["\x{201C}-\x{201E}])(?=\s*$)
+ end
+ ^(?:["\x{201C}-\x{201E}])@
+ name
+ string.quoted.double.heredoc.powershell
+ patterns
+
- name
- variable.other.readwrite.powershell
+ include
+ #variableNoProperty
- 1
- name
- punctuation.definition.variable.powershell
+ include
+ #doubleQuotedHereStringEscapes
- 2
- name
- support.variable.drive.powershell
+ include
+ #stringInterpolation
- 4
+
+
+
+ begin
+ @['\x{2018}-\x{201B}](?=\s*$)
+ end
+ ^['\x{2018}-\x{201B}]@
+ name
+ string.quoted.single.heredoc.powershell
+
+
+ begin
+ (?:["\x{201C}-\x{201E}])
+ beginCaptures
+
+ 0
name
- variable.other.member.powershell
+ punctuation.definition.string.begin.powershell
- match
- (?i:(\$|@)((?:\p{L}|\d|_)+:)?((?:\p{L}|\d|_)+))((?:\.(?:\p{L}|\d|_)+)*\b)?
-
-
- captures
+ end
+ (?:["\x{201C}-\x{201E}])
+ applyEndPatternLast
+
+ endCaptures
0
name
- variable.other.readwrite.powershell
+ punctuation.definition.string.end.powershell
- 1
+
+ name
+ string.quoted.double.powershell
+ patterns
+
- name
- punctuation.definition.variable.powershell
+ include
+ #variableNoProperty
- 2
- name
- punctuation.section.braces.begin.powershell
+ include
+ #doubleQuotedStringEscapes
- 3
- name
- support.variable.drive.powershell
+ include
+ #stringInterpolation
- 5
+
+
+
+ begin
+ (?<=^(['\x{2018}-\x{201B}"\x{201C}-\x{201E}])@|(?<=\g<1>))(?=\.(?!\.)|::|\[)
+ end
+ (?=[^\s\p{L}]|\n)
+ applyEndPatternLast
+
+ patterns
+
- name
- punctuation.section.braces.end.powershell
+ include
+ #accessors
- 6
- name
- variable.other.member.powershell
+ match
+ [^\s\W]+
-
- match
- (?i:(\$)(\{)((?:\p{L}|\d|_)+:)?([^}]*[^}`])(\}))((?:\.(?:\p{L}|\d|_)+)*\b)?
+
- UsingDirective
+ unquotedStrings_text
- match
- (?<!\w)(?i:(using))\s+(?i:(namespace|module))\s+(?i:((?:\w+(?:\.)?)+))
- captures
-
- 1
+ patterns
+
+ match
+ `(?!\n)\s
name
- keyword.control.using.powershell
+ constant.character.escape.powershell
- 2
- name
- keyword.other.powershell
+ include
+ #argumentModeEscapes
- 3
- name
- variable.parameter.powershell
+ begin
+ ['\x{2018}-\x{201B}]
+ end
+ ['\x{2018}-\x{201B}]
+ applyEndPatternLast
+
+ patterns
+
+
+ match
+ ['\x{2018}-\x{201B}]{2}
+ name
+ constant.character.escape.powershell
+
+
-
-
- RequiresDirective
-
- begin
- (?<=#)(?i:(requires))\s
- beginCaptures
-
- 0
- name
- keyword.control.requires.powershell
+ begin
+ ["\x{201C}-\x{201E}]
+ end
+ ["\x{201C}-\x{201E}]
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #doubleQuotedStringEscapes
+
+
+ begin
+ \$\(
+ end
+ \)
+ patterns
+
+
+ include
+ #unquotedStrings_text
+
+
+
+
-
- end
- $
- name
- meta.requires.powershell
+
+ begin
+ \$\(
+ end
+ \)
+ patterns
+
+
+ include
+ #unquotedStrings_text
+
+
+
+
+
+ unquotedStrings_text_interpolatedString
+
+ comment
+ !!!!!!!!!!!!!!!!!!WIP!!!
patterns
match
- \-(?i:Modules|PSSnapin|RunAsAdministrator|ShellId|Version)
+ `(?!\n)\s
name
- keyword.other.powershell
+ constant.character.escape.powershell
- match
- (?<!-)\b\p{L}+|\d+(?:\.\d+)*
- name
- variable.parameter.powershell
+ include
+ #argumentModeEscapes
- include
- #hashtable
+ begin
+ ['\x{2018}-\x{201B}]
+ end
+ ['\x{2018}-\x{201B}]
+ applyEndPatternLast
+
+ patterns
+
+
+ match
+ ['\x{2018}-\x{201B}]{2}
+ name
+ constant.character.escape.powershell
+
+
+
+
+ begin
+ ["\x{201C}-\x{201E}]
+ end
+ ["\x{201C}-\x{201E}]
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #doubleQuotedStringEscapes
+
+
+ begin
+ \$\(
+ end
+ \)
+ patterns
+
+
+ include
+ #unquotedStrings_text
+
+
+
+
+
+
+ begin
+ \$\(
+ end
+ \)
+ patterns
+
+
+ include
+ #unquotedStrings_text
+
+
- variableNoProperty
+ operators
patterns
- captures
+ begin
+ (?:(?<!\w)|\G)[\x{2013}-\x{2015}-](?i:is(?:not)?|as)(?!\p{L})
+ beginCaptures
0
name
- constant.language.powershell
-
- 1
-
- name
- punctuation.definition.variable.powershell
+ keyword.operator.comparison.type.powershell
- comment
- These are special constants.
- match
- (\$)(?i:(False|Null|True))\b
-
-
- captures
-
- 0
+ end
+ (?!\s)
+ applyEndPatternLast
+
+ patterns
+
- name
- support.constant.variable.powershell
+ include
+ #numericConstant
- 1
- name
- punctuation.definition.variable.powershell
+ include
+ #commentBlock
- 3
- name
- variable.other.member.powershell
+ include
+ #commentLine
-
- comment
- These are the other built-in constants.
- match
- (\$)(?i:(Error|ExecutionContext|Host|Home|PID|PsHome|PsVersionTable|ShellID))\b
+
- captures
+ begin
+ (?:(?<!\w|!)|\G)[\x{2013}-\x{2015}-](?i:[ic]?(?:eq|ne|[gl][te]|(?:not)?(?:like|match|contains|in)|replace))(?!\p{L})
+ beginCaptures
0
name
- support.variable.automatic.powershell
+ keyword.operator.comparison.powershell
- 1
+
+ end
+ (?!\s)
+ applyEndPatternLast
+
+ patterns
+
- name
- punctuation.definition.variable.powershell
+ include
+ #numericConstant
- 3
- name
- variable.other.member.powershell
+ include
+ #commentBlock
-
- comment
- Automatic variables are not constants, but they are read-only...
- match
- (\$)(?i:(\$|\^|\?|_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This))\b
+
+ include
+ #commentLine
+
+
- captures
+ begin
+ (?:(?<!\w|!)|\G)[\x{2013}-\x{2015}-](?i:join|split)(?!\p{L})
+ beginCaptures
0
name
- variable.language.powershell
+ keyword.operator.unary.powershell
- 1
+
+ end
+ (?!\s)
+ applyEndPatternLast
+
+ patterns
+
- name
- punctuation.definition.variable.powershell
+ include
+ #numericConstant
- 3
- name
- variable.other.member.powershell
+ include
+ #commentBlock
-
- comment
- Style preference variables as language variables so that they stand out.
- match
- (\$)(?i:(ConfirmPreference|DebugPreference|ErrorActionPreference|ErrorView|FormatEnumerationLimit|MaximumAliasCount|MaximumDriveCount|MaximumErrorCount|MaximumFunctionCount|MaximumHistoryCount|MaximumVariableCount|OFS|OutputEncoding|ProgressPreference|PsCulture|PSDebugContext|PSDefaultParameterValues|PSEmailServer|PSItem|PSModuleAutoloadingPreference|PSSenderInfo|PSSessionApplicationName|PSSessionConfigurationName|PSSessionOption|VerbosePreference|WarningPreference|WhatIfPreference))\b
+
+ include
+ #commentLine
+
+
- captures
+ begin
+ (?:(?<!\w|!)|\G)[\x{2013}-\x{2015}-](?i:and|or|not|xor)(?!\p{L})|!
+ beginCaptures
0
name
- variable.other.readwrite.powershell
+ keyword.operator.logical.powershell
- 1
+
+ end
+ (?!\s)
+ applyEndPatternLast
+
+ patterns
+
- name
- punctuation.definition.variable.powershell
+ include
+ #numericConstant
- 2
- name
- storage.modifier.scope.powershell
+ include
+ #commentBlock
- 4
- name
- variable.other.member.powershell
+ include
+ #commentLine
-
- match
- (?i:(\$|@)(global|local|private|script|using|workflow):((?:\p{L}|\d|_)+))
+
- captures
+ begin
+ (?:(?<!\w|!)|\G)[\x{2013}-\x{2015}-](?i:band|bor|bnot|bxor|shl|shr)(?!\p{L})
+ beginCaptures
0
name
- variable.other.readwrite.powershell
-
- 1
-
- name
- punctuation.definition.variable.powershell
+ keyword.operator.bitwise.powershell
- 2
+
+ end
+ (?!\s)
+ applyEndPatternLast
+
+ patterns
+
- name
- storage.modifier.scope.powershell
+ include
+ #numericConstant
- 4
- name
- keyword.other.powershell
+ include
+ #commentBlock
- 5
- name
- variable.other.member.powershell
+ include
+ #commentLine
-
- match
- (?i:(\$)(\{)(global|local|private|script|using|workflow):([^}]*[^}`])(\}))
+
- captures
+ begin
+ (?:(?<!\w|!)|\G)[\x{2013}-\x{2015}-](?i:f)(?!\p{L})
+ beginCaptures
0
name
- variable.other.readwrite.powershell
+ keyword.operator.string-format.powershell
- 1
+
+ end
+ (?!\s)
+ applyEndPatternLast
+
+ patterns
+
- name
- punctuation.definition.variable.powershell
+ include
+ #numericConstant
- 2
- name
- support.variable.drive.powershell
+ include
+ #commentBlock
- 4
- name
- variable.other.member.powershell
+ include
+ #commentLine
-
+
+
+
+ match
+ \+\+|[\x{2013}-\x{2015}-]{2}
+ name
+ keyword.operator.unary.powershell
+
+
match
- (?i:(\$)((?:\p{L}|\d|_)+:)?((?:\p{L}|\d|_)+))
+ (?:(?<!\w|!)|\G)[\x{2013}-\x{2015}-]\p{L}\w*
+ name
+ entity.name.parameter.powershell
- captures
+ begin
+ [+%*/\x{2013}-\x{2015}-]=?|=
+ beginCaptures
0
name
- variable.other.readwrite.powershell
-
- 1
-
- name
- punctuation.definition.variable.powershell
+ keyword.operator.assignment.powershell
- 2
+
+ end
+ (?!\s)
+ applyEndPatternLast
+
+ patterns
+
- name
- punctuation.section.braces.begin
+ include
+ #numericConstant
- 3
- name
- support.variable.drive.powershell
+ include
+ #commentBlock
- 5
- name
- punctuation.section.braces.end
+ include
+ #commentLine
-
- match
- (?i:(\$)(\{)((?:\p{L}|\d|_)+:)?([^}]*[^}`])(\}))
+
-
-
- hashtable
-
- begin
- (@)(\{)
- beginCaptures
-
- 1
+ comment
+ || and && conditional terminators are reserved
+ match
+ \|\||&&|;
name
- keyword.other.hashtable.begin.powershell
+ punctuation.terminator.statement.powershell
- 2
+ comment
+
+ match
+ [,|]
name
- punctuation.section.braces.begin.powershell
+ punctuation.separator.powershell
-
- end
- (\})
- endCaptures
-
- 1
- name
- punctuation.section.braces.end.powershell
+ comment
+ (dot) source operator, requires trailing space
+ begin
+ &|\.(?=\*?[\s,;&|{}\(\)]|$\[p{L}:?_{])
+ beginCaptures
+
+ 0
+
+ name
+ keyword.operator.other.powershell
+
+
+ end
+ (?!\s)
+ applyEndPatternLast
+
+ patterns
+
+
+ include
+ #numericConstant
+
+
+ include
+ #commentBlock
+
+
+ include
+ #commentLine
+
+
-
- name
- meta.hashtable.powershell
- patterns
-
- captures
+ comment
+ the range operator is only available after an operand (binary operator)
+ begin
+ (?<!^)\s*(\.\.)
+ beginCaptures
1
name
- punctuation.definition.string.begin.powershell
+ keyword.operator.range.powershell
- 2
+
+ end
+ (?!\s)
+ applyEndPatternLast
+
+ patterns
+
- name
- variable.other.readwrite.powershell
+ include
+ #numericConstant
- 3
- name
- punctuation.definition.string.end.powershell
+ include
+ #commentBlock
- 4
- name
- keyword.operator.assignment.powershell
+ include
+ #commentLine
-
- match
- \b((?:\'|\")?)(\w+)((?:\'|\")?)(?:\s+)?(=)(?:\s+)?
- name
- meta.hashtable.assignment.powershell
-
-
- include
- #scriptblock
-
-
- include
- $self
+
- doubleQuotedString
+ notCode
- begin
- (?<!(?<!`)")"
- beginCaptures
-
- 0
-
- name
- punctuation.definition.string.begin.powershell
-
-
- end
- "(?!")
- endCaptures
-
- 0
-
- name
- punctuation.definition.string.end.powershell
-
-
- name
- string.quoted.double.powershell
patterns
match
- (?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,64}\b
-
-
- include
- #variableNoProperty
-
-
- include
- #variable
+ `(?!\n)\s
+ name
+ invalid.character.escape.powershell
include
- #doubleQuotedStringEscapes
+ #commentBlock
include
- #interpolation
+ #commentLine
- match
- `\s*$
- name
- keyword.other.powershell
+ comment
+ 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.
+ begin
+ (?=[^\s\[(){}|,;&])
+ alternateBegin
+ (?=[^\x{2018}-\x{201B}"\x{201C}-\x{201E}\s\[(){}|,;&$@])|(?<=\S)(?=[$@<>])
+ end
+ (?=[(){}|,;&\s])
+ applyEndPatternLast
+
+ contentName
+ unquoted.text.powershell
+ patterns
+
+
+ include
+ #unquotedStrings_text
+
+