-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
source.nasal.js
307 lines (305 loc) · 11.3 KB
/
source.nasal.js
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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/BobDotCom/Nasal.tmbundle>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: [],
names: ['nasal'],
patterns: [
{match: '\\.{3}', name: 'support.type.ellipsis.nasal'},
{include: '#comment'},
{
match: '\\b([[:upper:]_][[:upper:][:digit:]_]*)\\b(?![\\.\\(\\\'\\"])',
name: 'constant.other.allcaps.nasal'
},
{
match: '\\b(0x(?i:[[:xdigit:]])+)',
name: 'constant.numeric.integer.hexadecimal.nasal'
},
{match: '\\b(0o[0-7]+)', name: 'constant.numeric.integer.octal.nasal'},
{
match: '\\b(?i:(\\d+\\.\\d*(e[\\-\\+]?\\d+)?))(?=[^[:alpha:]_])',
name: 'constant.numeric.float.nasal'
},
{
match: '(?<=[^[:alnum:]_])(?i:(\\.\\d+(e[\\-\\+]?\\d+)?))',
name: 'constant.numeric.float.nasal'
},
{
match: '\\b(?i:(\\d+e[\\-\\+]?\\d+))',
name: 'constant.numeric.float.nasal'
},
{match: '\\b\\d+', name: 'constant.numeric.integer.decimal.nasal'},
{match: '\\b(nil)\\b', name: 'constant.language.nil.nasal'},
{
begin:
'([a-zA-Z_?.$][\\w?.$]*)\\.([a-zA-Z_?.$][\\w?.$]*)\\s*(=)\\s*(func)\\s*(\\()',
beginCaptures: {
1: {name: 'support.class.nasal'},
2: {name: 'entity.name.function.nasal'},
3: {name: 'keyword.operator.nasal'},
4: {name: 'storage.type.function.nasal'},
5: {name: 'punctuation.definition.parameters.begin.nasal'}
},
end: '(\\))',
endCaptures: {1: {name: 'punctuation.definition.parameters.end.nasal'}},
name: 'meta.function.nasal',
patterns: [{include: '#function_parameters'}]
},
{
captures: {
1: {name: 'support.class.nasal'},
2: {name: 'entity.name.function.nasal'},
3: {name: 'keyword.operator.nasal'},
4: {name: 'storage.type.function.nasal'}
},
match:
'([a-zA-Z_?.$][\\w?.$]*)\\.([a-zA-Z_?.$][\\w?.$]*)\\s*(=)\\s*(func)\\b',
name: 'meta.function.nasal'
},
{
begin: '([a-zA-Z_?$][\\w?$]*)\\s*(=)\\s*(func)\\s*(\\()',
beginCaptures: {
1: {name: 'entity.name.function.nasal'},
2: {name: 'keyword.operator.nasal'},
3: {name: 'storage.type.function.nasal'},
4: {name: 'punctuation.definition.parameters.begin.nasal'}
},
end: '(\\))',
endCaptures: {1: {name: 'punctuation.definition.parameters.end.nasal'}},
name: 'meta.function.nasal',
patterns: [{include: '#function_parameters'}]
},
{
captures: {
1: {name: 'entity.name.function.nasal'},
2: {name: 'keyword.operator.nasal'},
3: {name: 'storage.type.function.nasal'}
},
match: '([a-zA-Z_?$][\\w?$]*)\\s*(=)\\s*(func)\\b',
name: 'meta.function.nasal'
},
{
begin: '([a-zA-Z_?$][\\w?$]*)\\s*(=)\\s*\\(\\s*(func)\\s*(\\()',
beginCaptures: {
1: {name: 'entity.name.function.nasal'},
2: {name: 'keyword.operator.nasal'},
3: {name: 'storage.type.function.nasal'},
4: {name: 'punctuation.definition.parameters.begin.nasal'}
},
end: '(\\))',
endCaptures: {1: {name: 'punctuation.definition.parameters.end.nasal'}},
name: 'meta.function.nasal',
patterns: [{include: '#function_parameters'}]
},
{
captures: {
1: {name: 'entity.name.function.nasal'},
2: {name: 'keyword.operator.nasal'},
3: {name: 'storage.type.function.nasal'}
},
match: '([a-zA-Z_?$][\\w?$]*)\\s*(=)\\s*\\(\\s*(func)\\b',
name: 'meta.function.nasal'
},
{
begin: '\\b([a-zA-Z_?.$][\\w?.$]*)\\s*:\\s*\\b(func)\\s*(\\()',
beginCaptures: {
1: {name: 'entity.name.function.nasal'},
2: {name: 'storage.type.function.nasal'},
3: {name: 'punctuation.definition.parameters.begin.nasal'}
},
end: '(\\))',
endCaptures: {1: {name: 'punctuation.definition.parameters.end.nasal'}},
name: 'meta.function.hash.nasal',
patterns: [{include: '#function_parameters'}]
},
{
captures: {
1: {name: 'entity.name.function.nasal'},
2: {name: 'storage.type.function.nasal'}
},
match: '\\b([a-zA-Z_?.$][\\w?.$]*)\\s*:\\s*\\b(func)\\b',
name: 'meta.function.hash.nasal'
},
{
begin: '\\b(func)\\s*(\\()',
beginCaptures: {
1: {name: 'storage.type.function.nasal'},
2: {name: 'punctuation.definition.parameters.begin.nasal'}
},
end: '(\\))',
endCaptures: {1: {name: 'punctuation.definition.parameters.end.nasal'}},
name: 'meta.function.nasal',
patterns: [{include: '#function_parameters'}]
},
{
captures: {1: {name: 'storage.type.function.nasal'}},
match: '\\b(func)\\b',
name: 'meta.function.nasal'
},
{
captures: {
1: {name: 'keyword.operator.new.nasal'},
2: {name: 'entity.name.type.instance.nasal'}
},
match: '(new)\\s+(\\w+(?:\\.\\w*)?)',
name: 'meta.class.instance.constructor'
},
{
match: '\\b(if|else|elsif|while|for|foreach|forindex)\\b',
name: 'keyword.control.nasal'
},
{
match:
'\\b(break(\\s+[A-Z]{2,16})?(?=\\s*(;|\\}))|continue(\\s+[A-Z]{2,16})?(?=\\s*(;|\\}))|([A-Z]{2,16})(?=\\s*;([^\\)#;]*?;){0,2}[^\\)#;]*?\\)))\\b',
name: 'keyword.control.nasal'
},
{
match:
'!|\\*|\\-|\\+|~|/|==|=|!=|<=|>=|<|>|!|\\?|\\:|\\*=|/=|\\+=|\\-=|~=|\\.\\.\\.|\\b(and|or)\\b',
name: 'keyword.operator.nasal'
},
{match: '\\b(me|arg|parents|obj)\\b', name: 'variable.language.nasal'},
{match: '\\b(return|var)\\b', name: 'storage.type.nasal'},
{
begin: "'",
beginCaptures: {0: {name: 'punctuation.definition.string.begin.nasal'}},
end: "'",
endCaptures: {0: {name: 'punctuation.definition.string.end.nasal'}},
name: 'string.quoted.single.nasal',
patterns: [{match: "\\\\'", name: 'constant.character.escape.nasal'}]
},
{
begin: '"',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.nasal'}},
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.end.nasal'}},
name: 'string.quoted.double.nasal',
patterns: [
{
match:
'\\\\(x[[:xdigit:]]{2}|[0-2][0-7]{,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|r|n|t|\\\\|")',
name: 'constant.character.escape.nasal'
},
{
match:
"%(?:%|(?:\\d+\\$)?[+-]?(?:[ 0]|'.{1})?-?\\d*(?:\\.\\d+)?[bcdeEufFgGosxX])",
name: 'constant.character.escape.nasal'
}
]
},
{
captures: {
1: {name: 'punctuation.definition.string.begin.nasal'},
2: {name: 'punctuation.definition.string.end.nasal'}
},
match: '(`).(`)',
name: 'string.other'
},
{match: '\\;', name: 'punctuation.terminator.statement.nasal'},
{
begin: '\\[',
beginCaptures: {0: {name: 'punctuation.section.scope.begin.nasal'}},
end: '\\]',
endCaptures: {0: {name: 'punctuation.section.scope.end.nasal'}},
patterns: [{include: '$self'}]
},
{
begin: '\\{',
beginCaptures: {0: {name: 'punctuation.section.scope.begin.nasal'}},
end: '\\}',
endCaptures: {0: {name: 'punctuation.section.scope.end.nasal'}},
patterns: [{include: '$self'}]
},
{
begin: '\\(',
beginCaptures: {0: {name: 'punctuation.section.scope.begin.nasal'}},
end: '\\)',
endCaptures: {0: {name: 'punctuation.section.scope.end.nasal'}},
patterns: [{include: '$self'}]
},
{include: '#illegal'},
{include: '#builtins'},
{include: '#function_call'}
],
repository: {
builtins: {
patterns: [
{
match:
'\\b(append|bind|call|caller|chr|closure|cmp|compile|contains|delete|die|find|ghosttype|id|int|keys|left|num|pop|right|setsize|size|sort|split|sprintf|streq|substr|subvec|typeof|readline)\\b',
name: 'variable.language.nasal'
},
{
match:
'\\b(abort|abs|aircraftToCart|addcommand|airportinfo|airwaysRoute|assert|carttogeod|cmdarg|courseAndDistance|createDiscontinuity|createViaTo|createWP|createWPFrom|defined|directory|fgcommand|findAirportsByICAO|findAirportsWithinRange|findFixesByID|findNavaidByFrequency|findNavaidsByFrequency|findNavaidsByID|findNavaidsWithinRange|finddata|flightplan|geodinfo|geodtocart|get_cart_ground_intersection|getprop|greatCircleMove|interpolate|isa|logprint|magvar|maketimer|start|stop|restart|maketimestamp|md5|navinfo|parse_markdown|parsexml|print|printf|printlog|rand|registerFlightPlanDelegate|removecommand|removelistener|resolvepath|setlistener|_setlistener|setprop|srand|systime|thisfunc|tileIndex|tilePath|values)\\b',
name: 'variable.language.nasal'
},
{
match: '\\b(singleShot|isRunning|simulatedTime)\\b',
name: 'variable.language.nasal'
},
{
match:
'\\b(D2R|FPS2KT|FT2M|GAL2L|IN2M|KG2LB|KT2FPS|KT2MPS|LG2GAL|LB2KG|M2FT|M2IN|M2NM|MPS2KT|NM2M|R2D)\\b',
name: 'constant.language.nasal'
},
{
match:
'\\b(addChild|addChildren|alias|clearValue|equals|getAliasTarget|getAttribute|getBoolValue|getChild|getChildren|getIndex|getName|getNode|getParent|getPath|getType|getValue|getValues|initNode|remove|removeAllChildren|removeChild|removeChildren|setAttribute|setBoolValue|setDoubleValue|setIntValue|setValue|setValues|unalias|compileCondition|condition|copy|dump|getNode|nodeList|runBinding|setAll|wrap|wrapNode)\\b',
name: 'support.function.nasal'
},
{match: '\\b(Node)\\b', name: 'support.class.nasal'},
{match: '\\b(props|globals)\\b', name: 'variable.language.nasal'}
]
},
comment: {
captures: {1: {name: 'punctuation.definition.comment.nasal'}},
match: '(#).*$\\n?',
name: 'comment.line.hash.nasal'
},
expressions: {patterns: [{include: '#illegal'}, {include: '#builtins'}]},
function_call: {
begin: '\\b([a-zA-Z_?$][\\w?$]*)(\\()',
beginCaptures: {
1: {name: 'support.function.nasal'},
2: {name: 'punctuation.definition.arguments.begin.nasal'}
},
end: '(\\))',
endCaptures: {1: {name: 'punctuation.definition.arguments.end.nasal'}},
name: 'meta.function-call.nasal',
patterns: [{include: '$self'}]
},
function_parameters: {
patterns: [
{include: '#keyword_arguments'},
{include: '#comment'},
{
captures: {
1: {name: 'variable.parameter.function.nasal'},
2: {name: 'punctuation.separator.parameters.nasal'}
},
match: '\\b(?:(\\w*))\\s*(?:(,)|(?=[\\n\\)]))'
}
]
},
illegal: {match: '%|\\$|@|&|\\^|\\||\\\\|`', name: 'invalid.illegal'},
keyword_arguments: {
begin: '\\b(\\w*)\\s*(=)(?!=)',
beginCaptures: {
1: {name: 'variable.parameter.function.keyword.nasal'},
2: {name: 'keyword.operator.assignment.nasal'}
},
end: '\\s*(?:(,)|(?=\\)))',
endCaptures: {1: {name: 'punctuation.separator.parameters.nasal'}},
patterns: [{include: '$self'}]
}
},
scopeName: 'source.nasal'
}
export default grammar