jexl-lezer 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -1
- package/dist/index.cjs +21 -21
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +21 -21
- package/package.json +17 -7
- package/rollup.config.js +3 -3
- package/src/highlight.js +62 -192
- package/src/{jexl.grammar → javascript.grammar} +735 -745
- package/src/parser.js +21 -21
- package/src/parser.terms.js +166 -165
- package/test/decorator.txt +64 -0
- package/test/expression.txt +686 -0
- package/test/jsx.txt +79 -0
- package/test/semicolon.txt +77 -0
- package/test/statement.txt +404 -0
- package/test/test-javascript.js +17 -0
- package/test/typescript.txt +401 -0
|
@@ -1,745 +1,735 @@
|
|
|
1
|
-
@dialects { jsx, ts }
|
|
2
|
-
|
|
3
|
-
@precedence {
|
|
4
|
-
typeargs,
|
|
5
|
-
typeMember,
|
|
6
|
-
typePrefix,
|
|
7
|
-
intersectionPrefixed @left,
|
|
8
|
-
intersection @left,
|
|
9
|
-
unionPrefixed @left,
|
|
10
|
-
union @left,
|
|
11
|
-
typeExtends @right,
|
|
12
|
-
else @right,
|
|
13
|
-
member,
|
|
14
|
-
readonly,
|
|
15
|
-
newArgs,
|
|
16
|
-
call,
|
|
17
|
-
instantiate,
|
|
18
|
-
taggedTemplate,
|
|
19
|
-
prefix,
|
|
20
|
-
postfix,
|
|
21
|
-
typeof,
|
|
22
|
-
exp @left,
|
|
23
|
-
times @left,
|
|
24
|
-
plus @left,
|
|
25
|
-
shift @left,
|
|
26
|
-
loop,
|
|
27
|
-
rel @left,
|
|
28
|
-
satisfies,
|
|
29
|
-
equal @left,
|
|
30
|
-
bitAnd @left,
|
|
31
|
-
bitXor @left,
|
|
32
|
-
bitOr @left,
|
|
33
|
-
and @left,
|
|
34
|
-
or @left,
|
|
35
|
-
ternary @right,
|
|
36
|
-
assign @right,
|
|
37
|
-
comma @left,
|
|
38
|
-
statement @cut,
|
|
39
|
-
predicate
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@top Script { statement* }
|
|
43
|
-
|
|
44
|
-
@top SingleExpression { expression }
|
|
45
|
-
|
|
46
|
-
@top SingleClassItem { classItem }
|
|
47
|
-
|
|
48
|
-
statement[@isGroup=Statement] {
|
|
49
|
-
ExportDeclaration |
|
|
50
|
-
ImportDeclaration |
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
kw<"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
} |
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
kw<"export">
|
|
77
|
-
kw<"export">
|
|
78
|
-
kw<"export"> tskw<"type">?
|
|
79
|
-
kw<"export">
|
|
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
|
-
classPropName
|
|
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
|
-
expressionNoComma
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
expressionNoComma !
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
expressionNoComma !
|
|
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
|
-
(plusMin?
|
|
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
|
-
@precedence {
|
|
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
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
"
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
"
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
tsAngleOpen[@dialect=ts,@name="<"] { "<" }
|
|
738
|
-
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
@external tokens insertSemicolon from "./tokens" { insertSemi }
|
|
742
|
-
|
|
743
|
-
@external propSource jsHighlight from "./highlight"
|
|
744
|
-
|
|
745
|
-
@detectDelim
|
|
1
|
+
@dialects { jsx, ts }
|
|
2
|
+
|
|
3
|
+
@precedence {
|
|
4
|
+
typeargs,
|
|
5
|
+
typeMember,
|
|
6
|
+
typePrefix,
|
|
7
|
+
intersectionPrefixed @left,
|
|
8
|
+
intersection @left,
|
|
9
|
+
unionPrefixed @left,
|
|
10
|
+
union @left,
|
|
11
|
+
typeExtends @right,
|
|
12
|
+
else @right,
|
|
13
|
+
member,
|
|
14
|
+
readonly,
|
|
15
|
+
newArgs,
|
|
16
|
+
call,
|
|
17
|
+
instantiate,
|
|
18
|
+
taggedTemplate,
|
|
19
|
+
prefix,
|
|
20
|
+
postfix,
|
|
21
|
+
typeof,
|
|
22
|
+
exp @left,
|
|
23
|
+
times @left,
|
|
24
|
+
plus @left,
|
|
25
|
+
shift @left,
|
|
26
|
+
loop,
|
|
27
|
+
rel @left,
|
|
28
|
+
satisfies,
|
|
29
|
+
equal @left,
|
|
30
|
+
bitAnd @left,
|
|
31
|
+
bitXor @left,
|
|
32
|
+
bitOr @left,
|
|
33
|
+
and @left,
|
|
34
|
+
or @left,
|
|
35
|
+
ternary @right,
|
|
36
|
+
assign @right,
|
|
37
|
+
comma @left,
|
|
38
|
+
statement @cut,
|
|
39
|
+
predicate
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@top Script { Hashbang? statement* }
|
|
43
|
+
|
|
44
|
+
@top SingleExpression { expression }
|
|
45
|
+
|
|
46
|
+
@top SingleClassItem { classItem }
|
|
47
|
+
|
|
48
|
+
statement[@isGroup=Statement] {
|
|
49
|
+
ExportDeclaration |
|
|
50
|
+
ImportDeclaration |
|
|
51
|
+
ForStatement { kw<"for"> ckw<"await">? (ForSpec | ForInSpec | ForOfSpec) statement } |
|
|
52
|
+
WhileStatement { kw<"while"> ParenthesizedExpression statement } |
|
|
53
|
+
WithStatement { kw<"with"> ParenthesizedExpression statement } |
|
|
54
|
+
DoStatement { kw<"do"> statement kw<"while"> ParenthesizedExpression semi } |
|
|
55
|
+
IfStatement { kw<"if"> ParenthesizedExpression statement (!else kw<"else"> statement)? } |
|
|
56
|
+
SwitchStatement { kw<"switch"> ParenthesizedExpression SwitchBody { "{" switchItem* "}" } } |
|
|
57
|
+
TryStatement {
|
|
58
|
+
kw<"try"> Block
|
|
59
|
+
CatchClause { kw<"catch"> ("(" pattern ")")? Block }?
|
|
60
|
+
FinallyClause { kw<"finally"> Block }?
|
|
61
|
+
} |
|
|
62
|
+
ReturnStatement { kw<"return"> (noSemi expression)? semi } |
|
|
63
|
+
ThrowStatement { kw<"throw"> expression semi } |
|
|
64
|
+
BreakStatement { kw<"break"> (noSemi Label)? semi } |
|
|
65
|
+
ContinueStatement { kw<"continue"> (noSemi Label)? semi } |
|
|
66
|
+
DebuggerStatement { kw<"debugger"> semi } |
|
|
67
|
+
Block |
|
|
68
|
+
LabeledStatement { Label ":" statement } |
|
|
69
|
+
declaration |
|
|
70
|
+
ExpressionStatement { expression semi } |
|
|
71
|
+
";"
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
ExportDeclaration {
|
|
75
|
+
kw<"export"> Star (ckw<"as"> (VariableName | String))? ckw<"from"> String semi |
|
|
76
|
+
kw<"export"> kw<"default"> (FunctionDeclaration | ClassDeclaration | expression semi) |
|
|
77
|
+
kw<"export"> tskw<"type">? declaration |
|
|
78
|
+
kw<"export"> tskw<"type">? ExportGroup (ckw<"from"> String)? semi |
|
|
79
|
+
kw<"export"> "=" expression semi
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
ExportGroup {
|
|
83
|
+
"{" commaSep<(VariableName | String | kw<"default">) (ckw<"as"> (VariableName { word } | String))?> "}"
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
ImportDeclaration {
|
|
87
|
+
kw<"import"> ckw<"defer">? tskw<"type">? (Star ckw<"as"> VariableDefinition | commaSep<VariableDefinition | ImportGroup>)
|
|
88
|
+
ckw<"from"> String semi |
|
|
89
|
+
kw<"import"> ckw<"defer">? String semi
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
ImportGroup {
|
|
93
|
+
"{" commaSep<tskw<"type">? (VariableDefinition | (VariableName | String | kw<"default">) ckw<"as"> VariableDefinition)> "}"
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
ForSpec {
|
|
97
|
+
"("
|
|
98
|
+
(VariableDeclaration | expression ";" | ";") expression? ";" expression?
|
|
99
|
+
")"
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
forXSpec<op> {
|
|
103
|
+
"("
|
|
104
|
+
(variableDeclarationKeyword pattern | VariableName | MemberExpression | ArrayPattern | ObjectPattern)
|
|
105
|
+
!loop op expression
|
|
106
|
+
")"
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
ForInSpec { forXSpec<kw<"in">> }
|
|
110
|
+
ForOfSpec { forXSpec<ckw<"of">> }
|
|
111
|
+
|
|
112
|
+
declaration {
|
|
113
|
+
FunctionDeclaration |
|
|
114
|
+
ClassDeclaration |
|
|
115
|
+
VariableDeclaration |
|
|
116
|
+
TypeAliasDeclaration |
|
|
117
|
+
InterfaceDeclaration |
|
|
118
|
+
EnumDeclaration |
|
|
119
|
+
NamespaceDeclaration |
|
|
120
|
+
AmbientDeclaration
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
FunctionDeclaration {
|
|
124
|
+
async? !statement kw<"function"> Star? VariableDefinition? functionSignature (Block | semi)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
ClassDeclaration {
|
|
128
|
+
!statement Decorator* tskw<"abstract">? kw<"class"> VariableDefinition TypeParamList?
|
|
129
|
+
(kw<"extends"> ((VariableName | MemberExpression) !typeargs TypeArgList | expression))?
|
|
130
|
+
(tskw<"implements"> commaSep1<type>)?
|
|
131
|
+
ClassBody
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
classItem { MethodDeclaration | PropertyDeclaration | StaticBlock | ";" }
|
|
135
|
+
|
|
136
|
+
ClassBody { "{" classItem* "}" }
|
|
137
|
+
|
|
138
|
+
privacy {
|
|
139
|
+
@extend[@name=Privacy,@dialect=ts]<word, "public" | "private" | "protected">
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
privacyArg {
|
|
143
|
+
@extend[@name=Privacy,@dialect=ts]<identifier, "public" | "private" | "protected">
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
propModifier {
|
|
147
|
+
Decorator |
|
|
148
|
+
tsPkwMod<"declare"> |
|
|
149
|
+
privacy |
|
|
150
|
+
pkwMod<"static"> |
|
|
151
|
+
tsPkwMod<"abstract"> |
|
|
152
|
+
tsPkwMod<"override">
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
classPropName { propName | PrivatePropertyDefinition }
|
|
156
|
+
|
|
157
|
+
MethodDeclaration[group=ClassItem] {
|
|
158
|
+
propModifier*
|
|
159
|
+
pkwMod<"async">?
|
|
160
|
+
(pkwMod<"get"> | pkwMod<"set"> | Star)?
|
|
161
|
+
classPropName
|
|
162
|
+
functionSignature
|
|
163
|
+
(Block | semi)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
StaticBlock[group=ClassItem] {
|
|
167
|
+
pkwMod<"static"> Block
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
PropertyDeclaration[group=ClassItem] {
|
|
171
|
+
propModifier*
|
|
172
|
+
(tsPkwMod<"readonly"> | pkwMod<"accessor">)?
|
|
173
|
+
classPropName
|
|
174
|
+
(Optional | LogicOp<"!">)?
|
|
175
|
+
TypeAnnotation?
|
|
176
|
+
("=" expressionNoComma)?
|
|
177
|
+
semi
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
variableDeclarationKeyword {
|
|
181
|
+
kw<"let"> | kw<"var"> | kw<"const"> | ckw<"await">? ckw<"using">
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
VariableDeclaration {
|
|
185
|
+
variableDeclarationKeyword commaSep1<patternAssignTyped> semi
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
TypeAliasDeclaration {
|
|
189
|
+
tskw<"type"> TypeDefinition TypeParamList? "=" type semi
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
InterfaceDeclaration {
|
|
193
|
+
tskw<"interface"> TypeDefinition TypeParamList? (kw<"extends"> commaSep1<type>)? ObjectType
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
EnumDeclaration {
|
|
197
|
+
kw<"const">? tskw<"enum"> TypeDefinition EnumBody { "{" commaSep<PropertyName ("=" expressionNoComma)?> "}" }
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
NamespaceDeclaration {
|
|
201
|
+
(tskw<"namespace"> | tskw<"module">) VariableDefinition ("." PropertyDefinition)* Block
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
AmbientDeclaration {
|
|
205
|
+
tskw<"declare"> (
|
|
206
|
+
VariableDeclaration |
|
|
207
|
+
TypeAliasDeclaration |
|
|
208
|
+
EnumDeclaration |
|
|
209
|
+
InterfaceDeclaration |
|
|
210
|
+
NamespaceDeclaration |
|
|
211
|
+
GlobalDeclaration { tskw<"global"> Block } |
|
|
212
|
+
ClassDeclaration {
|
|
213
|
+
tskw<"abstract">? kw<"class"> VariableDefinition TypeParamList?
|
|
214
|
+
(kw<"extends"> expression)?
|
|
215
|
+
(tskw<"implements"> commaSep1<type>)?
|
|
216
|
+
ClassBody { "{" (
|
|
217
|
+
MethodDeclaration |
|
|
218
|
+
PropertyDeclaration |
|
|
219
|
+
IndexSignature semi
|
|
220
|
+
)* "}" }
|
|
221
|
+
} |
|
|
222
|
+
AmbientFunctionDeclaration {
|
|
223
|
+
async? kw<"function"> Star? VariableDefinition? TypeParamList? ParamList (TypeAnnotation | TypePredicate) semi
|
|
224
|
+
}
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
decoratorExpression {
|
|
229
|
+
VariableName |
|
|
230
|
+
MemberExpression { decoratorExpression !member ("." | questionDot) (PropertyName | PrivatePropertyName) } |
|
|
231
|
+
CallExpression { decoratorExpression !call TypeArgList? questionDot? ArgList } |
|
|
232
|
+
ParenthesizedExpression
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
Decorator { "@" decoratorExpression }
|
|
236
|
+
|
|
237
|
+
pattern { VariableDefinition | ArrayPattern | ObjectPattern }
|
|
238
|
+
|
|
239
|
+
ArrayPattern { "[" commaSep<("..."? patternAssign)?> ~destructure "]" }
|
|
240
|
+
|
|
241
|
+
ObjectPattern { "{" commaSep<PatternProperty> ~destructure "}" }
|
|
242
|
+
|
|
243
|
+
patternAssign {
|
|
244
|
+
pattern ("=" expressionNoComma)?
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
TypeAnnotation { ":" type }
|
|
248
|
+
|
|
249
|
+
TypePredicate {
|
|
250
|
+
":" (
|
|
251
|
+
tskw<"asserts"> (VariableName | kw<"this">) !predicate (tskw<"is"> type)? |
|
|
252
|
+
(VariableName | kw<"this">) !predicate tskw<"is"> type
|
|
253
|
+
)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
patternAssignTyped {
|
|
257
|
+
pattern Optional? TypeAnnotation? ("=" expressionNoComma)?
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
ParamList {
|
|
261
|
+
"(" commaSep<"..." patternAssignTyped | Decorator* privacyArg? tskw<"readonly">? patternAssignTyped | kw<"this"> TypeAnnotation> ")"
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
Block {
|
|
265
|
+
!statement "{" statement* "}"
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
switchItem {
|
|
269
|
+
CaseLabel { kw<"case"> expression ":" } |
|
|
270
|
+
DefaultLabel { kw<"default"> ":" } |
|
|
271
|
+
statement
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
expression[@isGroup=Expression] {
|
|
275
|
+
expressionNoComma | SequenceExpression
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
SequenceExpression {
|
|
279
|
+
expressionNoComma !comma ("," expressionNoComma)+
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
expressionNoComma {
|
|
283
|
+
Number |
|
|
284
|
+
String |
|
|
285
|
+
TemplateString |
|
|
286
|
+
VariableName |
|
|
287
|
+
boolean |
|
|
288
|
+
kw<"this"> |
|
|
289
|
+
kw<"null"> |
|
|
290
|
+
kw<"super"> |
|
|
291
|
+
RegExp |
|
|
292
|
+
ArrayExpression |
|
|
293
|
+
ObjectExpression { "{" commaSep<Property> ~destructure "}" } |
|
|
294
|
+
NewTarget { kw<"new"> "." PropertyName } |
|
|
295
|
+
NewExpression { kw<"new"> expressionNoComma (!newArgs ArgList)? } |
|
|
296
|
+
UnaryExpression |
|
|
297
|
+
YieldExpression |
|
|
298
|
+
AwaitExpression |
|
|
299
|
+
ParenthesizedExpression |
|
|
300
|
+
ClassExpression |
|
|
301
|
+
FunctionExpression |
|
|
302
|
+
ArrowFunction |
|
|
303
|
+
MemberExpression |
|
|
304
|
+
BinaryExpression |
|
|
305
|
+
ConditionalExpression { expressionNoComma !ternary questionOp expressionNoComma LogicOp<":"> expressionNoComma } |
|
|
306
|
+
AssignmentExpression |
|
|
307
|
+
PostfixExpression { expressionNoComma !postfix (incdec | LogicOp<"!">) } |
|
|
308
|
+
CallExpression { expressionNoComma !call questionDot? ArgList } |
|
|
309
|
+
InstantiationExpression { (VariableName | MemberExpression) !instantiate TypeArgList } |
|
|
310
|
+
TaggedTemplateExpression { expressionNoComma !taggedTemplate TemplateString } |
|
|
311
|
+
DynamicImport { kw<"import"> "(" expressionNoComma ")" } |
|
|
312
|
+
ImportMeta { kw<"import"> "." PropertyName } |
|
|
313
|
+
JSXElement |
|
|
314
|
+
PrefixCast { tsAngleOpen (type | kw<"const">) ~tsAngle ">" expressionNoComma } |
|
|
315
|
+
ArrowFunction[@dynamicPrecedence=1] {
|
|
316
|
+
TypeParamList { tsAngleOpen commaSep<typeParam> ">" } ParamList TypeAnnotation? "=>" (Block | expressionNoComma)
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
ParenthesizedExpression { "(" expression ")" }
|
|
321
|
+
|
|
322
|
+
ArrayExpression {
|
|
323
|
+
"[" commaSep1<"..."? expressionNoComma | ""> ~destructure "]"
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
propName { PropertyDefinition | "[" expression "]" ~destructure | Number ~destructure | String ~destructure }
|
|
327
|
+
|
|
328
|
+
Property {
|
|
329
|
+
pkwMod<"async">? (pkwMod<"get"> | pkwMod<"set"> | Star)? propName functionSignature Block |
|
|
330
|
+
propName ~destructure (":" expressionNoComma)? |
|
|
331
|
+
"..." expressionNoComma
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
PatternProperty {
|
|
335
|
+
"..." patternAssign |
|
|
336
|
+
((PropertyName | Number | String) ~destructure (":" pattern)? |
|
|
337
|
+
("[" expression "]" ~destructure ":" pattern)) ("=" expressionNoComma)?
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
ClassExpression {
|
|
341
|
+
kw<"class"> VariableDefinition? (kw<"extends"> expression)? ClassBody
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
functionSignature { TypeParamList? ParamList (TypeAnnotation | TypePredicate)? }
|
|
345
|
+
|
|
346
|
+
FunctionExpression {
|
|
347
|
+
async? kw<"function"> Star? VariableDefinition? functionSignature Block
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
YieldExpression[@dynamicPrecedence=1] {
|
|
351
|
+
!prefix ckw<"yield"> Star? expressionNoComma
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
AwaitExpression[@dynamicPrecedence=1] {
|
|
355
|
+
!prefix ckw<"await"> expressionNoComma
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
UnaryExpression {
|
|
359
|
+
!prefix (kw<"void"> | kw<"typeof"> | kw<"delete"> |
|
|
360
|
+
LogicOp<"!"> | BitOp<"~"> | incdec | incdecPrefix | plusMin)
|
|
361
|
+
expressionNoComma
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
BinaryExpression {
|
|
365
|
+
expressionNoComma !exp ArithOp<"**"> expressionNoComma |
|
|
366
|
+
expressionNoComma !times (divide | ArithOp<"%"> | ArithOp<"*">) expressionNoComma |
|
|
367
|
+
expressionNoComma !plus plusMin expressionNoComma |
|
|
368
|
+
expressionNoComma !shift BitOp<">>" ">"? | "<<"> expressionNoComma |
|
|
369
|
+
expressionNoComma !rel (LessThan | CompareOp<"<=" | ">" "="?> | kw<"instanceof">) expressionNoComma |
|
|
370
|
+
expressionNoComma !satisfies tskw<"satisfies"> type |
|
|
371
|
+
(expressionNoComma | PrivatePropertyName) !rel ~tsIn kw<"in"> expressionNoComma |
|
|
372
|
+
expressionNoComma !rel ckw<"as"> (kw<"const"> | type) |
|
|
373
|
+
expressionNoComma !rel tskw<"satisfies"> type |
|
|
374
|
+
expressionNoComma !equal CompareOp<"==" "="? | "!=" "="?> expressionNoComma |
|
|
375
|
+
expressionNoComma !bitOr BitOp { "|" } expressionNoComma |
|
|
376
|
+
expressionNoComma !bitXor BitOp<"^"> expressionNoComma |
|
|
377
|
+
expressionNoComma !bitAnd BitOp { "&" } expressionNoComma |
|
|
378
|
+
expressionNoComma !and LogicOp<"&&"> expressionNoComma |
|
|
379
|
+
expressionNoComma !or LogicOp<"||" | "??"> expressionNoComma
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
AssignmentExpression {
|
|
383
|
+
(VariableName | MemberExpression) !assign UpdateOp<($[+\-/%^] | "*" "*"? | "|" "|"? | "&" "&"? | "<<" | ">>" ">"? | "??") "=">
|
|
384
|
+
expressionNoComma |
|
|
385
|
+
(VariableName | MemberExpression | ArrayPattern | ObjectPattern) !assign "=" expressionNoComma
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
MemberExpression {
|
|
389
|
+
expressionNoComma !member (("." | questionDot) (PropertyName | PrivatePropertyName) | questionDot? "[" expression "]")
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
ArgList {
|
|
393
|
+
"(" commaSep<"..."? expressionNoComma> ")"
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
ArrowFunction {
|
|
397
|
+
async? (ParamList { VariableDefinition } | ParamList TypeAnnotation?) "=>" (Block | expressionNoComma)
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
TypeArgList[@dynamicPrecedence=1] {
|
|
401
|
+
@extend[@dialect=ts,@name="<"]<LessThan, "<"> commaSep<type> ">"
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
TypeParamList {
|
|
405
|
+
"<" commaSep<typeParam> ">"
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
typeParam { (kw<"in"> | tskw<"out"> | kw<"const">)? TypeDefinition ~tsAngle (kw<"extends"> type)? ("=" type)? }
|
|
409
|
+
|
|
410
|
+
typeofExpression {
|
|
411
|
+
MemberExpression { typeofExpression !member (("." | questionDot) PropertyName | "[" expression "]") } |
|
|
412
|
+
InstantiationExpression { typeofExpression !instantiate TypeArgList } |
|
|
413
|
+
VariableName
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
type[@isGroup=Type] {
|
|
417
|
+
ThisType { kw<"this"> } |
|
|
418
|
+
LiteralType {
|
|
419
|
+
plusMin? Number |
|
|
420
|
+
boolean |
|
|
421
|
+
String
|
|
422
|
+
} |
|
|
423
|
+
TemplateType |
|
|
424
|
+
NullType { kw<"null"> } |
|
|
425
|
+
VoidType { kw<"void"> } |
|
|
426
|
+
TypeofType { kw<"typeof"> typeofExpression } |
|
|
427
|
+
KeyofType { !typePrefix tskw<"keyof"> type } |
|
|
428
|
+
UniqueType { !typePrefix tskw<"unique"> type } |
|
|
429
|
+
ImportType { kw<"import"> "(" String ")" } |
|
|
430
|
+
InferredType { tskw<"infer"> TypeName } |
|
|
431
|
+
ParenthesizedType { "(" type ")" } |
|
|
432
|
+
FunctionSignature { TypeParamList? ParamTypeList "=>" type } |
|
|
433
|
+
NewSignature { kw<"new"> ParamTypeList "=>" type } |
|
|
434
|
+
IndexedType |
|
|
435
|
+
TupleType { "[" commaSep<(Label ":")? type | "..." type> ~destructure "]" } |
|
|
436
|
+
ArrayType { type noSemiType "[" "]" } |
|
|
437
|
+
ReadonlyType { tskw<"readonly"> !readonly type } |
|
|
438
|
+
ObjectType |
|
|
439
|
+
UnionType {
|
|
440
|
+
type (!union unionOp type)+ |
|
|
441
|
+
unionOp type (!unionPrefixed unionOp type)*
|
|
442
|
+
} |
|
|
443
|
+
IntersectionType {
|
|
444
|
+
type (!intersection intersectionOp type)+ |
|
|
445
|
+
intersectionOp type (!intersectionPrefixed intersectionOp type)*
|
|
446
|
+
} |
|
|
447
|
+
ConditionalType { type !typeExtends kw<"extends"> type questionOp ~arrow type LogicOp<":"> type } |
|
|
448
|
+
ParameterizedType { (TypeName | IndexedType) !typeargs TypeArgList } |
|
|
449
|
+
TypeName
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
IndexedType {
|
|
453
|
+
type !typeMember ("." TypeName | noSemiType "[" type "]")+
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
ObjectType {
|
|
457
|
+
"{" (
|
|
458
|
+
(MethodType |
|
|
459
|
+
PropertyType |
|
|
460
|
+
IndexSignature |
|
|
461
|
+
CallSignature { ParamTypeList (TypeAnnotation | TypePredicate) } |
|
|
462
|
+
NewSignature[@dynamicPrecedence=1] { @extend[@name=new]<word, "new"> ParamTypeList TypeAnnotation })
|
|
463
|
+
("," | semi)
|
|
464
|
+
)* ~destructure "}"
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
IndexSignature {
|
|
468
|
+
(plusMin? tsPkwMod<"readonly">)?
|
|
469
|
+
"[" PropertyDefinition { identifier } (TypeAnnotation | ~tsIn kw<"in"> type (ckw<"as"> type)?) "]"
|
|
470
|
+
(plusMin? Optional)?
|
|
471
|
+
TypeAnnotation
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
MethodType {
|
|
475
|
+
pkwMod<"async">?
|
|
476
|
+
(pkwMod<"get"> | pkwMod<"set"> | Star)?
|
|
477
|
+
propName
|
|
478
|
+
(plusMin? Optional)?
|
|
479
|
+
functionSignature
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
PropertyType {
|
|
483
|
+
(plusMin? tsPkwMod<"readonly">)?
|
|
484
|
+
propName
|
|
485
|
+
(plusMin? Optional)?
|
|
486
|
+
TypeAnnotation
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
ParamTypeList[@name=ParamList] {
|
|
490
|
+
"(" commaSep<"..."? pattern ~arrow Optional? ~arrow TypeAnnotation? | kw<"this"> TypeAnnotation> ")"
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
@skip {} {
|
|
494
|
+
TemplateString[isolate] {
|
|
495
|
+
templateStart (templateEscape | templateContent | templateExpr)* templateEnd
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
TemplateType[isolate] {
|
|
499
|
+
templateStart (templateContent | templateType)* templateEnd
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
String[isolate] {
|
|
503
|
+
'"' (stringContentDouble | Escape)* ('"' | "\n") |
|
|
504
|
+
"'" (stringContentSingle | Escape)* ("'" | "\n")
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
BlockComment[isolate] { "/*" (blockCommentContent | blockCommentNewline)* blockCommentEnd }
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
templateExpr[@name=Interpolation,isolate] { InterpolationStart expression? InterpolationEnd }
|
|
511
|
+
|
|
512
|
+
templateType[@name=Interpolation,isolate] { InterpolationStart type? InterpolationEnd }
|
|
513
|
+
|
|
514
|
+
@skip {} {
|
|
515
|
+
JSXElement {
|
|
516
|
+
JSXSelfClosingTag |
|
|
517
|
+
(JSXOpenTag | JSXFragmentTag) (JSXText | JSXElement | JSXEscape)* JSXCloseTag
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
JSXSelfClosingTag { JSXStartTag jsxElementName jsxAttribute* JSXSelfCloseEndTag }
|
|
522
|
+
|
|
523
|
+
JSXOpenTag { JSXStartTag jsxElementName jsxAttribute* JSXEndTag }
|
|
524
|
+
|
|
525
|
+
JSXFragmentTag { JSXStartTag JSXEndTag }
|
|
526
|
+
|
|
527
|
+
JSXCloseTag { JSXStartCloseTag jsxElementName? JSXEndTag }
|
|
528
|
+
|
|
529
|
+
jsxElementName {
|
|
530
|
+
JSXIdentifier |
|
|
531
|
+
JSXBuiltin { JSXLowerIdentifier } |
|
|
532
|
+
JSXNamespacedName |
|
|
533
|
+
JSXMemberExpression
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
JSXMemberExpression { (JSXMemberExpression | JSXIdentifier | JSXLowerIdentifier) "." (JSXIdentifier | JSXLowerIdentifier) }
|
|
537
|
+
|
|
538
|
+
JSXNamespacedName { (JSXIdentifier | JSXNamespacedName | JSXLowerIdentifier) ":" (JSXIdentifier | JSXLowerIdentifier) }
|
|
539
|
+
|
|
540
|
+
jsxAttribute {
|
|
541
|
+
JSXSpreadAttribute { "{" "..." expression "}" } |
|
|
542
|
+
JSXAttribute { (JSXIdentifier | JSXNamespacedName | JSXLowerIdentifier) ("=" jsxAttributeValue)? }
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
jsxAttributeValue {
|
|
546
|
+
JSXAttributeValue |
|
|
547
|
+
JSXEscape { "{" expression "}" } |
|
|
548
|
+
JSXElement
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
JSXEscape { "{" "..."? expression "}" }
|
|
552
|
+
|
|
553
|
+
commaSep<content> {
|
|
554
|
+
"" | content ("," content?)*
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
commaSep1<content> {
|
|
558
|
+
content ("," content)*
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// Keywords
|
|
562
|
+
|
|
563
|
+
kw<term> { @specialize[@name={term}]<identifier, term> }
|
|
564
|
+
|
|
565
|
+
// Contextual keywords
|
|
566
|
+
|
|
567
|
+
ckw<term> { @extend[@name={term}]<identifier, term> }
|
|
568
|
+
|
|
569
|
+
tskw<term> { @extend[@name={term},@dialect=ts]<identifier, term> }
|
|
570
|
+
|
|
571
|
+
async { @extend[@name=async]<identifier, "async"> }
|
|
572
|
+
|
|
573
|
+
// Contextual keyword in property context
|
|
574
|
+
|
|
575
|
+
pkwMod<term> { @extend[@name={term}]<word, term> }
|
|
576
|
+
|
|
577
|
+
tsPkwMod<term> { @extend[@name={term},@dialect=ts]<word, term> }
|
|
578
|
+
|
|
579
|
+
semi { ";" | insertSemi }
|
|
580
|
+
|
|
581
|
+
boolean { @specialize[@name=BooleanLiteral]<identifier, "true" | "false"> }
|
|
582
|
+
|
|
583
|
+
Star { "*" }
|
|
584
|
+
|
|
585
|
+
VariableName { identifier ~arrow }
|
|
586
|
+
|
|
587
|
+
VariableDefinition { identifier ~arrow }
|
|
588
|
+
|
|
589
|
+
TypeDefinition { identifier }
|
|
590
|
+
|
|
591
|
+
TypeName { identifier ~arrow }
|
|
592
|
+
|
|
593
|
+
Label { identifier }
|
|
594
|
+
|
|
595
|
+
PropertyName { word ~propName }
|
|
596
|
+
|
|
597
|
+
PropertyDefinition { word ~propName }
|
|
598
|
+
|
|
599
|
+
PrivatePropertyName { privateIdentifier }
|
|
600
|
+
|
|
601
|
+
PrivatePropertyDefinition { privateIdentifier }
|
|
602
|
+
|
|
603
|
+
Optional { "?" }
|
|
604
|
+
|
|
605
|
+
questionOp[@name=LogicOp] { "?" }
|
|
606
|
+
|
|
607
|
+
unionOp[@name=LogicOp] { "|" }
|
|
608
|
+
|
|
609
|
+
plusMin { ArithOp<"+" | "-"> }
|
|
610
|
+
|
|
611
|
+
intersectionOp[@name=LogicOp] { "&" }
|
|
612
|
+
|
|
613
|
+
@skip { spaces | newline | LineComment | BlockComment }
|
|
614
|
+
|
|
615
|
+
@context trackNewline from "./tokens.js"
|
|
616
|
+
|
|
617
|
+
@external tokens noSemicolon from "./tokens" { noSemi }
|
|
618
|
+
|
|
619
|
+
@external tokens noSemicolonType from "./tokens" { noSemiType }
|
|
620
|
+
|
|
621
|
+
@external tokens operatorToken from "./tokens" {
|
|
622
|
+
incdec[@name=ArithOp],
|
|
623
|
+
incdecPrefix[@name=ArithOp]
|
|
624
|
+
questionDot[@name="?."]
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
@external tokens jsx from "./tokens" { JSXStartTag }
|
|
628
|
+
|
|
629
|
+
@local tokens {
|
|
630
|
+
InterpolationStart[closedBy=InterpolationEnd] { "${" }
|
|
631
|
+
templateEnd { "`" }
|
|
632
|
+
templateEscape[@name=Escape] { Escape }
|
|
633
|
+
@else templateContent
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
@local tokens {
|
|
637
|
+
blockCommentEnd { "*/" }
|
|
638
|
+
blockCommentNewline { "\n" }
|
|
639
|
+
@else blockCommentContent
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
@tokens {
|
|
643
|
+
spaces[@export] { $[\u0009 \u000b\u00a0\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]+ }
|
|
644
|
+
newline[@export] { $[\r\n\u2028\u2029] }
|
|
645
|
+
|
|
646
|
+
LineComment[isolate] { "//" ![\n]* }
|
|
647
|
+
|
|
648
|
+
Hashbang { "#!" ![\n]* }
|
|
649
|
+
|
|
650
|
+
divide[@name=ArithOp] { "/" }
|
|
651
|
+
|
|
652
|
+
@precedence { "/*", LineComment, divide }
|
|
653
|
+
|
|
654
|
+
@precedence { "/*", LineComment, RegExp }
|
|
655
|
+
|
|
656
|
+
identifierChar { @asciiLetter | $[_$\u{a1}-\u{10ffff}] }
|
|
657
|
+
|
|
658
|
+
word { identifierChar (identifierChar | @digit)* }
|
|
659
|
+
|
|
660
|
+
identifier { word }
|
|
661
|
+
|
|
662
|
+
privateIdentifier { "#" word }
|
|
663
|
+
|
|
664
|
+
@precedence { spaces, newline, identifier }
|
|
665
|
+
|
|
666
|
+
@precedence { spaces, newline, JSXIdentifier, JSXLowerIdentifier }
|
|
667
|
+
|
|
668
|
+
@precedence { spaces, newline, word }
|
|
669
|
+
|
|
670
|
+
hex { @digit | $[a-fA-F] }
|
|
671
|
+
|
|
672
|
+
Number {
|
|
673
|
+
(@digit ("_" | @digit)* ("." ("_" | @digit)*)? | "." @digit ("_" | @digit)*)
|
|
674
|
+
(("e" | "E") ("+" | "-")? ("_" | @digit)+)? |
|
|
675
|
+
@digit ("_" | @digit)* "n" |
|
|
676
|
+
"0x" (hex | "_")+ "n"? |
|
|
677
|
+
"0b" $[01_]+ "n"? |
|
|
678
|
+
"0o" $[0-7_]+ "n"?
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
@precedence { Number "." }
|
|
682
|
+
|
|
683
|
+
Escape {
|
|
684
|
+
"\\" ("x" hex hex | "u" ("{" hex+ "}" | hex hex hex hex) | ![xu])
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
stringContentSingle { ![\\\n']+ }
|
|
688
|
+
|
|
689
|
+
stringContentDouble { ![\\\n"]+ }
|
|
690
|
+
|
|
691
|
+
templateStart { "`" }
|
|
692
|
+
|
|
693
|
+
InterpolationEnd[openedBy=InterpolationStart] { "}" }
|
|
694
|
+
|
|
695
|
+
ArithOp<expr> { expr }
|
|
696
|
+
LogicOp<expr> { expr }
|
|
697
|
+
BitOp<expr> { expr }
|
|
698
|
+
CompareOp<expr> { expr }
|
|
699
|
+
UpdateOp<expr> { expr }
|
|
700
|
+
|
|
701
|
+
@precedence { "*", ArithOp }
|
|
702
|
+
|
|
703
|
+
RegExp[isolate] { "/" (![/\\\n[] | "\\" ![\n] | "[" (![\n\\\]] | "\\" ![\n])* "]")+ ("/" $[dgimsuvy]*)? }
|
|
704
|
+
|
|
705
|
+
LessThan[@name=CompareOp] { "<" }
|
|
706
|
+
|
|
707
|
+
"="[@name=Equals]
|
|
708
|
+
"..."[@name=Spread]
|
|
709
|
+
"=>"[@name=Arrow]
|
|
710
|
+
|
|
711
|
+
"(" ")" "[" "]" "{" "}" "<" ">"
|
|
712
|
+
|
|
713
|
+
"." "," ";" ":" "@"
|
|
714
|
+
|
|
715
|
+
JSXIdentifier { $[A-Z_$\u{a1}-\u{10ffff}] (identifierChar | @digit | "-")* }
|
|
716
|
+
JSXLowerIdentifier[@name=JSXIdentifier] { $[a-z] (identifierChar | @digit | "-")* }
|
|
717
|
+
|
|
718
|
+
JSXAttributeValue { '"' !["]* '"' | "'" ![']* "'" }
|
|
719
|
+
|
|
720
|
+
JSXStartCloseTag { "</" }
|
|
721
|
+
|
|
722
|
+
JSXEndTag { ">" }
|
|
723
|
+
|
|
724
|
+
JSXSelfCloseEndTag { "/>" }
|
|
725
|
+
|
|
726
|
+
JSXText { ![<{]+ }
|
|
727
|
+
|
|
728
|
+
tsAngleOpen[@dialect=ts,@name="<"] { "<" }
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
@external tokens insertSemicolon from "./tokens" { insertSemi }
|
|
732
|
+
|
|
733
|
+
@external propSource jsHighlight from "./highlight"
|
|
734
|
+
|
|
735
|
+
@detectDelim
|