-
Notifications
You must be signed in to change notification settings - Fork 0
/
javascript-modules.lang
419 lines (335 loc) · 13.4 KB
/
javascript-modules.lang
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
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is part of GtkSourceView
Author: Scott Martin <[email protected]>
Copyright (C) 2004 Scott Martin <[email protected]>
Copyright (C) 2005 Stef Walter (formerly Nate Nielsen) <[email protected]>
Copyright (C) 2005-2007 Marco Barisione <[email protected]>
Copyright (C) 2005-2007 Emanuele Aina
Copyright (C) 2019-2020 Jeffery To <[email protected]>
GtkSourceView is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
GtkSourceView is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, see <http://www.gnu.org/licenses/>.
-->
<language id="js-mod" name="JavaScript Modules" version="2.0" _section="Script" hidden="true">
<!-- from js:identifier-char -->
<keyword-char-class>(?!\x{2E2F})[\p{L}\p{Nl}\x{1885}-\x{1886}\x{2118}\x{212E}\x{309B}-\x{309C}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{00B7}\x{0387}\x{1369}-\x{1371}\x{19DA}$\x{200C}\x{200D}]</keyword-char-class>
<definitions>
<!--
See javascript.lang for general notes, naming conventions, etc.
-->
<!-- # Shared between export and import declarations -->
<!-- ## (Import) From module
from 'module'
-->
<context id="_from-module" once-only="true">
<start>\%{js:from-keyword}</start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
<context ref="js:embedded-lang-hooks"/>
<context ref="js:comments"/>
<context id="_from-module-content">
<include>
<context ref="js-lit:choice-string-path"/>
</include>
</context> <!-- /_from-module-content -->
</include>
</context> <!-- /_from-module -->
<context id="_ordered-from-module" once-only="true">
<start>\%{js:before-next-token}</start>
<end>\%{js:before-next-token}</end>
<include>
<context ref="_from-module"/>
</include>
</context> <!-- /_ordered-from-module -->
<!-- ## (Import) all / as namespace
* from 'module';
* as ns from 'module';
-->
<context id="_as-namespace" once-only="true">
<start>\%{js:as-keyword}</start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
<context ref="js:embedded-lang-hooks"/>
<context ref="js:comments"/>
<context id="_as-namespace-content">
<include>
<context ref="js:identifier"/>
</include>
</context> <!-- /_as-namespace-content -->
</include>
</context> <!-- /_as-namespace -->
<context id="_ordered-as-namespace" once-only="true">
<start>\%{js:before-next-token}</start>
<end>\%{js:before-next-token}</end>
<include>
<context ref="_as-namespace"/>
</include>
</context> <!-- /_ordered-as-namespace -->
<context id="_choice-all-as-namespace" end-parent="true">
<start>\*</start>
<end>\%{js:statement-end}</end>
<include>
<context ref="js:embedded-lang-hooks"/>
<context ref="js:comments"/>
<context id="_import-as-namespace-content">
<include>
<context ref="_ordered-as-namespace"/>
<context ref="_ordered-from-module"/>
</include>
</context> <!-- /_import-as-namespace-content -->
</include>
</context> <!-- /_choice-all-as-namespace -->
<!-- ## Export / import name group
{ x, y as b }
{ x as default }
{ default }
{ default as y }
-->
<context id="_name-group-identifier" once-only="true">
<start>\%{js:identifier-container-start}</start>
<end>\%{def:always-match}</end>
<include>
<!-- no embedded-lang-hooks here -->
<!-- no comments here -->
<!-- do not extend the context by matching comments or
embedded-lang-hooks, which may lead to multiple identifiers -->
<context id="_name-group-identifier-content">
<include>
<context id="_name-group-keywords" style-ref="js:keyword">
<match>\%{js:default-keyword}</match>
</context> <!-- /_name-group-keywords -->
<context ref="js:identifier"/>
</include>
</context> <!-- /_name-group-identifier-content -->
</include>
</context> <!-- /_name-group-identifier -->
<context id="_name-group-as-identifier" once-only="true">
<start>\%{js:as-keyword}</start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
<context ref="js:embedded-lang-hooks"/>
<context ref="js:comments"/>
<context id="_name-group-as-identifier-content">
<include>
<context ref="_name-group-identifier"/>
</include>
</context> <!-- /_name-group-as-identifier-content -->
</include>
</context> <!-- /_name-group-as-identifier -->
<context id="_name-group-name-content">
<include>
<context ref="_name-group-identifier"/>
<context ref="_name-group-as-identifier"/>
</include>
</context> <!-- /_name-group-name-content -->
<!-- <ExportClause> / <NamedImports> -->
<context id="_name-group" once-only="true">
<start>{</start>
<end>}</end>
<include>
<context ref="js:embedded-lang-hooks"/>
<context ref="js:comments"/>
<context id="_name-group-content">
<include>
<context id="_name-group-first-name" once-only="true">
<start>\%{js:before-next-token}</start>
<end>\%{js:before-next-token}</end>
<include>
<context ref="js:embedded-lang-hooks"/>
<context ref="js:comments"/>
<context ref="_name-group-name-content"/>
</include>
</context> <!-- /_name-group-first-name -->
<context id="_name-group-names">
<start>,</start>
<end>\%{js:before-next-token}</end>
<include>
<context ref="js:embedded-lang-hooks"/>
<context ref="js:comments"/>
<context ref="_name-group-name-content"/>
</include>
</context> <!-- /_name-group-names -->
</include>
</context> <!-- /_name-group-content -->
</include>
</context> <!-- /_name-group -->
<context id="_ordered-name-group" once-only="true">
<start>\%{js:before-next-token}</start>
<end>\%{js:before-next-token}</end>
<include>
<context ref="_name-group"/>
</include>
</context> <!-- /_ordered-name-group -->
<!-- # Export declaration -->
<!-- ## Export named
export { x, y as b };
export { x as default };
export { default } from 'module';
-->
<context id="_choice-export-named" end-parent="true">
<start>(?={)</start>
<end>\%{js:statement-end}</end>
<include>
<context ref="js:embedded-lang-hooks"/>
<context ref="js:comments"/>
<context id="_choice-export-named-content">
<include>
<context ref="_ordered-name-group"/>
<context ref="_ordered-from-module"/>
</include>
</context> <!-- /_choice-export-named-content -->
</include>
</context> <!-- /_choice-export-named -->
<!-- ## Export default
export default function () { ... }
export default class { ... }
export default expr;
-->
<context id="_choice-export-default" end-parent="true">
<start>\%{js:default-keyword}</start>
<end>\%{js:statement-end}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
<context ref="js:embedded-lang-hooks"/>
<context ref="js:comments"/>
<context id="_export-default-content">
<include>
<context ref="js-fn:choice-class-expression"/>
<context ref="js-fn:choice-function-expression"/>
<context ref="js-expr:choice-expression-without-comma"/>
</include>
</context> <!-- /_export-default-content -->
</include>
</context> <!-- /_choice-export-default -->
<!-- ## Export declaration
export { foo, bar as barry };
export const a = 1;
export default function () { ... }
export * from 'module';
export * as ns from 'module';
-->
<!-- <ExportDeclaration> -->
<context id="export-declarations" style-ref="js:export-import-declaration">
<start>\%{js:export-keyword}</start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
<context ref="js:embedded-lang-hooks"/>
<context ref="js:comments"/>
<context id="_export-declaration-content">
<include>
<context ref="_choice-export-named"/>
<context ref="_choice-export-default"/>
<context ref="_choice-all-as-namespace"/>
<context ref="js-fn:choice-class-expression-required-name"/>
<context ref="js-fn:choice-function-expression"/>
<context ref="js-st:choice-variable-declaration"/>
</include>
</context> <!-- /_export-declaration-content -->
</include>
</context> <!-- /export-declarations -->
<!-- # Import declaration -->
<!-- ## Import named
import { default as y } from 'module';
-->
<context id="_choice-import-named" end-parent="true">
<start>(?={)</start>
<end>\%{js:statement-end}</end>
<include>
<context ref="js:embedded-lang-hooks"/>
<context ref="js:comments"/>
<context id="_choice-import-named-content">
<include>
<context ref="_ordered-name-group"/>
<context ref="_ordered-from-module"/>
</include>
</context> <!-- /_choice-import-named-content -->
</include>
</context> <!-- /_choice-import-named -->
<!-- ## Import default
import def from 'module';
import def, { a, b } from 'module';
import def, * as ns from 'module';
-->
<context id="_choice-import-default-additional" end-parent="true">
<start>,</start>
<end>\%{js:before-next-token}</end>
<include>
<context ref="js:embedded-lang-hooks"/>
<context ref="js:comments"/>
<context id="_import-default-additional-content">
<include>
<context ref="_choice-import-named"/>
<context ref="_choice-all-as-namespace"/>
</include>
</context> <!-- /_import-default-additional-content -->
</include>
</context> <!-- /_choice-import-default-additional -->
<context id="_choice-import-default-only" end-parent="true">
<start>\%{js:before-next-token}</start>
<end>\%{js:statement-end}</end>
<include>
<context ref="js:embedded-lang-hooks"/>
<context ref="js:comments"/>
<context id="_import-default-only-content">
<include>
<context ref="_ordered-from-module"/>
</include>
</context> <!-- /_import-default-only-content -->
</include>
</context> <!-- /_choice-import-default-only -->
<context id="_choice-import-default" end-parent="true">
<start>\%{js:identifier-container-start}</start>
<end>\%{js:before-next-token}</end>
<include>
<context ref="js:embedded-lang-hooks"/>
<context ref="js:comments"/>
<context id="_import-default-content">
<include>
<context ref="js:ordered-identifier"/>
<context ref="_choice-import-default-additional"/>
<context ref="_choice-import-default-only"/>
</include>
</context> <!-- /_import-default-content -->
</include>
</context> <!-- /_choice-import-default -->
<!-- ## Import declaration
import { foo as food, bar } from 'module';
import defaultFn, * as Mod from 'module';
import * as ns from 'module';
import 'module';
-->
<!-- <ImportDeclaration> -->
<!-- also matches import() and import.meta -->
<context id="import-declarations" style-ref="js:export-import-declaration">
<start>\%{js:import-keyword}</start>
<end>\%{js:before-next-token}</end>
<include>
<context sub-pattern="0" where="start" style-ref="js:keyword"/>
<context ref="js:embedded-lang-hooks"/>
<context ref="js:comments"/>
<context id="_import-declaration-content">
<include>
<context ref="js-expr:_choice-import-call-expression"/>
<context ref="js-expr:_choice-import-meta-expression"/>
<context ref="_choice-import-named"/>
<context ref="_choice-all-as-namespace"/>
<context ref="_choice-import-default"/>
<context ref="js-lit:choice-string-path"/>
</include>
</context> <!-- /_import-declaration-content -->
</include>
</context> <!-- /import-declarations -->
</definitions>
</language>