Skip to content

Commit e014fc7

Browse files
committed
Add data sections
1 parent 7d179b3 commit e014fc7

File tree

2 files changed

+57
-2
lines changed

2 files changed

+57
-2
lines changed

PowerShell.sublime-syntax

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,18 @@ contexts:
105105
- include: requires-directives
106106

107107
# Normal code
108+
- include: escape-sequences
109+
108110
- include: commands
109111
- include: constants
110112
- include: types
111113
- include: hashtables
112114
- include: variables
113115
- include: strings
114-
- include: script-blocks
115-
- include: escape-sequences
116116
- include: numbers
117+
- include: data-blocks
118+
119+
- include: script-blocks
117120
- include: groups
118121
- include: arrays
119122
- include: subexpressions
@@ -668,6 +671,33 @@ contexts:
668671
# - match: <+
669672
# scope: invalid.illegal.powershell
670673

674+
###[ DATA BLOCK ]##############################################################
675+
676+
data-blocks:
677+
- match: \b(?i:data){{kebab_break}}
678+
scope: keyword.control.context.powershell
679+
push: [data-block-body, data-block-name]
680+
681+
data-block-name:
682+
- match: '{{identifier_simple}}'
683+
scope: entity.name.section.powershell
684+
pop: 1
685+
- include: else-pop
686+
687+
data-block-body:
688+
- meta_scope: meta.block.data.powershell
689+
- match: \{
690+
scope: punctuation.section.block.begin.powershell
691+
push: inside-data-block
692+
- include: else-pop
693+
694+
inside-data-block:
695+
- match: \}
696+
scope: punctuation.section.block.end.powershell
697+
pop: 1
698+
# Data sections use a subset of Pwsh, but we don't distinguish yet.
699+
- include: statements
700+
671701
###[ CONSTANTS ]###############################################################
672702

673703
constants:

Tests/syntax_test_PowerShell.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,31 @@ switch ('this') {
10021002
}
10031003
# <- meta.block punctuation.section.braces.end
10041004

1005+
data {
1006+
"Thank you for using my PowerShell Organize.pst script."
1007+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.data.powershell
1008+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.interpolated.powershell string.quoted.double.powershell
1009+
# ^ punctuation.definition.string.begin.powershell
1010+
# ^ punctuation.definition.string.end.powershell
1011+
"It is provided free of charge to the community."
1012+
"I appreciate your comments and feedback."
1013+
}
1014+
1015+
data TextMsgs {
1016+
#^^^^^^^^^^^^^^^^^^ meta.block.data.powershell
1017+
# ^^^^ keyword.control.context.powershell
1018+
# ^^^^^^^^ entity.name.section.powershell
1019+
# ^ punctuation.section.block.begin.powershell
1020+
ConvertFrom-StringData -StringData @'
1021+
# @@@@@@@@@@@@@@@@@@@@@@ reference
1022+
Text001 = Windows 7
1023+
Text002 = Windows Server 2008 R2
1024+
'@
1025+
}
1026+
1027+
$TextMsgs
1028+
1029+
10051030
# Functions and filters
10061031
functioN MyFunction{}
10071032
#^^^^^^^^^^^^^^^^^^^^ meta.function.powershell

0 commit comments

Comments
 (0)