-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAngelScript.sublime-syntax
706 lines (651 loc) · 19.7 KB
/
AngelScript.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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
%YAML 1.2
---
name: Crackshell AngelScript
file_extensions:
- as
- asc
- mas
scope: source.as
variables:
identifier: '[A-Za-z_][A-Za-z0-9_]*'
number: ((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?
primitives: (int|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|bool|float|double|bool|auto|void|array|dictionary|ref)
class_modifiers: '(abstract|mixin)'
definition_modifiers: '(protected|private)'
language_variables: '(this)'
language_support_functions: '(GetVar(Int|Float|Bool|String|Ivec2|Vec[234])|GetParam(Int|Long|Float|Bool|I?Vec[234]|String|Array|Dictionary)|HashString|SetVar|AddVar|AddFunction|print|xy|xyz|xyzw|atan|sin|asin|cos|acos|sqrt|pow|pow2|round|roundl|floor|ceil|log|normalize|dot|length|lengthsq|max|min|clamp|randf|randi|randdir|randfn|addrot|rottowards|capangle|angdiff|dist|distsq|formatTime|ease|formatThousands|formatInt|formatFloat|lerp|ilerp|sign|tocolor|i?vec[234]|UnitPtr)'
control_keywords_single: '(return|break|continue)'
control_keywords: '(if|else|in|while|do|switch|try|catch)'
operators_bitwise: '([|&^~]|<{2,3}|>{2,3})'
operators_arithmetic: '[+\-\*/%]'
operators_assignment: (=|{{operators_arithmetic}}=|{{operators_bitwise}}=|\+\+|--)
operators_logical: '(\|\||&&|==|!=?|<=|>=|<(?!<)|>(?!>))'
operators_words: '(and|or|not|is)'
operators: '({{operators_bitwise}}|{{operators_arithmetic}}|{{operators_assignment}}|{{operators_logical}}|{{operators_words}})'
possible_typename: (const\s*)?({{primitives}}|(({{identifier}}::)*[A-Za-z_][A-Za-z0-9_<>@]*))(\s*&(in|out|inout)?\s*)?
contexts:
global:
- include: has-comments
- include: has-preprocessor
namespace:
- match: 'namespace'
scope: storage.type.namespace
set:
- meta_scope: meta.namespace
- include: global
- match: '{{identifier}}'
scope: entity.name.namespace
- match: '{'
scope: punctuation.section.block.begin
push:
- include: global
- include: has-namespaces
- include: has-interfaces
- include: has-classes
- include: has-enums
- include: has-definitions
- match: '(?=})'
pop: true
- match: '}'
scope: punctuation.section.block.end
pop: true
class:
- meta_scope: meta.class
- match: '\b{{class_modifiers}}\b'
scope: storage.modifier
- match: '\bclass\b'
scope: storage.type.class
set:
- include: global
- match: '{{identifier}}'
scope: entity.name.class
- match: ':'
scope: punctuation.separator
push:
- include: global
- match: '{{identifier}}'
scope: entity.other.inherited-class
- match: ','
scope: punctuation.separator
- match: '(?={)'
pop: true
- match: '{'
scope: punctuation.section.block.begin
push:
- include: global
- match: '(?={{identifier}}\s*\()'
push: function-constructor-definition
- include: has-definitions
- match: '(?=})'
pop: true
- match: '}'
scope: punctuation.section.block.end
pop: true
interface:
- match: 'interface'
scope: storage.type.interface
set:
- meta_scope: meta.interface
- include: global
- match: '{{identifier}}'
scope: entity.name.interface
- match: '{'
scope: punctuation.section.block.begin
push:
- include: global
- include: has-definitions
- match: '(?=})'
pop: true
- match: '}'
scope: punctuation.section.block.end
pop: true
enum:
- match: 'enum'
scope: storage.type.enum
set:
- meta_scope: meta.enum
- include: global
- match: '{{identifier}}'
scope: entity.name.enum
- match: '{'
scope: punctuation.section.block.begin
push:
- include: global
- match: '{{identifier}}'
push:
- include: global
- match: '='
scope: keyword.operator.assignment
push:
- include: global
- match: '(?=[,}])'
pop: true
- include: expression
- match: ','
scope: punctuation.separator
pop: true
- match: '(?=})'
pop: true
- match: '(?=})'
pop: true
- match: '}'
scope: punctuation.section.block.end
pop: true
stringescapes:
- match: '\\.'
scope: constant.character.escape
sstring:
- meta_scope: meta.string string.quoted.single
- include: stringescapes
- match: "'"
scope: punctuation.definition.string.end
pop: true
- match: '$'
pop: true
dstring:
- meta_scope: meta.string string.quoted.double
- include: stringescapes
- match: '"'
scope: punctuation.definition.string.end
pop: true
- match: '$'
pop: true
tstring:
- meta_scope: meta.string string.quoted.triple
- match: '"""'
scope: punctuation.definition.string.end
pop: true
expression-in-parens:
- include: global
- match: '\('
scope: punctuation.section.parens.begin
push:
- include: global
- include: expression
- match: '\)'
scope: punctuation.section.parens.end
set:
- match: '\.'
scope: punctuation.accessor
- match: ''
pop: true
expression-has-functioncall:
- match: '\bcast(?=<)'
scope: keyword.other
push:
- include: global
- match: '<'
scope: punctuation.definition.generic.begin
push: typename
- match: '>'
scope: punctuation.definition.generic.end
set: expression-in-parens
- match: '\b{{primitives}}(?=\()'
scope: storage.type
push: expression-in-parens
- match: '(super)\s*(?=\()'
scope: meta.function-call
captures:
1: variable.language
push: expression-in-parens
- match: '(?=({{identifier}}\.?)+\s*(\())'
push:
- include: global
- meta_scope: meta.function-call
- match: '({{language_variables}})\s*(\.)'
captures:
1: variable.language
2: punctuation.accessor
- match: '(m_{{identifier}})\s*(\.)'
captures:
1: variable.other.member
2: punctuation.accessor
- match: '({{identifier}})\s*(\.)'
captures:
1: variable.other
2: punctuation.accessor
- match: '(?=({{identifier}})\s*(\())'
push:
- match: '\b{{language_support_functions}}\b'
scope: support.function
- match: '{{identifier}}'
scope: entity.name.function
- match: '\('
scope: punctuation.section.parens.begin
set:
- include: global
- include: expression
- include: expression-in-parens
expression-has-operators:
- match: '(?=@?\(?\s*\b({{identifier}}\.?)+\s*\)?\s*({{operators_assignment}}|\[))'
push:
- match: '@'
scope: keyword.other
- match: '(?=\()'
set: expression
- match: '{{language_variables}}'
scope: variable.language
set: expression
- match: 'm_{{identifier}}'
scope: variable.other.member
set: expression
- match: '{{identifier}}'
scope: variable.other
set: expression
expression-has-namespace-accessor:
- match: '(@)?({{identifier}})(?=::)'
captures:
1: keyword.other
2: entity.name.namespace
push:
- match: '::'
scope: punctuation.separator
pop: true
expression:
- meta_scope: meta.expression
- match: '\b{{operators_words}}\b'
scope: keyword.operator.word
- match: '\b(function)(?=\()'
scope: storage.type.function
push:
- include: global
- match: '\('
scope: punctuation.section.parens.begin
push:
- match: '{{identifier}}'
scope: variable.parameter
- match: ','
scope: punctuation.separator
- match: '\)'
scope: punctuation.section.parens.end
pop: true
- match: '{'
scope: punctuation.section.block.begin
set: code-scope
- include: expression-has-functioncall
- match: '\b{{number}}\b'
scope: constant.numeric
- match: '\b(true|false|null)\b'
scope: constant.language
- match: "'"
scope: punctuation.definition.string.begin
push: sstring
- match: '"""'
scope: punctuation.definition.string.begin
push: tstring
- match: '"'
scope: punctuation.definition.string.begin
push: dstring
- include: expression-has-namespace-accessor
- match: '\b[A-Z][A-Z0-9_]+\b'
scope: entity.name.constant
- match: '@'
scope: keyword.other
- match: '{{language_variables}}'
scope: variable.language
- match: 'm_{{identifier}}'
scope: variable.other.member
- match: '{{identifier}}'
scope: variable.other
- match: '{'
scope: punctuation.section.braces.begin
push:
- include: global
- include: expression
- match: '(?=\()'
push: expression-in-parens
- match: '\['
scope: punctuation.section.brackets.begin
push:
- include: global
- include: expression
- match: '}'
scope: punctuation.section.braces.end
pop: true
- match: '(?=\))'
pop: true
- match: '\]'
scope: punctuation.section.brackets.end
set:
- include: global
- match: '\.'
scope: punctuation.accessor
- match: ''
pop: true
- match: '{{operators_logical}}'
scope: keyword.operator.logical
- match: '{{operators_assignment}}'
scope: keyword.operator.assignment
- match: '{{operators_arithmetic}}'
scope: keyword.operator.arithmetic
- match: '{{operators_bitwise}}'
scope: keyword.operator.bitwise
- match: '\.'
scope: punctuation.accessor
- match: ','
scope: punctuation.separator
- match: ';'
scope: punctuation.terminator
pop: true
code-scope:
- meta_scope: meta.codescope
- include: global
- match: ';'
scope: punctuation.terminator
- match: '{'
scope: punctuation.section.block.begin
push: code-scope
- match: '}'
scope: punctuation.section.block.end
pop: true
- include: expression-has-namespace-accessor
- match: '\b{{control_keywords_single}}\b'
scope: keyword.control
push: expression
- match: '\belse\b'
scope: keyword.control
- match: '\b(case)\s+(?=.*:)'
captures:
1: keyword.control
push:
- include: global
- match: ':'
scope: punctuation.separator
pop: true
- include: expression
- match: '\b(for)\s*'
captures:
1: keyword.control
push:
- include: global
- match: '\('
scope: punctuation.section.parens.begin
push:
- include: global
- match: '(?={{possible_typename}}\s*{{identifier}}\s*=)'
push:
- variable-definition
- typename
- match: '(?=\b({{identifier}}\.?)+\s*{{operators}})'
push:
- match: '{{language_variables}}'
scope: variable.language
push: expression
- match: 'm_{{identifier}}'
scope: variable.other.member
push: expression
- match: '{{identifier}}'
scope: variable.other
push: expression
- match: '(?=\))'
pop: true
- match: ';'
scope: punctuation.terminator
- match: '\)'
scope: punctuation.section.parens.end
pop: true
- match: '(?={)'
pop: true
- match: '{'
scope: punctuation.section.block.begin
set: code-scope
- match: ''
pop: true
- match: '\b{{control_keywords}}\b'
scope: keyword.control
push:
- include: expression-in-parens
- match: '{'
scope: punctuation.section.block.begin
set: code-scope
- match: '(?=\()'
push: expression-in-parens
- include: expression-has-functioncall
- include: expression-has-operators
- include: has-definitions-in-code
typename:
- match: '\b(const)\s+\b'
captures:
1: storage.modifier
- match: '\b({{identifier}})(::)'
captures:
1: entity.name.namespace
2: punctuation.separator
- match: '\b({{primitives}}|{{identifier}})\b'
scope: storage.type
- match: '\s*(&(in|out|inout)?)'
captures:
1: keyword.other
pop: true
- match: '@'
scope: keyword.other
- match: '<'
scope: punctuation.definition.generic.begin
push:
- match: '>'
scope: punctuation.definition.generic.end
pop: true
- include: typename
- match: ''
pop: true
generic-container:
- match: '<'
scope: punctuation.definition.generic.begin
push: generic-container
- match: '>'
scope: punctuation.definition.generic.end
pop: true
- match: ''
push: typename
definition:
- include: global
- match: '(?={{identifier}}\s*\()'
set: function-definition
- match: '(?={{identifier}}\s*)'
set: variable-definition
definition-in-code:
- include: global
- match: '(?={{identifier}}\s*[=;\(])'
set: variable-definition
variable-definition-value:
- match: '{'
scope: punctuation.section.brackets.begin
set:
- include: global
- match: '\b{{definition_modifiers}}\b'
scope: storage.modifier
- match: '\b(get|set)\b'
scope: keyword.other
push:
- include: global
- match: '{'
scope: punctuation.section.block.begin
set:
- meta_scope: meta.function
- include: code-scope
- match: ';'
pop: true
- match: '}'
scope: punctuation.section.brackets.end
pop: true
- match: '='
scope: keyword.operator.assignment
set: expression
- match: '\('
scope: punctuation.section.params.begin
set: expression
- match: ';'
scope: punctuation.terminator
pop: true
variable-definition:
- match: 'm_{{identifier}}'
scope: variable.other.member
set: variable-definition-value
- match: '{{identifier}}'
scope: variable.other
set: variable-definition-value
function-definition:
- include: global
- meta_scope: meta.function
- match: '{{identifier}}'
scope: entity.name.function
- include: function-definition-params
function-constructor-definition:
- include: global
- match: '{{identifier}}'
scope: entity.name.function.constructor
- include: function-definition-params
function-parameter-definition:
- include: global
- match: '(?={{identifier}}\s*[,\)]?)'
set:
- include: global
- match: '{{identifier}}'
scope: variable.parameter
- match: '='
scope: keyword.operator.assignment
push:
- include: global
- match: '(?=[,\)])'
pop: true
- include: expression
- match: ','
scope: punctuation.separator
pop: true
- match: '(?=\))'
pop: true
function-definition-params:
- match: '\('
scope: punctuation.section.params.begin
push:
- meta_scope: meta.function meta.function.parameters
- include: global
- match: '(?={{possible_typename}}\s+&?{{identifier}})'
push:
- function-parameter-definition
- typename
- match: '\)'
scope: punctuation.section.params.end
pop: true
- match: ';'
scope: punctuation.terminator
pop: true
- match: '{'
scope: punctuation.section.block.begin
set:
- meta_scope: meta.function
- include: code-scope
comment-block:
- match: '\*/'
scope: punctuation.definition.comment
pop: true
has-comments:
- match: '(///).*$'
scope: comment.block.documentation
captures:
1: punctuation.definition.comment
- match: '(//).*$'
scope: comment.line
captures:
1: punctuation.definition.comment
- match: '(?=/\*\*[^/])'
push:
- meta_scope: comment.block.documentation
- match: '/\*\*'
scope: punctuation.definition.comment
- include: comment-block
- match: '(?=/\*)'
push:
- meta_scope: comment.block
- match: '/\*'
scope: punctuation.definition.comment
- include: comment-block
preprocessor-expression:
- include: global
- match: '$'
pop: true
- include: expression
has-preprocessor:
- match: '^\s*([#%])'
captures:
1: keyword.control.import
push:
- meta_scope: meta.preprocessor
- match: '//.*'
scope: comment.line
- match: '(?i)(if|else|endif)\b'
scope: support.function
set: preprocessor-expression
- match: '(PROFILE_START|PROFILE_STOP)\b'
scope: support.function
set:
- meta_scope: string.unquoted
- match: '$'
pop: true
- match: '{{identifier}}'
scope: keyword.control.import
set: preprocessor-expression
- match: '$'
pop: true
has-namespaces:
- match: '\b(?=namespace)\b'
push: namespace
has-interfaces:
- match: '\b(?=interface)\b'
push: interface
has-classes:
- include: has-metadatas
- match: '\b(?=({{class_modifiers}}\s+)?class)\b'
push: class
has-enums:
- match: '\b(?=enum)\b'
push: enum
has-definitions-in-code:
- match: '(?=\b{{possible_typename}})'
push:
- definition-in-code
- typename
has-definitions:
- include: has-metadatas
- match: '\b{{definition_modifiers}}\b'
scope: storage.modifier
- match: '(?=\b{{possible_typename}})'
push:
- definition
- typename
has-metadatas:
- match: '^\s*\['
scope: punctuation.definition.annotation
push:
- meta_scope: meta.annotation
- match: '{{identifier}}'
scope: keyword.other
push:
- match: '='
scope: keyword.operator.assignment
push:
- match: '\b(true|false|null)\b'
scope: constant.language
- match: '{{number}}'
scope: constant.numeric
- match: '"'
scope: punctuation.definition.string.begin
push: dstring
- match: ''
scope: string.unquoted
- match: '(?=[\s\]])'
pop: true
- match: ''
pop: true
- match: '\]'
scope: punctuation.definition.annotation
pop: true
main:
- include: has-namespaces
- include: has-interfaces
- include: has-classes
- include: has-enums
- include: has-definitions
- include: global
- match: '}'
scope: invalid