-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
AmxxEditorPawn.sublime-syntax
303 lines (252 loc) · 8.49 KB
/
AmxxEditorPawn.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
%YAML 1.2
---
name: AmxxEditorPawn
file_extensions:
- inc
- sma
scope: source.sma
contexts:
# "AMXX-Pawn Syntax"
main:
- include: pawn_string
- include: pawn_character
- include: pawn_coment
- include: pawn_directives
- include: pawn_numbers
- include: pawn_keywords
- include: pawn_function
- include: pawn_post_keywords
- include: parens
- include: check_brackets
# Constants
- match: (true|false)
scope: constant.language
- include: Packages/AmxxEditor/AmxxEditorConsts.sublime-syntax
########################################################
# "PAWN Comments"
pawn_coment:
- match: ^/\* =(\s*.*?)\s*= \*/$\n?
scope: comment.block.pawn
captures:
1: meta.toc-list.banner.block.pawn
- match: /\*
scope: punctuation.definition.comment.pawn
push:
- meta_scope: comment.block.pawn
- match: \*/
scope: punctuation.definition.comment.pawn
pop: true
- match: \*/
scope: invalid.illegal.stray-comment-end.pawn
- match: ^// =(\s*.*?)\s*=\s*$\n?
scope: comment.line.banner.pawn
captures:
1: meta.toc-list.banner.line.pawn
- match: //
scope: punctuation.definition.comment.pawn
push:
- meta_scope: comment.line.double-slash.pawn
- match: '(\\)$\n'
captures:
1: punctuation.separator.continuation.pawn
- match: \n
pop: true
- match: '//'
scope: punctuation.definition.comment.pawn
push:
- meta_scope: comment.line.pawn
- match: $
pop: true
########################################################
# "Pawn Directives"
pawn_directives:
- match: ^\s*#
scope: keyword.other.preprocessor.pawn
push:
- include: directive_include
- include: directive_define
- include: directive_others
- include: directive_invalid
- match: '%\d' # Colored %1 %2...
scope: keyword.other.preprocessor.group.pawn
directive_include:
- match: (include)\s+((["][\t ]*[\w\-\/]*\.(inc|sma)?[\t ]*["])|([<][\t ]*[\w\-\/]*[\t ]*[>])|([^\s]*))
captures:
1: keyword.other.preprocessor.include.pawn
3: include_path.pawn
4: include_path.pawn
5: include_path.pawn
6: invalid.illegal.invalid-usage-of-preprocessor-directive.pawn
pop: true
directive_define:
- match: (define)\s+(([a-zA-Z_][^\s]*)|([^\s]*))
captures:
1: keyword.other.preprocessor.define.pawn
3: entity.name.constant.preprocessor
4: invalid.illegal.invalid-usage-of-preprocessor-directive.pawn
pop: true
directive_others:
- match: (if|elseif|else|endif|endinput|undef|endscript|error|file|line|tryinclude|emit|pragma|assert)
scope: keyword.other.preprocessor.define.pawn
push:
- meta_scope: entity.name.constant.preprocessor
- include: pawn_coment
- match: \n|$
pop: true
directive_invalid:
- match: '[^\n]*'
scope: invalid.illegal.invalid-usage-of-preprocessor-directive.pawn
pop: true
########################################################
# "PAWN String"
pawn_string:
- match: '"'
scope: punctuation.definition.string.begin.pawn
push:
- meta_scope: string.quoted.double.pawn
- match: '(")|(?<=^|[^\\])\s*(\n)'
captures:
1: punctuation.definition.string.end.pawn
2: invalid.illegal.unexpected-end-of-line.pawn
pop: true
- include: string_escaped_char
- include: string_placeholder
string_escaped_char:
- match: \^(\^|[abefnprtv\'"?]|[0-3]\d{,2}|[4-7]\d?|x[a-fA-F0-9]{,2}|u[a-fA-F0-9]{,4}|U[a-fA-F0-9]{,8})
scope: constant.character.escape.pawn
- match: '\\[drywR]'
scope: constant.character.escape.pawn
- match: \^.
scope: invalid.illegal.unknown-escape.pawn
string_placeholder:
- match: |-
(?x)%
((-?\d+)|\*(-?\d+\$)?)? # minimum field width
(\.((-?\d+)|\*(-?\d+\$)?)?)? # precision
[cbdiufXxasLNn%] # conversion type
scope: constant.other.placeholder.pawn
pawn_character:
- match: ('[\^]?.')|('.(.+'))
captures:
1: string.quoted.single.pawn
2: invalid.illegal.invalid-character.pawn
########################################################
# "PAWN Function"
pawn_function:
- include: function_definition
- include: function_call
function_definition:
- match: ^[\s;]*(public|stock|native|forward)\s+([A-Za-z_]\w*:\s*)?([A-Za-z_][\w_]*)[\s]*(\()
captures:
1: storage.type.function.pawn
2: storage.modifier.tag.pawn
3: support.function.definition.pawn
4: function.parens.begin.pawn keyword.brackets.paren.begin.AmxxPawn
push:
- meta_scope: amxxsupport.function.definition
- match: \)
scope: function.parens.end.pawn keyword.brackets.paren.end.AmxxPawn
pop: true
- include: main
- include: function_block
- match: '^[ ;]*([A-Za-z_]\w*:)?([A-Za-z_][\w_]*)[\s]*(\()'
captures:
1: storage.modifier.tag.pawn
2: support.function.definition.pawn
3: function.parens.begin.pawn keyword.brackets.paren.begin.AmxxPawn
push:
- meta_scope: amxxsupport.function.definition
- match: \)
scope: function.parens.end.pawn keyword.brackets.paren.end.AmxxPawn
pop: true
- include: main
- include: function_block
function_block:
- match: '\{'
scope: punctuation.definition.group.start
push:
- meta_scope: meta.block.pawn
- match: '\}'
scope: punctuation.definition.group.end
pop: true
- include: main
- include: function_call
- include: main
function_call:
- match: \s*([A-Za-z_][\w_]*)[\s|\\n]*(\()
captures:
1: support.function.call.pawn
2: function.parens.begin.pawn support.function.call.paren.pawn keyword.brackets.paren.begin.AmxxPawn
push:
- meta_content_scope: support.function.call.paren.pawn
- match: \)
scope: function.parens.end.pawn support.function.call.paren.pawn keyword.brackets.paren.end.AmxxPawn
pop: true
- include: main
########################################################
# "PAWN Numbers"
pawn_numbers:
- match: '(\d+)(\.{2})(\d+)'
captures:
1: constant.numeric.int.pawn
2: keyword.operator.switch-range.pawn
3: constant.numeric.int.pawn
- match: ([-]?0x[\da-f]+)
scope: constant.numeric.hex.pawn
- match: \b(\d+\.\d+)\b
scope: constant.numeric.float.pawn
- match: \b(\d+)\b
scope: constant.numeric.int.pawn
########################################################
# "PAWN Keywords"
pawn_post_keywords:
- match: '(?<!\?)\b[A-Za-z_]\w*\:'
scope: storage.modifier.tag.pawn
- match: \s*\b(public|stock|native|forward)\b
scope: storage.type.function.pawn
- match: (\[|\]|)
scope: keyword.brackets.pawn
pawn_keywords:
- match: \s*(case\b([^:\n]*):)\s+
captures:
1: keyword.control.pawn
2: storage.type.vars.pawn
- match: \s*\b(sizeof|charsmax|assert|break|case|continue|default|do|else|exit|for|goto|if|return|state|switch|while)\b
scope: keyword.control.pawn
- match: \s*\b(Float|new|enum|char|const|static)\b
scope: storage.type.vars.pawn
- match: (any\:\.\.\.)
scope: storage.modifier.tag.pawn
- match: (\-|\+|\*|\/|%|&|\||\^|<<|>>)?=
scope: keyword.operator.assignment.pawn
- match: (==|!=|<=|>=|<>|<|>)
scope: keyword.operator.comparison.pawn
- match: (\-\-|\+\+)
scope: keyword.operator.increment-decrement.pawn
- match: (\?|:)
scope: keyword.operator.ternary.pawn
- match: (\-|\+|\*|\/|%)
scope: keyword.operator.arithmetic.pawn
- match: (!|&&|\|\|)
scope: keyword.operator.logical.pawn
- match: (~|&|\||\^|<<|>>)
scope: keyword.operator.bitwise.pawn
- match: (\,|;)
scope: keyword.coma.pawn
- match: ({|})
scope: keyword.brace.pawn
########################################################
# "Check Brackets Closed"
parens:
- match: \(
scope: parens.pawn
push:
- meta_scope: meta.group.c
- match: \)
scope: parens.pawn
pop: true
- include: main
check_brackets:
- match: \)
scope: invalid.illegal.stray-bracket-end
########################################################