@@ -60,10 +60,10 @@ declaration
60
60
61
61
classDeclaration
62
62
: modifiers? (CLASS | (FUN NL *)? INTERFACE ) NL * simpleIdentifier
63
- (NL * typeParameters)? (NL * primaryConstructor)?
64
- (NL * COLON NL * delegationSpecifiers)?
65
- (NL * typeConstraints)?
66
- (NL * classBody | NL * enumClassBody)?
63
+ (NL * typeParameters)? (NL * primaryConstructor)?
64
+ (NL * COLON NL * delegationSpecifiers)?
65
+ (NL * typeConstraints)?
66
+ (NL * classBody | NL * enumClassBody)?
67
67
;
68
68
69
69
primaryConstructor
@@ -140,9 +140,9 @@ anonymousInitializer
140
140
141
141
companionObject
142
142
: modifiers? COMPANION NL * OBJECT
143
- (NL * simpleIdentifier)?
144
- (NL * COLON NL * delegationSpecifiers)?
145
- (NL * classBody)?
143
+ (NL * simpleIdentifier)?
144
+ (NL * COLON NL * delegationSpecifiers)?
145
+ (NL * classBody)?
146
146
;
147
147
148
148
functionValueParameters
@@ -155,11 +155,11 @@ functionValueParameter
155
155
156
156
functionDeclaration
157
157
: modifiers?
158
- FUN (NL * typeParameters)? (NL * receiverType NL * DOT )? NL * simpleIdentifier
159
- NL * functionValueParameters
160
- (NL * COLON NL * type)?
161
- (NL * typeConstraints)?
162
- (NL * functionBody)?
158
+ FUN (NL * typeParameters)? (NL * receiverType NL * DOT )? NL * simpleIdentifier
159
+ NL * functionValueParameters
160
+ (NL * COLON NL * type)?
161
+ (NL * typeConstraints)?
162
+ (NL * functionBody)?
163
163
;
164
164
165
165
functionBody
@@ -177,12 +177,12 @@ multiVariableDeclaration
177
177
178
178
propertyDeclaration
179
179
: modifiers? (VAL | VAR )
180
- (NL * typeParameters)?
181
- (NL * receiverType NL * DOT )?
182
- (NL * (multiVariableDeclaration | variableDeclaration))
183
- (NL * typeConstraints)?
184
- (NL * (ASSIGNMENT NL * expression | propertyDelegate))?
185
- (NL + SEMICOLON )? NL * (getter? (NL * semi? setter)? | setter? (NL * semi? getter)?)
180
+ (NL * typeParameters)?
181
+ (NL * receiverType NL * DOT )?
182
+ (NL * (multiVariableDeclaration | variableDeclaration))
183
+ (NL * typeConstraints)?
184
+ (NL * (ASSIGNMENT NL * expression | propertyDelegate))?
185
+ (NL + SEMICOLON )? NL * (getter? (NL * semi? setter)? | setter? (NL * semi? getter)?)
186
186
;
187
187
188
188
propertyDelegate
@@ -191,12 +191,12 @@ propertyDelegate
191
191
192
192
getter
193
193
: modifiers? GET
194
- | modifiers? GET NL * LPAREN NL * RPAREN (NL * COLON NL * type)? NL * functionBody
194
+ ( NL * LPAREN NL * RPAREN (NL * COLON NL * type)? NL * functionBody)?
195
195
;
196
196
197
197
setter
198
198
: modifiers? SET
199
- | modifiers? SET NL * LPAREN NL * parameterWithOptionalType (NL * COMMA )? NL * RPAREN (NL * COLON NL * type)? NL * functionBody
199
+ ( NL * LPAREN NL * parameterWithOptionalType (NL * COMMA )? NL * RPAREN (NL * COLON NL * type)? NL * functionBody)?
200
200
;
201
201
202
202
parametersWithOptionalType
@@ -213,18 +213,17 @@ parameter
213
213
214
214
objectDeclaration
215
215
: modifiers? OBJECT
216
- NL * simpleIdentifier
217
- (NL * COLON NL * delegationSpecifiers)?
218
- (NL * classBody)?
216
+ NL * simpleIdentifier
217
+ (NL * COLON NL * delegationSpecifiers)?
218
+ (NL * classBody)?
219
219
;
220
220
221
221
secondaryConstructor
222
222
: modifiers? CONSTRUCTOR NL * functionValueParameters (NL * COLON NL * constructorDelegationCall)? NL * block?
223
223
;
224
224
225
225
constructorDelegationCall
226
- : THIS NL * valueArguments
227
- | SUPER NL * valueArguments
226
+ : (THIS | SUPER ) NL * valueArguments
228
227
;
229
228
230
229
// SECTION: enumClasses
@@ -244,11 +243,7 @@ enumEntry
244
243
// SECTION: types
245
244
246
245
type
247
- : typeModifiers?
248
- ( parenthesizedType
249
- | nullableType
250
- | typeReference
251
- | functionType)
246
+ : typeModifiers? (parenthesizedType | nullableType | typeReference | functionType)
252
247
;
253
248
254
249
typeReference
@@ -274,7 +269,8 @@ simpleUserType
274
269
;
275
270
276
271
typeProjection
277
- : typeProjectionModifiers? type | MULT
272
+ : typeProjectionModifiers? type
273
+ | MULT
278
274
;
279
275
280
276
typeProjectionModifiers
@@ -299,15 +295,11 @@ parenthesizedType
299
295
;
300
296
301
297
receiverType
302
- : typeModifiers?
303
- ( parenthesizedType
304
- | nullableType
305
- | typeReference)
298
+ : typeModifiers? (parenthesizedType | nullableType | typeReference)
306
299
;
307
300
308
301
parenthesizedUserType
309
- : LPAREN NL * userType NL * RPAREN
310
- | LPAREN NL * parenthesizedUserType NL * RPAREN
302
+ : LPAREN NL * (userType | parenthesizedUserType) NL * RPAREN
311
303
;
312
304
313
305
// SECTION: statements
@@ -317,11 +309,7 @@ statements
317
309
;
318
310
319
311
statement
320
- : (label | annotation)*
321
- ( declaration
322
- | assignment
323
- | loopStatement
324
- | expression)
312
+ : (label | annotation)* ( declaration | assignment | loopStatement | expression)
325
313
;
326
314
327
315
label
@@ -344,26 +332,26 @@ loopStatement
344
332
;
345
333
346
334
forStatement
347
- : FOR NL * LPAREN annotation* (variableDeclaration | multiVariableDeclaration) IN expression RPAREN NL * controlStructureBody?
335
+ : FOR NL * LPAREN annotation* (variableDeclaration | multiVariableDeclaration)
336
+ IN expression RPAREN NL * controlStructureBody?
348
337
;
349
338
350
339
whileStatement
351
- : WHILE NL * LPAREN expression RPAREN NL * controlStructureBody
352
- | WHILE NL * LPAREN expression RPAREN NL * SEMICOLON
340
+ : WHILE NL * LPAREN expression RPAREN NL * (controlStructureBody | SEMICOLON )
353
341
;
354
342
355
343
doWhileStatement
356
344
: DO NL * controlStructureBody? NL * WHILE NL * LPAREN expression RPAREN
357
345
;
358
346
359
347
assignment
360
- : directlyAssignableExpression ASSIGNMENT NL * expression
361
- | assignableExpression assignmentAndOperator NL * expression
348
+ : (directlyAssignableExpression ASSIGNMENT | assignableExpression assignmentAndOperator) NL * expression
362
349
;
363
350
364
351
semi
365
352
: (SEMICOLON | NL ) NL *
366
- | EOF ;
353
+ | EOF
354
+ ;
367
355
368
356
semis
369
357
: (SEMICOLON | NL )+
@@ -439,8 +427,7 @@ unaryPrefix
439
427
;
440
428
441
429
postfixUnaryExpression
442
- : primaryExpression
443
- | primaryExpression postfixUnarySuffix+
430
+ : primaryExpression postfixUnarySuffix*
444
431
;
445
432
446
433
postfixUnarySuffix
@@ -462,7 +449,8 @@ parenthesizedDirectlyAssignableExpression
462
449
;
463
450
464
451
assignableExpression
465
- : prefixUnaryExpression | parenthesizedAssignableExpression
452
+ : prefixUnaryExpression
453
+ | parenthesizedAssignableExpression
466
454
;
467
455
468
456
parenthesizedAssignableExpression
@@ -484,8 +472,7 @@ navigationSuffix
484
472
;
485
473
486
474
callSuffix
487
- : typeArguments? valueArguments? annotatedLambda
488
- | typeArguments? valueArguments
475
+ : typeArguments? (valueArguments? annotatedLambda | valueArguments)
489
476
;
490
477
491
478
annotatedLambda
@@ -497,8 +484,7 @@ typeArguments
497
484
;
498
485
499
486
valueArguments
500
- : LPAREN NL * RPAREN
501
- | LPAREN NL * valueArgument (NL * COMMA NL * valueArgument)* (NL * COMMA )? NL * RPAREN
487
+ : LPAREN NL * (valueArgument (NL * COMMA NL * valueArgument)* (NL * COMMA )? NL *)? RPAREN
502
488
;
503
489
504
490
valueArgument
@@ -527,8 +513,7 @@ parenthesizedExpression
527
513
;
528
514
529
515
collectionLiteral
530
- : LSQUARE NL * expression (NL * COMMA NL * expression)* (NL * COMMA )? NL * RSQUARE
531
- | LSQUARE NL * RSQUARE
516
+ : LSQUARE NL * (expression (NL * COMMA NL * expression)* (NL * COMMA )? NL *)? RSQUARE
532
517
;
533
518
534
519
literalConstant
@@ -577,8 +562,7 @@ multiLineStringExpression
577
562
;
578
563
579
564
lambdaLiteral
580
- : LCURL NL * statements NL * RCURL
581
- | LCURL NL * lambdaParameters? NL * ARROW NL * statements NL * RCURL
565
+ : LCURL NL * (lambdaParameters? NL * ARROW NL *)? statements NL * RCURL
582
566
;
583
567
584
568
lambdaParameters
@@ -592,11 +576,11 @@ lambdaParameter
592
576
593
577
anonymousFunction
594
578
: FUN
595
- (NL * type NL * DOT )?
596
- NL * parametersWithOptionalType
597
- (NL * COLON NL * type)?
598
- (NL * typeConstraints)?
599
- (NL * functionBody)?
579
+ (NL * type NL * DOT )?
580
+ NL * parametersWithOptionalType
581
+ (NL * COLON NL * type)?
582
+ (NL * typeConstraints)?
583
+ (NL * functionBody)?
600
584
;
601
585
602
586
functionLiteral
@@ -605,8 +589,7 @@ functionLiteral
605
589
;
606
590
607
591
objectLiteral
608
- : OBJECT NL * COLON NL * delegationSpecifiers NL * classBody
609
- | OBJECT NL * classBody
592
+ : OBJECT NL * (COLON NL * delegationSpecifiers NL *)? classBody
610
593
;
611
594
612
595
thisExpression
@@ -620,8 +603,10 @@ superExpression
620
603
;
621
604
622
605
ifExpression
623
- : IF NL * LPAREN NL * expression NL * RPAREN NL * (controlStructureBody | SEMICOLON )
624
- | IF NL * LPAREN NL * expression NL * RPAREN NL * controlStructureBody? NL * SEMICOLON ? NL * ELSE NL * (controlStructureBody | SEMICOLON )
606
+ : IF NL * LPAREN NL * expression NL * RPAREN NL *
607
+ ( controlStructureBody
608
+ | controlStructureBody? NL * SEMICOLON ? NL * ELSE NL * (controlStructureBody | SEMICOLON )
609
+ | SEMICOLON )
625
610
;
626
611
627
612
whenSubject
@@ -666,12 +651,14 @@ finallyBlock
666
651
jumpExpression
667
652
: THROW NL * expression
668
653
| (RETURN | RETURN_AT ) expression?
669
- | CONTINUE | CONTINUE_AT
670
- | BREAK | BREAK_AT
654
+ | CONTINUE
655
+ | CONTINUE_AT
656
+ | BREAK
657
+ | BREAK_AT
671
658
;
672
659
673
660
callableReference
674
- : ( receiverType? NL * COLONCOLON NL * (simpleIdentifier | CLASS ) )
661
+ : receiverType? NL * COLONCOLON NL * (simpleIdentifier | CLASS )
675
662
;
676
663
677
664
assignmentAndOperator
@@ -697,15 +684,18 @@ comparisonOperator
697
684
;
698
685
699
686
inOperator
700
- : IN | NOT_IN
687
+ : IN
688
+ | NOT_IN
701
689
;
702
690
703
691
isOperator
704
- : IS | NOT_IS
692
+ : IS
693
+ | NOT_IS
705
694
;
706
695
707
696
additiveOperator
708
- : ADD | SUB
697
+ : ADD
698
+ | SUB
709
699
;
710
700
711
701
multiplicativeOperator
739
729
;
740
730
741
731
memberAccessOperator
742
- : DOT | safeNav | COLONCOLON
732
+ : DOT
733
+ | safeNav
734
+ | COLONCOLON
743
735
;
744
736
745
737
safeNav
@@ -772,7 +764,8 @@ typeModifiers
772
764
;
773
765
774
766
typeModifier
775
- : annotation | SUSPEND NL *
767
+ : annotation
768
+ | SUSPEND NL *
776
769
;
777
770
778
771
classModifier
@@ -851,13 +844,11 @@ annotation
851
844
;
852
845
853
846
singleAnnotation
854
- : annotationUseSiteTarget NL * unescapedAnnotation
855
- | (AT_NO_WS | AT_PRE_WS ) unescapedAnnotation
847
+ : (annotationUseSiteTarget NL * | AT_NO_WS | AT_PRE_WS ) unescapedAnnotation
856
848
;
857
849
858
850
multiAnnotation
859
- : annotationUseSiteTarget NL * LSQUARE unescapedAnnotation+ RSQUARE
860
- | (AT_NO_WS | AT_PRE_WS ) LSQUARE unescapedAnnotation+ RSQUARE
851
+ : (annotationUseSiteTarget NL * | AT_NO_WS | AT_PRE_WS ) LSQUARE unescapedAnnotation+ RSQUARE
861
852
;
862
853
863
854
annotationUseSiteTarget
@@ -871,7 +862,8 @@ unescapedAnnotation
871
862
872
863
// SECTION: identifiers
873
864
874
- simpleIdentifier : Identifier
865
+ simpleIdentifier
866
+ : Identifier
875
867
| ABSTRACT
876
868
| ANNOTATION
877
869
| BY
0 commit comments