Changeset View
Changeset View
Standalone View
Standalone View
data/syntax/brightscript.xml
- This file was added.
1 | <?xml version="1.0" encoding="UTF-8"?> | ||||
---|---|---|---|---|---|
2 | <!DOCTYPE language SYSTEM "language.dtd"> | ||||
3 | <language | ||||
4 | name="BrightScript" | ||||
5 | section="Scripts" | ||||
6 | extensions="*.brs" | ||||
7 | version="0" | ||||
8 | kateversion="5.0" | ||||
9 | author="Daniel Levin (dendy.ua@gmail.com)" | ||||
10 | license="MIT"> | ||||
11 | | ||||
12 | <highlighting> | ||||
13 | | ||||
14 | | ||||
15 | | ||||
16 | | ||||
17 | <list name="library"><item>library</item></list> | ||||
18 | | ||||
19 | <list name="function"><item>function</item></list> | ||||
20 | <list name="endfunction"><item>endfunction</item></list> | ||||
21 | <list name="sub"><item>sub</item></list> | ||||
22 | <list name="endsub"><item>endsub</item></list> | ||||
23 | <list name="as"><item>as</item></list> | ||||
24 | | ||||
25 | <list name="end"><item>end</item></list> | ||||
26 | <list name="exit"><item>exit</item></list> | ||||
27 | | ||||
28 | <list name="if"><item>if</item></list> | ||||
29 | <list name="endif"><item>endif</item></list> | ||||
30 | <list name="then"><item>then</item></list> | ||||
31 | <list name="else"><item>else</item></list> | ||||
32 | <list name="elseif"><item>elseif</item></list> | ||||
33 | | ||||
34 | <list name="while"><item>while</item></list> | ||||
35 | <list name="endwhile"><item>endwhile</item></list> | ||||
36 | <list name="exitwhile"><item>exitwhile</item></list> | ||||
37 | | ||||
38 | <list name="for"><item>for</item></list> | ||||
39 | <list name="endfor"><item>endfor</item></list> | ||||
40 | <list name="each"><item>each</item></list> | ||||
41 | <list name="in"><item>in</item></list> | ||||
42 | <list name="to"><item>to</item></list> | ||||
43 | <list name="step"><item>step</item></list> | ||||
44 | <list name="next"><item>next</item></list> | ||||
45 | | ||||
46 | <list name="print"><item>print</item></list> | ||||
47 | <list name="return"><item>return</item></list> | ||||
48 | | ||||
49 | <list name="dim"><item>dim</item></list> | ||||
50 | <list name="stop"><item>stop</item></list> | ||||
51 | <list name="goto"><item>goto</item></list> | ||||
52 | | ||||
53 | <list name="m"><item>m</item></list> | ||||
54 | <list name="top"> | ||||
55 | <item>top</item> | ||||
56 | <item>global</item> | ||||
57 | </list> | ||||
58 | | ||||
59 | <list name="end_of_scope"> | ||||
60 | <item>then</item> | ||||
61 | <item>end</item> | ||||
62 | <item>exit</item> | ||||
63 | </list> | ||||
64 | | ||||
65 | <list name="unary"> | ||||
66 | <item>not</item> | ||||
67 | </list> | ||||
68 | | ||||
69 | <list name="builtin_functions"> | ||||
70 | <item>tab</item> | ||||
71 | <item>pos</item> | ||||
72 | <item>CreateObject</item> | ||||
73 | <item>Type</item> | ||||
74 | <item>GetGlobalAA</item> | ||||
75 | <item>Box</item> | ||||
76 | <item>Run</item> | ||||
77 | <item>Eval</item> | ||||
78 | <item>GetLastRunCompileError</item> | ||||
79 | <item>GetLastRunRuntimeError</item> | ||||
80 | <item>ObjFun</item> | ||||
81 | </list> | ||||
82 | | ||||
83 | <list name="utility_functions"> | ||||
84 | <item>Sleep</item> | ||||
85 | <item>Wait</item> | ||||
86 | <item>GetInterface</item> | ||||
87 | <item>FindMemberFunction</item> | ||||
88 | <item>UpTime</item> | ||||
89 | <item>RebootSystem</item> | ||||
90 | <item>ListDir</item> | ||||
91 | <item>ReadAsciiFile</item> | ||||
92 | <item>WriteAsciiFile</item> | ||||
93 | <item>CopyFile</item> | ||||
94 | <item>MoveFile</item> | ||||
95 | <item>MatchFiles</item> | ||||
96 | <item>DeleteFile</item> | ||||
97 | <item>DeleteDirectory</item> | ||||
98 | <item>CreateDirectory</item> | ||||
99 | <item>FormatDrive</item> | ||||
100 | <item>StrToI</item> | ||||
101 | <item>RunGarbageCollector</item> | ||||
102 | <item>ParseJson</item> | ||||
103 | <item>FormatJson</item> | ||||
104 | <item>Tr</item> | ||||
105 | </list> | ||||
106 | | ||||
107 | <list name="string_functions"> | ||||
108 | <item>UCase</item> | ||||
109 | <item>LCase</item> | ||||
110 | <item>Asc</item> | ||||
111 | <item>Chr</item> | ||||
112 | <item>Instr</item> | ||||
113 | <item>Left</item> | ||||
114 | <item>Len</item> | ||||
115 | <item>Mid</item> | ||||
116 | <item>Str</item> | ||||
117 | <item>StrI</item> | ||||
118 | <item>String</item> | ||||
119 | <item>StringI</item> | ||||
120 | <item>Val</item> | ||||
121 | <item>Substitute</item> | ||||
122 | </list> | ||||
123 | | ||||
124 | <list name="math_functions"> | ||||
125 | <item>Abs</item> | ||||
126 | <item>Atn</item> | ||||
127 | <item>Cdbl</item> | ||||
128 | <item>Cint</item> | ||||
129 | <item>Cos</item> | ||||
130 | <item>Csng</item> | ||||
131 | <item>Exp</item> | ||||
132 | <item>Fix</item> | ||||
133 | <item>Int</item> | ||||
134 | <item>Log</item> | ||||
135 | <item>Rnd</item> | ||||
136 | <item>Sgn</item> | ||||
137 | <item>Sin</item> | ||||
138 | <item>Sqr</item> | ||||
139 | <item>Tan</item> | ||||
140 | </list> | ||||
141 | | ||||
142 | <list name="comments"> | ||||
143 | <item>rem</item> | ||||
144 | </list> | ||||
145 | | ||||
146 | <list name="types"> | ||||
147 | <item>invalid</item> | ||||
148 | <item>void</item> | ||||
149 | <item>dynamic</item> | ||||
150 | <item>boolean</item> | ||||
151 | <item>integer</item> | ||||
152 | <item>longinteger</item> | ||||
153 | <item>float</item> | ||||
154 | <item>double</item> | ||||
155 | <item>string</item> | ||||
156 | <item>object</item> | ||||
157 | <item>function</item> | ||||
158 | <item>interface</item> | ||||
159 | </list> | ||||
160 | | ||||
161 | <list name="constants"> | ||||
162 | <item>true</item> | ||||
163 | <item>false</item> | ||||
164 | <item>invalid</item> | ||||
165 | <item>LINE_NUM</item> | ||||
166 | </list> | ||||
167 | | ||||
168 | | ||||
169 | | ||||
170 | | ||||
171 | <contexts> | ||||
172 | | ||||
173 | <!-- Contexts starting with @ are for inclusion only. --> | ||||
174 | | ||||
175 | <context name="global" attribute="g" lineEndContext="#stay"> | ||||
176 | <DetectSpaces/> | ||||
177 | <keyword String="library" attribute="import" context="library"/> | ||||
178 | <IncludeRules context="@comment"/> | ||||
179 | <IncludeRules context="@macro"/> | ||||
180 | <IncludeRules context="@function"/> | ||||
181 | <IncludeRules context="@sub"/> | ||||
182 | </context> | ||||
183 | | ||||
184 | | ||||
185 | <!-- Import statement, which might appear at the global context: | ||||
186 | library "mylibname.brs" | ||||
187 | --> | ||||
188 | <context name="library" attribute="import" lineEndContext="#pop"> | ||||
189 | <DetectSpaces/> | ||||
190 | <DetectChar char=""" attribute="string" context="#pop!string"/> | ||||
191 | </context> | ||||
192 | | ||||
193 | | ||||
194 | <!-- Comments have higher priority over anything else. --> | ||||
195 | <context name="@comment" attribute="g" lineEndContext="#stay"> | ||||
196 | <DetectSpaces/> | ||||
197 | <DetectChar char="'" attribute="comment" context="comment"/> | ||||
198 | <keyword String="comments" attribute="comment" context="comment"/> | ||||
199 | </context> | ||||
200 | | ||||
201 | <context name="comment" attribute="comment" lineEndContext="#pop"> | ||||
202 | </context> | ||||
203 | | ||||
204 | | ||||
205 | <!-- Macro statement starts with # and might appear anywhere in the code: | ||||
206 | #if foo | ||||
207 | ... | ||||
208 | #else | ||||
209 | ... | ||||
210 | #endif | ||||
211 | --> | ||||
212 | <context name="@macro" attribute="g" lineEndContext="#stay"> | ||||
213 | <DetectChar char="#" attribute="macro" context="macro_line"/> | ||||
214 | </context> | ||||
215 | | ||||
216 | <context name="macro_line" attribute="macro" lineEndContext="#pop"> | ||||
217 | <IncludeRules context="@comment"/> | ||||
218 | </context> | ||||
219 | | ||||
220 | | ||||
221 | <!-- Colon starts a new line. --> | ||||
222 | <context name="line_break" attribute="g" lineEndContext="#stay"> | ||||
223 | <IncludeRules context="@line_break"/> | ||||
224 | </context> | ||||
225 | | ||||
226 | <context name="@line_break" attribute="g" lineEndContext="#stay"> | ||||
227 | <DetectChar char=":" attribute="line_break" context="#pop"/> | ||||
228 | </context> | ||||
229 | | ||||
230 | | ||||
231 | <!-- Common rules for function and sub. --> | ||||
232 | <context name="@code_end" attribute="g" lineEndContext="#stay"> | ||||
233 | <RegExpr String="end\s+(if|for|while)" insensitive="true" attribute="control" context="#pop"/> | ||||
234 | </context> | ||||
235 | | ||||
236 | <context name="arg_as_type" attribute="g" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop"> | ||||
237 | <DetectSpaces/> | ||||
238 | <DetectIdentifier attribute="var" context="#pop!arg_params"/> | ||||
239 | </context> | ||||
240 | | ||||
241 | <context name="arg_params" attribute="g" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop"> | ||||
242 | <DetectSpaces/> | ||||
243 | <keyword String="as" context="as_type" lookAhead="true"/> | ||||
244 | <DetectChar char="=" attribute="assign" context="rvalue"/> | ||||
245 | </context> | ||||
246 | | ||||
247 | <context name="as_type" attribute="g" lineEndContext="#stay"> | ||||
248 | <keyword String="as" attribute="keyword" context="as_type_value"/> | ||||
249 | </context> | ||||
250 | | ||||
251 | <context name="as_type_value" attribute="g" lineEndContext="#stay"> | ||||
252 | <keyword String="types" attribute="type" context="#pop#pop"/> | ||||
253 | <DetectIdentifier attribute="invalid" context="#pop#pop"/> | ||||
254 | </context> | ||||
255 | | ||||
256 | | ||||
257 | <!-- Regular function definition. --> | ||||
258 | <context name="@function" attribute="g" lineEndContext="#stay"> | ||||
259 | <keyword String="function" attribute="keyword" context="function"/> | ||||
260 | </context> | ||||
261 | | ||||
262 | <context name="function" attribute="g" lineEndContext="#stay" fallthrough="true" fallthroughContext="function_name"> | ||||
263 | </context> | ||||
264 | | ||||
265 | <context name="function_name" attribute="g" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!function_code"> | ||||
266 | <DetectSpaces/> | ||||
267 | <DetectIdentifier attribute="func" context="#pop!func_open_brace"/> | ||||
268 | <DetectChar char="(" context="#pop!func_open_brace" lookAhead="true"/> | ||||
269 | </context> | ||||
270 | | ||||
271 | <context name="func_open_brace" attribute="g" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!function_code"> | ||||
272 | <DetectSpaces/> | ||||
273 | <DetectChar char="(" attribute="scope" context="func_args"/> | ||||
274 | </context> | ||||
275 | | ||||
276 | <context name="func_args" attribute="g" lineEndContext="#stay" fallthroughContext="#pop#pop!function_code"> | ||||
277 | <DetectSpaces/> | ||||
278 | <DetectIdentifier context="arg_as_type" lookAhead="true"/> | ||||
279 | <DetectChar char=")" attribute="scope" context="#pop#pop!function_ret"/> | ||||
280 | <DetectChar char="," attribute="coma" context="arg_as_type"/> | ||||
281 | </context> | ||||
282 | | ||||
283 | <context name="function_ret" attribute="g" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!function_code"> | ||||
284 | <DetectChar char=" " context="#stay"/> | ||||
285 | <keyword String="as" context="as_type" lookAhead="true"/> | ||||
286 | </context> | ||||
287 | | ||||
288 | <context name="function_code" attribute="g" lineEndContext="#stay"> | ||||
289 | <DetectSpaces/> | ||||
290 | <keyword String="end" context="function_end" lookAhead="true"/> | ||||
291 | <keyword String="endfunction" attribute="keyword" context="#pop#pop"/> | ||||
292 | <IncludeRules context="@code"/> | ||||
293 | </context> | ||||
294 | | ||||
295 | <context name="function_end" attribute="g" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop"> | ||||
296 | <DetectSpaces/> | ||||
297 | <RegExpr String="end\s+function" insensitive="true" attribute="keyword" context="#pop#pop#pop"/> | ||||
298 | <IncludeRules context="@code_end"/> | ||||
299 | </context> | ||||
300 | | ||||
301 | | ||||
302 | <!-- sub is a function with void return type. --> | ||||
303 | <context name="@sub" attribute="g" lineEndContext="#stay"> | ||||
304 | <keyword String="sub" attribute="keyword" context="sub"/> | ||||
305 | </context> | ||||
306 | | ||||
307 | <context name="sub" attribute="g" lineEndContext="#stay" fallthrough="true" fallthroughContext="sub_name"> | ||||
308 | </context> | ||||
309 | | ||||
310 | <context name="sub_name" attribute="g" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!sub_code"> | ||||
311 | <DetectSpaces/> | ||||
312 | <DetectIdentifier attribute="func" context="#pop!sub_open_brace"/> | ||||
313 | </context> | ||||
314 | | ||||
315 | <context name="sub_open_brace" attribute="g" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!sub_code"> | ||||
316 | <DetectSpaces/> | ||||
317 | <DetectChar char="(" attribute="scope" context="sub_args"/> | ||||
318 | </context> | ||||
319 | | ||||
320 | <context name="sub_args" attribute="g" lineEndContext="#stay" fallthroughContext="#pop#pop!sub_code"> | ||||
321 | <DetectSpaces/> | ||||
322 | <DetectIdentifier context="arg_as_type" lookAhead="true"/> | ||||
323 | <DetectChar char=")" attribute="scope" context="#pop#pop!sub_ret"/> | ||||
324 | <DetectChar char="," attribute="coma" context="arg_as_type"/> | ||||
325 | </context> | ||||
326 | | ||||
327 | <context name="sub_ret" attribute="g" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!sub_code"> | ||||
328 | <DetectChar char=" " context="#stay"/> | ||||
329 | <keyword String="as" context="as_type" lookAhead="true"/> | ||||
330 | </context> | ||||
331 | | ||||
332 | <context name="sub_code" attribute="code" lineEndContext="#stay"> | ||||
333 | <DetectSpaces/> | ||||
334 | <keyword String="end" context="sub_end" lookAhead="true"/> | ||||
335 | <keyword String="endsub" attribute="keyword" context="#pop#pop"/> | ||||
336 | <IncludeRules context="@code"/> | ||||
337 | </context> | ||||
338 | | ||||
339 | <context name="sub_end" attribute="g" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop#pop"> | ||||
340 | <DetectSpaces/> | ||||
341 | <RegExpr String="end\s+sub" insensitive="true" attribute="keyword" context="#pop#pop#pop"/> | ||||
342 | <IncludeRules context="@code_end"/> | ||||
343 | </context> | ||||
344 | | ||||
345 | | ||||
346 | <!-- @code represents execution body, including function and sub contents. | ||||
347 | --> | ||||
348 | <context name="@code" attribute="g" lineEndContext="#stay"> | ||||
349 | <DetectSpaces/> | ||||
350 | <IncludeRules context="@macro"/> | ||||
351 | <IncludeRules context="@comment"/> | ||||
352 | | ||||
353 | <keyword String="print" attribute="print" context="print"/> | ||||
354 | <keyword String="goto" attribute="keyword" context="goto"/> | ||||
355 | <keyword String="return" attribute="control" context="rvalue"/> | ||||
356 | <keyword String="stop" attribute="keyword"/> | ||||
357 | | ||||
358 | <keyword String="dim" attribute="keyword" context="dim"/> | ||||
359 | | ||||
360 | <keyword String="if" attribute="control" context="rvalue"/> | ||||
361 | <keyword String="then" attribute="control"/> | ||||
362 | <keyword String="else" attribute="control"/> | ||||
363 | <keyword String="elseif" attribute="control"/> | ||||
364 | <keyword String="endif" attribute="control"/> | ||||
365 | | ||||
366 | <keyword String="while" attribute="control" context="rvalue"/> | ||||
367 | <keyword String="endwhile" attribute="control"/> | ||||
368 | <keyword String="exitwhile" attribute="control"/> | ||||
369 | | ||||
370 | <keyword String="for" attribute="control" context="for"/> | ||||
371 | <keyword String="endfor" attribute="control"/> | ||||
372 | <keyword String="next" attribute="control"/> | ||||
373 | | ||||
374 | <keyword String="exit" attribute="control" context="exit"/> | ||||
375 | | ||||
376 | <DetectChar char=":" context="line_break" lookAhead="true"/> | ||||
377 | | ||||
378 | <DetectIdentifier context="lvalue" lookAhead="true"/> | ||||
379 | </context> | ||||
380 | | ||||
381 | <context name="print" attribute="g" lineEndContext="#pop" fallthrough="true" fallthroughContext="rvalue"> | ||||
382 | <DetectChar char="," attribute="coma"/> | ||||
383 | <DetectChar char=";" attribute="coma"/> | ||||
384 | <IncludeRules context="@line_break"/> | ||||
385 | </context> | ||||
386 | | ||||
387 | <context name="goto" attribute="g" lineEndContext="#pop"> | ||||
388 | <DetectSpaces/> | ||||
389 | <DetectIdentifier attribute="label" context="#pop"/> | ||||
390 | </context> | ||||
391 | | ||||
392 | <context name="dim" attribute="g" lineEndContext="#pop"> | ||||
393 | <DetectSpaces/> | ||||
394 | <DetectIdentifier attribute="var" context="#pop!dim_array"/> | ||||
395 | <IncludeRules context="@comment"/> | ||||
396 | </context> | ||||
397 | | ||||
398 | <context name="dim_array" attribute="g" lineEndContext="#pop"> | ||||
399 | <DetectSpaces/> | ||||
400 | <DetectChar char="[" attribute="operator" context="#pop!array"/> | ||||
401 | <IncludeRules context="@comment"/> | ||||
402 | </context> | ||||
403 | | ||||
404 | <context name="for" attribute="g" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!for_var"> | ||||
405 | <DetectSpaces/> | ||||
406 | <keyword String="each" attribute="control" context="#pop!for_each"/> | ||||
407 | <IncludeRules context="@comment"/> | ||||
408 | </context> | ||||
409 | | ||||
410 | <context name="for_each" attribute="g" lineEndContext="#pop"> | ||||
411 | <DetectSpaces/> | ||||
412 | <DetectIdentifier attribute="var" context="#pop!for_in"/> | ||||
413 | <IncludeRules context="@comment"/> | ||||
414 | </context> | ||||
415 | | ||||
416 | <context name="for_in" attribute="g" lineEndContext="#pop"> | ||||
417 | <DetectSpaces/> | ||||
418 | <keyword String="in" attribute="control" context="#pop!rvalue"/> | ||||
419 | <IncludeRules context="@comment"/> | ||||
420 | </context> | ||||
421 | | ||||
422 | <context name="for_var" attribute="g" lineEndContext="#pop" fallthrough="true" fallthroughContext="lvalue"> | ||||
423 | <DetectSpaces/> | ||||
424 | <keyword String="to" attribute="control" context="#pop!for_to"/> | ||||
425 | <IncludeRules context="@comment"/> | ||||
426 | </context> | ||||
427 | | ||||
428 | <context name="for_to" attribute="g" lineEndContext="#pop" fallthrough="true" fallthroughContext="rvalue"> | ||||
429 | <DetectSpaces/> | ||||
430 | <keyword String="step" attribute="control" context="#pop!rvalue"/> | ||||
431 | </context> | ||||
432 | | ||||
433 | <context name="exit" attribute="g" lineEndContext="#pop"> | ||||
434 | <DetectSpaces/> | ||||
435 | <keyword String="for" attribute="control" context="#pop"/> | ||||
436 | <keyword String="while" attribute="control" context="#pop"/> | ||||
437 | <IncludeRules context="@comment"/> | ||||
438 | </context> | ||||
439 | | ||||
440 | | ||||
441 | | ||||
442 | <!-- Builtin functions are reserved keywords. They cannot be used as a local variable names. | ||||
443 | Thus doing something like below is an error and will be highlighted with 'invalid': | ||||
444 | eval = 1 | ||||
445 | foo = eval | ||||
446 | It is still valid to use any word, including reserved ones, as an variable parameter: | ||||
447 | foo.eval = 1 | ||||
448 | foo = bar.eval | ||||
449 | foo.eval() | ||||
450 | --> | ||||
451 | <context name="@lvalue_builtin_functions" attribute="g" lineEndContext="#stay"> | ||||
452 | <keyword String="builtin_functions" context="#pop!lvalue_builtin_function" lookAhead="true"/> | ||||
453 | </context> | ||||
454 | | ||||
455 | <context name="lvalue_builtin_function" attribute="g" lineEndContext="#pop"> | ||||
456 | <RegExpr String="[a-zA-Z_][a-zA-Z0-1_]*\s*\(" context="#pop!lvalue_builtin_call" lookAhead="true"/> | ||||
457 | <DetectIdentifier attribute="invalid" context="#pop"/> | ||||
458 | </context> | ||||
459 | | ||||
460 | <context name="lvalue_builtin_call" attribute="g" lineEndContext="#pop"> | ||||
461 | <DetectIdentifier attribute="builtin_func" context="#pop!lvalue_call_open_brace"/> | ||||
462 | </context> | ||||
463 | | ||||
464 | | ||||
465 | <context name="@rvalue_builtin_functions" attribute="g" lineEndContext="#stay"> | ||||
466 | <keyword String="builtin_functions" context="#pop!rvalue_builtin_function" lookAhead="true"/> | ||||
467 | </context> | ||||
468 | | ||||
469 | <context name="rvalue_builtin_function" attribute="g" lineEndContext="#pop"> | ||||
470 | <RegExpr String="[a-zA-Z_][a-zA-Z0-1_]*\s*\(" context="#pop!rvalue_builtin_call" lookAhead="true"/> | ||||
471 | <DetectIdentifier attribute="invalid" context="#pop"/> | ||||
472 | </context> | ||||
473 | | ||||
474 | <context name="rvalue_builtin_call" attribute="g" lineEndContext="#pop"> | ||||
475 | <DetectIdentifier attribute="builtin_func" context="#pop!rvalue_call_open_brace"/> | ||||
476 | </context> | ||||
477 | | ||||
478 | | ||||
479 | <!-- Library functions have nothing special comparing to other functions. They just have different | ||||
480 | highlighting colors. It is valid to shadow function with a variable with the same name, | ||||
481 | although it is not recommended and might be considered as a warning by various linters. | ||||
482 | --> | ||||
483 | <context name="@lvalue_library_functions" attribute="g" lineEndContext="#stay"> | ||||
484 | <keyword String="utility_functions" context="#pop!lvalue_library_function" lookAhead="true"/> | ||||
485 | <keyword String="string_functions" context="#pop!lvalue_library_function" lookAhead="true"/> | ||||
486 | <keyword String="math_functions" context="#pop!lvalue_library_function" lookAhead="true"/> | ||||
487 | </context> | ||||
488 | | ||||
489 | <context name="lvalue_library_function" attribute="g" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!lvalue_var"> | ||||
490 | <RegExpr String="[a-zA-Z_][a-zA-Z0-1_]*\s*\(" context="#pop!lvalue_library_call" lookAhead="true"/> | ||||
491 | </context> | ||||
492 | | ||||
493 | <context name="lvalue_library_call" attribute="g" lineEndContext="#pop"> | ||||
494 | <DetectIdentifier attribute="library_func" context="#pop!lvalue_call_open_brace"/> | ||||
495 | </context> | ||||
496 | | ||||
497 | | ||||
498 | <context name="@rvalue_library_functions" attribute="g" lineEndContext="#stay"> | ||||
499 | <keyword String="utility_functions" context="#pop!rvalue_library_function" lookAhead="true"/> | ||||
500 | <keyword String="string_functions" context="#pop!rvalue_library_function" lookAhead="true"/> | ||||
501 | <keyword String="math_functions" context="#pop!rvalue_library_function" lookAhead="true"/> | ||||
502 | </context> | ||||
503 | | ||||
504 | <context name="rvalue_library_function" attribute="g" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!rvalue_var"> | ||||
505 | <RegExpr String="[a-zA-Z_][a-zA-Z0-1_]*\s*\(" context="#pop!rvalue_library_call" lookAhead="true"/> | ||||
506 | </context> | ||||
507 | | ||||
508 | <context name="rvalue_library_call" attribute="g" lineEndContext="#pop"> | ||||
509 | <DetectIdentifier attribute="library_func" context="#pop!rvalue_call_open_brace"/> | ||||
510 | </context> | ||||
511 | | ||||
512 | | ||||
513 | <!-- lvalue contexts represent expressions of the left side of the assignment operators or | ||||
514 | standalone function calls. | ||||
515 | --> | ||||
516 | <context name="lvalue" attribute="g" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!lvalue_exp"> | ||||
517 | <DetectSpaces/> | ||||
518 | <keyword String="m" attribute="m" context="#pop!lvalue_m_dot"/> | ||||
519 | <IncludeRules context="@lvalue_builtin_functions"/> | ||||
520 | <IncludeRules context="@lvalue_library_functions"/> | ||||
521 | <IncludeRules context="@comment"/> | ||||
522 | </context> | ||||
523 | | ||||
524 | <context name="lvalue_exp" attribute="g" lineEndContext="#pop"> | ||||
525 | <DetectSpaces/> | ||||
526 | <RegExpr String="[a-zA-Z_][a-zA-Z0-1_]*\s*\(" context="#pop!lvalue_call" lookAhead="true"/> | ||||
527 | <RegExpr String="[a-zA-Z_][a-zA-Z0-1_]*:" attribute="label" context="#pop"/> | ||||
528 | <DetectIdentifier context="#pop!lvalue_var" lookAhead="true"/> | ||||
529 | </context> | ||||
530 | | ||||
531 | <context name="lvalue_m_dot" attribute="g" lineEndContext="#pop"> | ||||
532 | <DetectSpaces/> | ||||
533 | <DetectChar char="." attribute="operator" context="#pop!lvalue_top"/> | ||||
534 | <IncludeRules context="@comment"/> | ||||
535 | <IncludeRules context="@lvalue_ops"/> | ||||
536 | </context> | ||||
537 | | ||||
538 | <context name="lvalue_top" attribute="g" lineEndContext="#pop"> | ||||
539 | <DetectSpaces/> | ||||
540 | <keyword String="top" attribute="top" context="#pop!lvalue_operator"/> | ||||
541 | <DetectIdentifier context="#pop!lvalue_exp" lookAhead="true"/> | ||||
542 | <IncludeRules context="@comment"/> | ||||
543 | </context> | ||||
544 | | ||||
545 | <context name="lvalue_var" attribute="g" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop"> | ||||
546 | <DetectIdentifier attribute="var" context="#pop!lvalue_var_postfix"/> | ||||
547 | </context> | ||||
548 | | ||||
549 | <context name="lvalue_var_postfix" attribute="g" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!lvalue_operator"> | ||||
550 | <AnyChar String="$%&!#" attribute="var" context="#pop!lvalue_operator"/> | ||||
551 | </context> | ||||
552 | | ||||
553 | <context name="lvalue_operator" attribute="g" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop"> | ||||
554 | <DetectSpaces/> | ||||
555 | <DetectChar char="." attribute="operator" context="#pop!lvalue_exp"/> | ||||
556 | <IncludeRules context="@lvalue_ops"/> | ||||
557 | </context> | ||||
558 | | ||||
559 | <context name="@lvalue_ops" attribute="g" lineEndContext="#stay"> | ||||
560 | <IncludeRules context="@lvalue_call_open_brace"/> | ||||
561 | <DetectChar char="[" attribute="operator" context="lvalue_array"/> | ||||
562 | <RegExpr String="(=|\+=|\-=|\*=|/=|\\=|<<=|>>=)" attribute="assign" context="#pop!rvalue"/> | ||||
563 | </context> | ||||
564 | | ||||
565 | <context name="lvalue_array" attribute="g" lineEndContext="#stay" fallthrough="true" fallthroughContext="rvalue"> | ||||
566 | <DetectSpaces/> | ||||
567 | <DetectChar char="," attribute="coma"/> | ||||
568 | <DetectChar char="]" attribute="operator" context="#pop!lvalue_operator"/> | ||||
569 | </context> | ||||
570 | | ||||
571 | <context name="lvalue_call" attribute="g" lineEndContext="#stay"> | ||||
572 | <DetectIdentifier attribute="func" context="#pop!lvalue_call_open_brace"/> | ||||
573 | </context> | ||||
574 | | ||||
575 | <context name="lvalue_call_open_brace" attribute="g" lineEndContext="#stay"> | ||||
576 | <IncludeRules context="@lvalue_call_open_brace"/> | ||||
577 | </context> | ||||
578 | | ||||
579 | <context name="@lvalue_call_open_brace" attribute="g" lineEndContext="#stay"> | ||||
580 | <DetectChar char="(" attribute="scope" context="lvalue_call_args"/> | ||||
581 | </context> | ||||
582 | | ||||
583 | <context name="lvalue_call_args" attribute="g" lineEndContext="#stay" fallthrough="true" fallthroughContext="rvalue"> | ||||
584 | <DetectSpaces/> | ||||
585 | <DetectChar char=")" attribute="scope" context="#pop#pop!lvalue_operator"/> | ||||
586 | <DetectChar char="," attribute="coma"/> | ||||
587 | </context> | ||||
588 | | ||||
589 | | ||||
590 | <!-- rvalue contexts represent expressions on the right side of assignment operators and arguments | ||||
591 | to other functions, 'print' calls, object keys, array values, etc. | ||||
592 | --> | ||||
593 | <context name="rvalue" attribute="g" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop"> | ||||
594 | <DetectSpaces/> | ||||
595 | <IncludeRules context="@comment"/> | ||||
596 | <IncludeRules context="@function"/> | ||||
597 | <IncludeRules context="@sub"/> | ||||
598 | <keyword String="unary" attribute="unary"/> | ||||
599 | <keyword String="end_of_scope" context="#pop#pop" lookAhead="true"/> | ||||
600 | <DetectChar char=""" attribute="string" context="#pop!string"/> | ||||
601 | <DetectChar char="[" attribute="operator" context="#pop!array"/> | ||||
602 | <DetectChar char="(" attribute="scope" context="#pop!rvalue_scope"/> | ||||
603 | <DetectChar char="{" attribute="operator" context="#pop!object"/> | ||||
604 | <keyword String="constants" attribute="constant" context="#pop!rvalue_operator"/> | ||||
605 | <RegExpr String="[-+]?[0-9]*\.[0-9]" context="#pop!float" lookAhead="true"/> | ||||
606 | <RegExpr String="[-+]?[0-9]" context="#pop!int" lookAhead="true"/> | ||||
607 | <keyword String="m" attribute="m" context="#pop!rvalue_m_dot"/> | ||||
608 | <IncludeRules context="@rvalue_builtin_functions"/> | ||||
609 | <IncludeRules context="@rvalue_library_functions"/> | ||||
610 | <IncludeRules context="@rvalue_dot"/> | ||||
611 | </context> | ||||
612 | | ||||
613 | <context name="rvalue_var" attribute="g" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop"> | ||||
614 | <DetectIdentifier attribute="var" context="#pop!rvalue_var_postfix"/> | ||||
615 | </context> | ||||
616 | | ||||
617 | <context name="rvalue_var_postfix" attribute="g" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!rvalue_operator"> | ||||
618 | <AnyChar String="$%&!#" attribute="var" context="#pop!rvalue_operator"/> | ||||
619 | </context> | ||||
620 | | ||||
621 | <context name="rvalue_operator" attribute="g" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!rvalue_end"> | ||||
622 | <DetectSpaces/> | ||||
623 | <DetectChar char="." attribute="operator" context="#pop!rvalue_dot"/> | ||||
624 | <IncludeRules context="@rvalue_ops"/> | ||||
625 | </context> | ||||
626 | | ||||
627 | <context name="@rvalue_ops" attribute="g" lineEndContext="#stay"> | ||||
628 | <IncludeRules context="@rvalue_call_open_brace"/> | ||||
629 | <DetectChar char="[" attribute="operator" context="#pop!array"/> | ||||
630 | </context> | ||||
631 | | ||||
632 | <context name="rvalue_end" attribute="g" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop"> | ||||
633 | <DetectSpaces/> | ||||
634 | <RegExpr String="(=|<>|<<|>>|<=|>=|<|>|\^|\-|\+|\*|\/|\\)" context="#pop!rvalue_binary" lookAhead="true"/> | ||||
635 | <RegExpr String="(and|or|mod)[\W]" insensitive="true" context="#pop!rvalue_binary" lookAhead="true"/> | ||||
636 | </context> | ||||
637 | | ||||
638 | <context name="rvalue_binary" attribute="invalid" lineEndContext="#stay"> | ||||
639 | <DetectSpaces/> | ||||
640 | <RegExpr String="(=|<>|<<|>>|<=|>=|<|>|\^|\-|\+|\*|\/|\\|and|or|mod)" insensitive="true" attribute="binary" context="#pop!rvalue"/> | ||||
641 | </context> | ||||
642 | | ||||
643 | <context name="rvalue_m_dot" attribute="g" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!rvalue_end"> | ||||
644 | <DetectSpaces/> | ||||
645 | <DetectChar char="." attribute="operator" context="#pop!rvalue_top"/> | ||||
646 | <IncludeRules context="@comment"/> | ||||
647 | <IncludeRules context="@rvalue_ops"/> | ||||
648 | </context> | ||||
649 | | ||||
650 | <context name="rvalue_top" attribute="g" lineEndContext="#pop"> | ||||
651 | <DetectSpaces/> | ||||
652 | <keyword String="top" attribute="top" context="#pop!rvalue_operator"/> | ||||
653 | <DetectIdentifier context="#pop!rvalue_dot" lookAhead="true"/> | ||||
654 | <IncludeRules context="@comment"/> | ||||
655 | </context> | ||||
656 | | ||||
657 | <context name="rvalue_scope" attribute="g" lineEndContext="#stay" fallthrough="true" fallthroughContext="rvalue"> | ||||
658 | <DetectSpaces/> | ||||
659 | <DetectChar char=")" attribute="scope" context="#pop!rvalue_operator"/> | ||||
660 | </context> | ||||
661 | | ||||
662 | <context name="rvalue_dot" attribute="g" lineEndContext="#stay"> | ||||
663 | <IncludeRules context="@rvalue_dot"/> | ||||
664 | </context> | ||||
665 | | ||||
666 | <context name="@rvalue_dot" attribute="g" lineEndContext="#stay"> | ||||
667 | <RegExpr String="[a-zA-Z_][a-zA-Z0-1_]*\s*\(" context="#pop!rvalue_call" lookAhead="true"/> | ||||
668 | <DetectIdentifier context="#pop!rvalue_var" lookAhead="true"/> | ||||
669 | </context> | ||||
670 | | ||||
671 | | ||||
672 | <!-- Other rvalue expressions. --> | ||||
673 | <context name="string" attribute="string" lineEndContext="#pop#pop"> | ||||
674 | <DetectChar char=""" attribute="string" context="#pop!rvalue_operator"/> | ||||
675 | </context> | ||||
676 | | ||||
677 | <context name="array" attribute="g" lineEndContext="#stay" fallthrough="true" fallthroughContext="rvalue"> | ||||
678 | <DetectSpaces/> | ||||
679 | <DetectChar char="," attribute="coma"/> | ||||
680 | <DetectChar char="]" attribute="operator" context="#pop!rvalue_operator"/> | ||||
681 | </context> | ||||
682 | | ||||
683 | <context name="object" attribute="g" lineEndContext="#stay"> | ||||
684 | <DetectSpaces/> | ||||
685 | <IncludeRules context="@comment"/> | ||||
686 | <DetectChar char="," attribute="coma"/> | ||||
687 | <DetectChar char="}" attribute="operator" context="#pop!rvalue_operator"/> | ||||
688 | <DetectChar char=""" attribute="var" context="object_param_string"/> | ||||
689 | <DetectIdentifier attribute="var" context="object_param_colon"/> | ||||
690 | </context> | ||||
691 | | ||||
692 | <context name="object_param_string" attribute="var" lineEndContext="#pop"> | ||||
693 | <DetectChar char=""" attribute="var" context="#pop!object_param_colon"/> | ||||
694 | </context> | ||||
695 | | ||||
696 | <context name="object_param_colon" attribute="g" lineEndContext="#pop"> | ||||
697 | <DetectSpaces/> | ||||
698 | <IncludeRules context="@comment"/> | ||||
699 | <DetectChar char=":" attribute="operator" context="#pop!rvalue"/> | ||||
700 | </context> | ||||
701 | | ||||
702 | <context name="float" attribute="float" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop"> | ||||
703 | <!-- documentation says this is a valid string, but implementation gives compile error --> | ||||
704 | <!--<RegExpr String="[-+]?[0-9]*\.[0-9]+([eE][-+]?[0-9]+)?\$" attribute="string" context="postfix_delimiter"/>--> | ||||
705 | <!--<RegExpr String="[-+]?[0-9]*\.[0-9]+([eE][-+]?[0-9]+)?[%&]" attribute="dec" context="postfix_delimiter"/>--> | ||||
706 | <RegExpr String="[-+]?[0-9]*\.[0-9]+([eE][-+]?[0-9]+)?[!#]?" attribute="float" context="postfix_delimiter"/> | ||||
707 | </context> | ||||
708 | | ||||
709 | <context name="int" attribute="dec" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop"> | ||||
710 | <!-- documentation says this is a valid string, but implementation gives compile error --> | ||||
711 | <!--<RegExpr String="[-+]?[0-9]*\$" attribute="string" context="postfix_delimiter"/>--> | ||||
712 | <RegExpr String="[-+]?[0-9]*[!#]" attribute="float" context="postfix_delimiter"/> | ||||
713 | <RegExpr String="[-+]?[0-9]*[%&]?" attribute="dec" context="postfix_delimiter"/> | ||||
714 | </context> | ||||
715 | | ||||
716 | <context name="postfix_delimiter" attribute="g" lineEndContext="#pop#pop" fallthrough="true" fallthroughContext="#pop#pop"> | ||||
717 | <RegExpr String="[\s\W]" context="#pop#pop!rvalue_operator" lookAhead="true"/> | ||||
718 | </context> | ||||
719 | | ||||
720 | <context name="rvalue_call" attribute="g" lineEndContext="#stay"> | ||||
721 | <DetectIdentifier attribute="func" context="#pop!rvalue_call_open_brace"/> | ||||
722 | </context> | ||||
723 | | ||||
724 | <context name="rvalue_call_open_brace" attribute="g" lineEndContext="#stay"> | ||||
725 | <IncludeRules context="@rvalue_call_open_brace"/> | ||||
726 | </context> | ||||
727 | | ||||
728 | <context name="@rvalue_call_open_brace" attribute="g" lineEndContext="#stay"> | ||||
729 | <DetectChar char="(" attribute="scope" context="rvalue_call_args"/> | ||||
730 | </context> | ||||
731 | | ||||
732 | <context name="rvalue_call_args" attribute="g" lineEndContext="#stay" fallthrough="true" fallthroughContext="rvalue"> | ||||
733 | <DetectSpaces/> | ||||
734 | <DetectChar char=")" attribute="scope" context="#pop#pop!rvalue_operator"/> | ||||
735 | <DetectChar char="," attribute="coma"/> | ||||
736 | </context> | ||||
737 | | ||||
738 | </contexts> | ||||
739 | | ||||
740 | | ||||
741 | | ||||
742 | | ||||
743 | <itemDatas> | ||||
744 | <itemData name="g" defStyleNum="dsNormal"/> | ||||
745 | <itemData name="import" defStyleNum="dsImport"/> | ||||
746 | <itemData name="func" defStyleNum="dsFunction"/> | ||||
747 | <itemData name="keyword" defStyleNum="dsKeyword"/> | ||||
748 | <itemData name="control" defStyleNum="dsControlFlow"/> | ||||
749 | <itemData name="assign" defStyleNum="dsOperator"/> | ||||
750 | <itemData name="binary" defStyleNum="dsOperator"/> | ||||
751 | <itemData name="unary" defStyleNum="dsOperator"/> | ||||
752 | <itemData name="operator" defStyleNum="dsOperator"/> | ||||
753 | <itemData name="scope" defStyleNum="dsOperator"/> | ||||
754 | <itemData name="coma" defStyleNum="dsOperator"/> | ||||
755 | <itemData name="type" defStyleNum="dsDataType"/> | ||||
756 | <itemData name="var" defStyleNum="dsVariable"/> | ||||
757 | <itemData name="comment" defStyleNum="dsComment"/> | ||||
758 | <itemData name="print" defStyleNum="dsBuiltIn"/> | ||||
759 | <itemData name="builtin_func" defStyleNum="dsBuiltIn"/> | ||||
760 | <itemData name="library_func" defStyleNum="dsBuiltIn"/> | ||||
761 | <itemData name="dec" defStyleNum="dsDecVal"/> | ||||
762 | <itemData name="float" defStyleNum="dsFloat"/> | ||||
763 | <itemData name="string" defStyleNum="dsString"/> | ||||
764 | <itemData name="constant" defStyleNum="dsConstant"/> | ||||
765 | <itemData name="macro" defStyleNum="dsPreprocessor"/> | ||||
766 | <itemData name="label" defStyleNum="dsSpecialChar"/> | ||||
767 | <itemData name="line_break" defStyleNum="dsSpecialChar"/> | ||||
768 | <itemData name="m" defStyleNum="dsExtension"/> | ||||
769 | <itemData name="top" defStyleNum="dsExtension"/> | ||||
770 | <itemData name="invalid" defStyleNum="dsError"/> | ||||
771 | </itemDatas> | ||||
772 | | ||||
773 | </highlighting> | ||||
774 | | ||||
775 | | ||||
776 | | ||||
777 | | ||||
778 | <general> | ||||
779 | <comments> | ||||
780 | <comment name="singleLine" start="'"/> | ||||
781 | </comments> | ||||
782 | | ||||
783 | <keywords casesensitive="0" additionalDeliminator="'"/> | ||||
784 | </general> | ||||
785 | | ||||
786 | </language> |