1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+
6
+ export const conf = {
7
+ // the default separators except `$-`
8
+ wordPattern : / ( - ? \d * \. \d \w * ) | ( [ ^ \` \~ \! \@ \# % \^ \& \* \( \) \= \+ \[ \{ \] \} \\ \| \; \: \' \" \, \. \< \> \/ \? \s ] + ) / g,
9
+ comments : {
10
+ lineComment : '#' ,
11
+ blockComment : [ '<#' , '#>' ]
12
+ } ,
13
+ brackets : [
14
+ [ '{' , '}' ] ,
15
+ [ '[' , ']' ] ,
16
+ [ '(' , ')' ]
17
+ ] ,
18
+ autoClosingPairs : [
19
+ { open : '{' , close : '}' } ,
20
+ { open : '[' , close : ']' } ,
21
+ { open : '(' , close : ')' } ,
22
+ { open : '"' , close : '"' , notIn : [ 'string' ] } ,
23
+ { open : "'" , close : "'" , notIn : [ 'string' , 'comment' ] }
24
+ ] ,
25
+ surroundingPairs : [
26
+ { open : '{' , close : '}' } ,
27
+ { open : '[' , close : ']' } ,
28
+ { open : '(' , close : ')' } ,
29
+ { open : '"' , close : '"' } ,
30
+ { open : "'" , close : "'" }
31
+ ] ,
32
+ folding : {
33
+ markers : {
34
+ start : new RegExp ( '^\\s*#region\\b' ) ,
35
+ end : new RegExp ( '^\\s*#endregion\\b' )
36
+ }
37
+ }
38
+ } ;
39
+
40
+ export const language = {
41
+ defaultToken : '' ,
42
+ ignoreCase : true ,
43
+ tokenPostfix : '.ps1' ,
44
+
45
+ brackets : [
46
+ { token : 'delimiter.curly' , open : '{' , close : '}' } ,
47
+ { token : 'delimiter.square' , open : '[' , close : ']' } ,
48
+ { token : 'delimiter.parenthesis' , open : '(' , close : ')' }
49
+ ] ,
50
+
51
+ keywords : [
52
+ 'begin' ,
53
+ 'break' ,
54
+ 'catch' ,
55
+ 'class' ,
56
+ 'continue' ,
57
+ 'data' ,
58
+ 'define' ,
59
+ 'do' ,
60
+ 'dynamicparam' ,
61
+ 'else' ,
62
+ 'elseif' ,
63
+ 'end' ,
64
+ 'exit' ,
65
+ 'filter' ,
66
+ 'finally' ,
67
+ 'for' ,
68
+ 'foreach' ,
69
+ 'from' ,
70
+ 'function' ,
71
+ 'if' ,
72
+ 'in' ,
73
+ 'param' ,
74
+ 'process' ,
75
+ 'return' ,
76
+ 'switch' ,
77
+ 'throw' ,
78
+ 'trap' ,
79
+ 'try' ,
80
+ 'until' ,
81
+ 'using' ,
82
+ 'var' ,
83
+ 'while' ,
84
+ 'workflow' ,
85
+ 'parallel' ,
86
+ 'sequence' ,
87
+ 'inlinescript' ,
88
+ 'configuration'
89
+ ] ,
90
+
91
+ helpKeywords :
92
+ / S Y N O P S I S | D E S C R I P T I O N | P A R A M E T E R | E X A M P L E | I N P U T S | O U T P U T S | N O T E S | L I N K | C O M P O N E N T | R O L E | F U N C T I O N A L I T Y | F O R W A R D H E L P T A R G E T N A M E | F O R W A R D H E L P C A T E G O R Y | R E M O T E H E L P R U N S P A C E | E X T E R N A L H E L P / ,
93
+
94
+ // we include these common regular expressions
95
+ symbols : / [ = > < ! ~ ? & % | + \- * \/ \^ ; \. , ] + / ,
96
+ escapes : / ` (?: [ a b f n r t v \\ " ' $ ] | x [ 0 - 9 A - F a - f ] { 1 , 4 } | u [ 0 - 9 A - F a - f ] { 4 } | U [ 0 - 9 A - F a - f ] { 8 } ) / ,
97
+
98
+ // The main tokenizer for our languages
99
+ tokenizer : {
100
+ root : [
101
+ // commands and keywords
102
+ [
103
+ / [ a - z A - Z _ ] [ \w - ] * / ,
104
+ {
105
+ cases : {
106
+ '@keywords' : { token : 'keyword.$0' } ,
107
+ '@default' : ''
108
+ }
109
+ }
110
+ ] ,
111
+
112
+ // whitespace
113
+ [ / [ \t \r \n ] + / , '' ] ,
114
+
115
+ // labels
116
+ [ / ^ : \w * / , 'metatag' ] ,
117
+
118
+ // variables
119
+ [
120
+ / \$ ( \{ ( ( g l o b a l | l o c a l | p r i v a t e | s c r i p t | u s i n g ) : ) ? [ \w ] + \} | ( ( g l o b a l | l o c a l | p r i v a t e | s c r i p t | u s i n g ) : ) ? [ \w ] + ) / ,
121
+ 'variable'
122
+ ] ,
123
+
124
+ // Comments
125
+ [ / < # / , 'comment' , '@comment' ] ,
126
+ [ / # .* $ / , 'comment' ] ,
127
+
128
+ // delimiters
129
+ [ / [ { } ( ) \[ \] ] / , '@brackets' ] ,
130
+ [ / @ s y m b o l s / , 'delimiter' ] ,
131
+
132
+ // numbers
133
+ [ / \d * \. \d + ( [ e E ] [ \- + ] ? \d + ) ? / , 'number.float' ] ,
134
+ [ / 0 [ x X ] [ 0 - 9 a - f A - F _ ] * [ 0 - 9 a - f A - F ] / , 'number.hex' ] ,
135
+ [ / \d + ?/ , 'number' ] ,
136
+
137
+ // delimiter: after number because of .\d floats
138
+ [ / [ ; , . ] / , 'delimiter' ] ,
139
+
140
+ // strings:
141
+ [ / \@ " / , 'string' , '@herestring."' ] ,
142
+ [ / \@ ' / , 'string' , "@herestring.'" ] ,
143
+ [
144
+ / " / ,
145
+ {
146
+ cases : {
147
+ '@eos' : 'string' ,
148
+ '@default' : { token : 'string' , next : '@string."' }
149
+ }
150
+ }
151
+ ] ,
152
+ [
153
+ / ' / ,
154
+ {
155
+ cases : {
156
+ '@eos' : 'string' ,
157
+ '@default' : { token : 'string' , next : "@string.'" }
158
+ }
159
+ }
160
+ ]
161
+ ] ,
162
+
163
+ string : [
164
+ [
165
+ / [ ^ " ' \$ ` ] + / ,
166
+ {
167
+ cases : {
168
+ '@eos' : { token : 'string' , next : '@popall' } ,
169
+ '@default' : 'string'
170
+ }
171
+ }
172
+ ] ,
173
+ [
174
+ / @ e s c a p e s / ,
175
+ {
176
+ cases : {
177
+ '@eos' : { token : 'string.escape' , next : '@popall' } ,
178
+ '@default' : 'string.escape'
179
+ }
180
+ }
181
+ ] ,
182
+ [
183
+ / ` ./ ,
184
+ {
185
+ cases : {
186
+ '@eos' : {
187
+ token : 'string.escape.invalid' ,
188
+ next : '@popall'
189
+ } ,
190
+ '@default' : 'string.escape.invalid'
191
+ }
192
+ }
193
+ ] ,
194
+
195
+ [
196
+ / \$ [ \w ] + $ / ,
197
+ {
198
+ cases : {
199
+ '$S2=="' : { token : 'variable' , next : '@popall' } ,
200
+ '@default' : { token : 'string' , next : '@popall' }
201
+ }
202
+ }
203
+ ] ,
204
+ [
205
+ / \$ [ \w ] + / ,
206
+ {
207
+ cases : {
208
+ '$S2=="' : 'variable' ,
209
+ '@default' : 'string'
210
+ }
211
+ }
212
+ ] ,
213
+
214
+ [
215
+ / [ " ' ] / ,
216
+ {
217
+ cases : {
218
+ '$#==$S2' : { token : 'string' , next : '@pop' } ,
219
+ '@default' : {
220
+ cases : {
221
+ '@eos' : { token : 'string' , next : '@popall' } ,
222
+ '@default' : 'string'
223
+ }
224
+ }
225
+ }
226
+ }
227
+ ]
228
+ ] ,
229
+
230
+ herestring : [
231
+ [
232
+ / ^ \s * ( [ " ' ] ) @ / ,
233
+ {
234
+ cases : {
235
+ '$1==$S2' : { token : 'string' , next : '@pop' } ,
236
+ '@default' : 'string'
237
+ }
238
+ }
239
+ ] ,
240
+ [ / [ ^ \$ ` ] + / , 'string' ] ,
241
+ [ / @ e s c a p e s / , 'string.escape' ] ,
242
+ [ / ` ./ , 'string.escape.invalid' ] ,
243
+ [
244
+ / \$ [ \w ] + / ,
245
+ {
246
+ cases : {
247
+ '$S2=="' : 'variable' ,
248
+ '@default' : 'string'
249
+ }
250
+ }
251
+ ]
252
+ ] ,
253
+
254
+ comment : [
255
+ [ / [ ^ # \. ] + / , 'comment' ] ,
256
+ [ / # > / , 'comment' , '@pop' ] ,
257
+ [ / ( \. ) ( @ h e l p K e y w o r d s ) (? ! \w ) / , { token : 'comment.keyword.$2' } ] ,
258
+ [ / [ \. # ] / , 'comment' ]
259
+ ]
260
+ }
261
+ } ;
0 commit comments