-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflatdata.sublime-syntax
347 lines (315 loc) · 9.85 KB
/
flatdata.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
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
name: Flatdata
file_extensions: [flatdata]
scope: source.flatdata
variables:
identifier: '\b[A-Za-z_][A-Za-z_0-9]*\b'
qualified_identifier: '\b[A-Za-z_\.][A-Za-z_\.0-9]*\b'
basic_type: '\b(bool|i8|u8|i16|u16|i32|u32|i64|u64)\b'
bit_width: '\b[0-9]+\b'
dec_literal: '\b[0-9]+\b'
hex_literal: '\b0x[0-9A-Fa-f]+\b'
contexts:
prototype:
- include: comments
comments:
- match: '//'
scope: punctuation.definition.comment.flatdata
push:
- meta_scope: comment.line.double-slash.flatdata
- match: $\n?
pop: true
- match: '/\*'
scope: punctuation.definition.comment.begin.flatdata
push:
- meta_scope: comment.block.flatdata
- match: '\*/'
scope: punctuation.definition.comment.end.flatdata
pop: true
parenthesis_identifier:
- match: '\('
scope: punctuation.section.parens.begin.flatdata
set:
- match: '{{identifier}}'
scope: variable.parameter.flatdata
set:
- match: '\)'
scope: punctuation.section.parens.end.flatdata
pop: true
const_decoration:
- match: '@\bconst\b'
scope: keyword.control.flatdata
push:
- include: parenthesis_identifier
range_decoration:
- match: '@\brange\b'
scope: keyword.control.flatdata
push:
- include: parenthesis_identifier
field:
- include: const_decoration
- include: range_decoration
- match: '{{identifier}}'
scope: variable.flatdata
push:
- match: ':'
set:
- match: '{{basic_type}}|{{identifier}}'
scope: storage.type.flatdata
set:
- match: ';'
scope: punctuation.terminator.flatdata
pop: true
- match: ':'
set:
- match: '{{bit_width}}'
scope: storage.modifier.flatdata
set:
- match: ';'
scope: punctuation.terminator.flatdata
pop: true
struct:
- match: '\bstruct\b'
scope: storage.type.flatdata
push:
- match: '{{identifier}}'
scope: entity.name.struct.flatdata
set:
- match: '{'
scope: punctuation.section.braces.begin.flatdata
set:
- meta_scope: meta.struct.flatdata
- include: field
- match: '}'
scope: punctuation.section.braces.end.flatdata
pop: true
enum_entry:
- match: '{{identifier}}'
scope: parameter.enum.entry.flatdata
push:
- match: '='
scope: punctuation.enum.entry.value
set:
- match: '{{dec_literal}}'
scope: parameter.enum.entry.value
set:
- match: ','
scope: punctuation.separator.enum.entry.flatdata
pop: true
- match: ','
scope: punctuation.separator.enum.entry.flatdata
pop: true
- match: (?=\S) # Last entry
pop: true
enum_list:
- match: '{'
scope: punctuation.section.braces.begin.flatdata
set:
- meta_scope: meta.enum.flatdata
- include: enum_entry
- match: '}'
scope: punctuation.section.braces.end.flatdata
pop: true
enum:
- match: '\benum\b'
scope: storage.type.flatdata
push:
- match: '{{identifier}}'
scope: entity.name.enum.flatdata
set:
- match: ':'
scope: punctuation.enum.type
set:
- match: '{{basic_type}}'
scope: storage.enum.type
set:
- match: ':'
scope: punctuation.enum.bit_width
set:
- match: '{{dec_literal}}'
scope: storage.enum.bit_width
- include: enum_list
- include: enum_list
vector:
- match: '\bvector\b'
scope: storage.type.flatdata
set:
- match: '<'
scope: punctuation.definition.generic.begin.flatdata
set:
- match: '{{qualified_identifier}}'
scope: variable.parameter.flatdata
set:
- match: '>'
scope: punctuation.definition.generic.end.flatdata
set:
- match: ';'
scope: punctuation.terminator.flatdata
pop: true
multivector:
- match: '\bmultivector\b'
scope: storage.type.flatdata
set:
- match: '<'
scope: punctuation.definition.generic.begin.flatdata
set:
- match: '{{bit_width}}'
scope: storage.modifier.flatdata
set:
- match: ','
scope: punctuation.separator.sequence.flatdata
push:
- match: '{{qualified_identifier}}'
scope: variable.parameter.flatdata
pop: true
- match: '>'
scope: punctuation.definition.generic.end.flatdata
set:
- match: ';'
scope: punctuation.terminator.flatdata
pop: true
single_object:
- match: '{{qualified_identifier}}'
scope: storage.type.flatdata
set:
- match: ';'
scope: punctuation.terminator.flatdata
pop: true
raw_data:
- match: '\braw_data\b'
scope: storage.type.flatdata
set:
- match: ';'
scope: punctuation.terminator.flatdata
pop: true
archive_resource:
- match: '\barchive\b'
scope: storage.modifier.flatdata
set:
- match: '{{qualified_identifier}}'
scope: storage.type.flatdata
set:
- match: ';'
scope: punctuation.terminator.flatdata
pop: true
resource_type:
- include: raw_data
- include: vector
- include: multivector
- include: archive_resource
- include: single_object # has to be last in the list, since the others have higher priority
explicit_reference:
- match: '@\bexplicit_reference\b'
scope: keyword.control.flatdata
push:
- match: '\('
scope: punctuation.section.parens.begin.flatdata
set:
- match: '{{qualified_identifier}}'
scope: variable.parameter.flatdata
set:
- match: ','
scope: punctuation.separator.mapping.pair.flatdata
set:
- match: '{{qualified_identifier}}'
scope: variable.parameter.flatdata
set:
- match: '\)'
scope: punctuation.section.parens.end.flatdata
pop: true
qualified_identifier_list:
- match: '{{qualified_identifier}}'
scope: variable.parameter.flatdata
set:
- match: '\)'
scope: punctuation.section.parens.end.flatdata
pop: true
- match: ','
scope: punctuation.separator.sequence.flatdata
set:
- include: qualified_identifier_list
bound_implicitly:
- match: '@\bbound_implicitly\b'
scope: keyword.control.flatdata
push:
- match: '\('
scope: punctuation.section.parens.begin.flatdata
set:
- match: '{{identifier}}'
scope: variable.parameter.flatdata
set:
- match: ':'
scope: punctuation.separator.mapping.key-value.flatdata
set:
- include: qualified_identifier_list
optional_decoration:
- match: '@\boptional\b'
scope: keyword.control.flatdata
resource_decorations:
- include: explicit_reference
- include: optional_decoration
archive_decorations:
- include: bound_implicitly
resource:
- include: resource_decorations
- match: '{{identifier}}'
scope: variable.flatdata
push:
- match: ':'
set:
- include: resource_type
archive:
- include: archive_decorations
- match: '\barchive\b'
scope: storage.type.flatdata
push:
- match: '{{identifier}}'
scope: entity.name.struct.flatdata
set:
- match: '{'
set:
- meta_scope: meta.struct.flatdata
- include: resource
- match: '}'
pop: true
constant:
- match: '\bconst\b'
scope: storage.modifier.flatdata
push:
- match: '{{basic_type}}'
scope: storage.type.flatdata
set:
- match: '{{identifier}}'
scope: variable.other.constant.flatdata
set:
- match: '='
scope: keyword.operator.assignment.flatdata
set:
- match: '{{dec_literal}}'
scope: constant.numeric.integer.flatdata
- match: '{{hex_literal}}'
scope: constant.numeric.hex.flatdata
- match: ';'
pop: true
flatdata_entry:
- include: struct
- include: enum
- include: archive
- include: constant
namespace:
- match: '\bnamespace\b'
scope: keyword.other.flatdata
push:
- match: '{{identifier}}'
scope: entity.name.namespace.flatdata
set:
- match: '{'
set:
- meta_scope: meta.namespace.flatdata
- include: flatdata_entry
- match: '}'
pop: true
main:
- include: namespace