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