-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUTL Source.sublime-syntax
290 lines (268 loc) · 8.93 KB
/
UTL Source.sublime-syntax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
%YAML 1.2
---
name: UTL Source
hidden: true
scope: source.utl
variables:
identifier_start: '[[:alpha:]_]'
identifier: '\b{{identifier_start}}[[:alnum:]_]*\b'
path: '\\?({{identifier}}\\)*{{identifier}}'
contexts:
main:
- include: statements
statements:
- include: function
- include: expressions
block:
- include: embedded-html
- include: statements
embedded-html:
- match: (-?%\])(\s*\n)?
scope: meta.embedded.block.utl
captures:
1: punctuation.section.embedded.end.utl
2: meta.html-newline-after-utl.utl
push:
- meta_scope: embedding.utl text.html.basic
- clear_scopes: true
- match: \[%-?
scope: meta.embedded.block.utl punctuation.section.embedded.begin.utl
pop: true
- match: ''
with_prototype:
- include: single-line-utl-tag
- match: (?=\[%-?)
pop: true
push: scope:text.html.basic
single-line-utl-tag:
- match: (?:\[%-?(?=.*-?%\]))
scope: punctuation.section.embedded.begin.utl
push:
- meta_scope: meta.embedded.line.nested.utl
- meta_content_scope: source.utl
- match: (-?%\])(\s*\n)?
captures:
1: punctuation.section.embedded.end.utl
2: meta.html-newline-after-utl.utl
pop: true
- include: statements
expressions:
- include: comments
- match: \b(break|continue|else(if)?|end|for(each)?|if|while|exit|return|then)\b
scope: keyword.control.utl
- include: strings
- match: ;
scope: punctuation.terminator.expression.utl
- include: numbers
- match: (\+|-|\*|/|%|\.)=
scope: keyword.operator.assignment.augmented.utl
- match: '(?:(\=)(&))|(&(?=[[:alpha:]$_]))'
captures:
1: keyword.operator.assignment.utl
2: storage.modifier.reference.utl
3: storage.modifier.reference.utl
- match: (\-\-|\+\+)
scope: keyword.operator.increment-decrement.utl
- match: (\-|\+|\*|/|%)
scope: keyword.operator.arithmetic.utl
- match: (==|!=|<=|>=|<|>)
scope: keyword.operator.comparison.utl
- match: (?i)(!|&&|\|\|)|\b(as)\b
scope: keyword.operator.logical.utl
- include: function-call
- match: \.
scope: keyword.operator.string.utl
- match: "="
scope: keyword.operator.assignment.utl
- match: '(\[)\s*(\])'
scope: meta.array.empty.utl
captures:
1: punctuation.section.array.begin.utl
2: punctuation.section.array.end.utl
- match: '\['
scope: punctuation.section.array.begin.utl
push:
- meta_scope: meta.array.utl
- match: '\]'
scope: punctuation.section.array.end.utl
pop: true
- include: expressions
- include: constants
- include: variables
after-identifier:
- include: item-access
- match: '(?=\S)'
pop: true
after-function-call:
- include: item-access
- match: '(?=\S)'
pop: true
item-access:
- match: '\['
scope: meta.item-access.utl punctuation.section.brackets.begin.utl
push:
- meta_content_scope: meta.item-access.arguments.utl
- match: '\]'
scope: meta.item-access.utl punctuation.section.brackets.end.utl
pop: true
- include: expressions
function:
- match: (?i)(?=\bmacro\b\s*{{identifier_start}})
push:
- meta_content_scope: meta.function.utl
- include: comments
- match: (?i)\bmacro\b
scope: storage.type.function.utl
- match: '{{identifier}}'
scope: entity.name.function.utl
# Lookahead is used here to prevent doubling up of meta.function and meta.function.parameters
- match: (?=\()
set:
- match: \(
scope: meta.function.parameters.utl meta.group.utl punctuation.section.group.begin.utl
set: function-parameters
# Exit on unexpected content
- match: (?=\S)
pop: true
function-parameters:
- meta_content_scope: meta.function.parameters.utl meta.group.utl
- match: '\)'
scope: punctuation.section.group.end.utl
set:
- meta_content_scope: meta.function.utl
- match: '(?=:)'
set: function-return-type
#- match: ;
# scope: meta.block.utl punctuation.section.block.begin.utl
# set: function-body
# Exit on unexpected content
- match: (?=\S)
pop: true
- include: comments
- match: '{{identifier}}'
scope: variable.parameter.utl
captures:
1: punctuation.definition.variable.utl
- match: ','
scope: punctuation.separator.utl
- match: '='
scope: keyword.operator.assignment.utl
push:
- match: '(?=,|\))'
pop: true
- include: expressions
function-return-type:
- meta_content_scope: meta.function.return-type.utl
- match: '(?=;)'
pop: true
- match: ':'
scope: punctuation.separator.utl
# Exit on unexpected content
- match: (?=\S)
pop: true
# TODO: function blocks need work
function-body:
- meta_content_scope: meta.function.utl meta.block.utl
- match: end;?
scope: meta.function.utl meta.block.utl punctuation.section.block.end.utl
pop: true
- include: embedded-html
#- match: '\{'
# scope: punctuation.section.block.begin.utl
# push: block
- include: statements
comments:
- match: /\*
scope: punctuation.definition.comment.begin.utl
push:
- meta_scope: comment.block.utl
- match: \*/
scope: punctuation.definition.comment.end.utl
pop: true
constants:
- match: (?i)\b(TRUE|FALSE|NULL)\b
scope: constant.language.utl
function-call:
# Functions in a user-defined namespace should only be highlighted as user,
# any built-in function names should not be highlighted specially
- match: '(?={{path}}\\{{identifier}}\s*\()'
push:
- meta_scope: meta.function-call.utl
- meta_content_scope: meta.path.utl
#- include: identifier-parts
- match: '{{identifier}}(?=\s*\()'
scope: variable.function.utl
set: function-call-parameters
- match: (?i)\b(echo)\b
scope: support.function.construct.utl
# Root namespace function calls may be a built-in or user
- match: '(\\)?(?={{identifier}}\s*\()'
captures:
1: punctuation.separator.namespace.utl
push:
- meta_scope: meta.function-call.utl
- match: (?=\s*\()
set: function-call-parameters
#- include: support
- match: '{{identifier}}'
scope: variable.function.utl
function-call-parameters:
- match: \s*(\()
scope: meta.function-call.utl
captures:
1: meta.group.utl punctuation.section.group.begin.utl
set:
- meta_content_scope: meta.function-call.utl meta.group.utl
- match: \)
scope: meta.function-call.utl meta.group.utl punctuation.section.group.end.utl
set: after-function-call
- match: ','
scope: punctuation.separator.utl
- include: expressions
numbers:
- match: |-
(?x:
(?:(\b\d+|\B)\.\d+|\b\d+\.\d*)(?:[eE][+-]?\d+)?\b
|
\b\d+(?:[eE][+-]?\d+)\b
)
scope: constant.numeric.float.decimal.utl
- match: '\b\d+\b'
scope: constant.numeric.integer.decimal.utl
string-double-quoted:
- match: '"'
scope: punctuation.definition.string.begin.utl
push:
- meta_scope: string.quoted.double.utl
- meta_content_scope: meta.string-contents.quoted.double.utl
- match: '(?=\S)'
set:
- meta_scope: string.quoted.double.utl
- meta_content_scope: meta.string-contents.quoted.double.utl
- match: '"'
scope: punctuation.definition.string.end.utl
pop: true
string-single-quoted:
- match: "'"
scope: punctuation.definition.string.begin.utl
push:
- meta_scope: string.quoted.single.utl
- meta_content_scope: meta.string-contents.quoted.single.utl
- match: '(?=\S)'
set:
- meta_scope: string.quoted.single.utl
- meta_content_scope: meta.string-contents.quoted.single.utl
- match: "'"
scope: punctuation.definition.string.end.utl
pop: true
- match: '\\[\\'']'
scope: constant.character.escape.utl
strings:
- include: string-double-quoted
- include: string-single-quoted
variables:
- match: '{{identifier}}'
scope: variable.other.utl
captures:
1: punctuation.definition.variable.utl
push: after-identifier