@@ -177,12 +177,12 @@ module.exports = grammar({
177
177
top_level_object : $ => seq ( $ . _declaration , optional ( $ . _semi ) ) ,
178
178
179
179
type_alias : $ => seq (
180
- optional ( field ( 'modifiers' , $ . modifiers ) ) ,
180
+ optional ( $ . modifiers ) ,
181
181
"typealias" ,
182
- field ( 'name' , alias ( $ . simple_identifier , $ . type_identifier ) ) ,
183
- optional ( field ( 'type_parameters' , $ . type_parameters ) ) ,
182
+ alias ( $ . simple_identifier , $ . type_identifier ) ,
183
+ optional ( $ . type_parameters ) ,
184
184
"=" ,
185
- field ( 'type' , $ . _type )
185
+ $ . _type
186
186
) ,
187
187
188
188
_declaration : $ => choice (
@@ -208,30 +208,30 @@ module.exports = grammar({
208
208
209
209
class_declaration : $ => prec . right ( choice (
210
210
seq (
211
- optional ( field ( 'modifiers' , $ . modifiers ) ) ,
212
- field ( 'kind' , choice ( "class" , "interface" ) ) ,
213
- field ( 'name' , alias ( $ . simple_identifier , $ . type_identifier ) ) ,
214
- optional ( field ( 'type_parameters' , $ . type_parameters ) ) ,
215
- optional ( field ( 'primary_constructor' , $ . primary_constructor ) ) ,
216
- optional ( seq ( ":" , field ( 'delegation_specifiers' , $ . _delegation_specifiers ) ) ) ,
217
- optional ( field ( 'constraints' , $ . type_constraints ) ) ,
218
- optional ( field ( 'body' , $ . class_body ) )
211
+ optional ( $ . modifiers ) ,
212
+ choice ( "class" , "interface" ) ,
213
+ alias ( $ . simple_identifier , $ . type_identifier ) ,
214
+ optional ( $ . type_parameters ) ,
215
+ optional ( $ . primary_constructor ) ,
216
+ optional ( seq ( ":" , $ . _delegation_specifiers ) ) ,
217
+ optional ( $ . type_constraints ) ,
218
+ optional ( $ . class_body )
219
219
) ,
220
220
seq (
221
- optional ( field ( 'modifiers' , $ . modifiers ) ) ,
222
- field ( 'kind' , "enum" ) , "class" ,
223
- field ( 'name' , alias ( $ . simple_identifier , $ . type_identifier ) ) ,
224
- optional ( field ( 'type_parameters' , $ . type_parameters ) ) ,
225
- optional ( field ( 'primary_constructor' , $ . primary_constructor ) ) ,
226
- optional ( seq ( ":" , field ( 'delegation_specifiers' , $ . _delegation_specifiers ) ) ) ,
227
- optional ( field ( 'constraints' , $ . type_constraints ) ) ,
228
- optional ( field ( 'body' , $ . enum_class_body ) )
221
+ optional ( $ . modifiers ) ,
222
+ "enum" , "class" ,
223
+ alias ( $ . simple_identifier , $ . type_identifier ) ,
224
+ optional ( $ . type_parameters ) ,
225
+ optional ( $ . primary_constructor ) ,
226
+ optional ( seq ( ":" , $ . _delegation_specifiers ) ) ,
227
+ optional ( $ . type_constraints ) ,
228
+ optional ( $ . enum_class_body )
229
229
)
230
230
) ) ,
231
231
232
232
primary_constructor : $ => seq (
233
- optional ( seq ( optional ( field ( 'modifiers' , $ . modifiers ) ) , "constructor" ) ) ,
234
- field ( 'parameters' , $ . _class_parameters )
233
+ optional ( seq ( optional ( $ . modifiers ) , "constructor" ) ) ,
234
+ $ . _class_parameters
235
235
) ,
236
236
237
237
class_body : $ => seq ( "{" , optional ( $ . _class_member_declarations ) , "}" ) ,
@@ -308,15 +308,15 @@ module.exports = grammar({
308
308
$ . secondary_constructor
309
309
) ,
310
310
311
- anonymous_initializer : $ => seq ( "init" , field ( 'body' , $ . _block ) ) ,
311
+ anonymous_initializer : $ => seq ( "init" , $ . _block ) ,
312
312
313
313
companion_object : $ => seq (
314
- optional ( field ( 'modifiers' , $ . modifiers ) ) ,
314
+ optional ( $ . modifiers ) ,
315
315
"companion" ,
316
316
"object" ,
317
- optional ( field ( 'name' , alias ( $ . simple_identifier , $ . type_identifier ) ) ) ,
318
- optional ( seq ( ":" , field ( 'delegation_specifiers' , $ . _delegation_specifiers ) ) ) ,
319
- optional ( field ( 'body' , $ . class_body ) )
317
+ optional ( alias ( $ . simple_identifier , $ . type_identifier ) ) ,
318
+ optional ( seq ( ":" , $ . _delegation_specifiers ) ) ,
319
+ optional ( $ . class_body )
320
320
) ,
321
321
322
322
function_value_parameters : $ => seq (
@@ -342,15 +342,15 @@ module.exports = grammar({
342
342
) ,
343
343
344
344
function_declaration : $ => prec . right ( seq ( // TODO
345
- optional ( field ( 'modifiers' , $ . modifiers ) ) ,
345
+ optional ( $ . modifiers ) ,
346
346
"fun" ,
347
- optional ( field ( 'type_parameters' , $ . type_parameters ) ) ,
348
- optional ( seq ( field ( 'receiver' , $ . _receiver_type ) , optional ( '.' ) ) ) ,
349
- field ( 'name' , $ . simple_identifier ) ,
350
- field ( 'parameters' , $ . function_value_parameters ) ,
351
- optional ( seq ( ":" , field ( 'return_type' , $ . _type ) ) ) ,
352
- optional ( field ( 'constraints' , $ . type_constraints ) ) ,
353
- optional ( field ( 'body' , $ . function_body ) )
347
+ optional ( $ . type_parameters ) ,
348
+ optional ( seq ( $ . _receiver_type , optional ( '.' ) ) ) ,
349
+ $ . simple_identifier ,
350
+ $ . function_value_parameters ,
351
+ optional ( seq ( ":" , $ . _type ) ) ,
352
+ optional ( $ . type_constraints ) ,
353
+ optional ( $ . function_body )
354
354
) ) ,
355
355
356
356
function_body : $ => choice ( $ . _block , seq ( "=" , $ . _expression ) ) ,
@@ -362,21 +362,21 @@ module.exports = grammar({
362
362
) ) ,
363
363
364
364
property_declaration : $ => prec . right ( seq (
365
- optional ( field ( 'modifiers' , $ . modifiers ) ) ,
366
- field ( 'kind' , choice ( "val" , "var" ) ) ,
367
- optional ( field ( 'type_parameters' , $ . type_parameters ) ) ,
368
- optional ( seq ( field ( 'receiver' , $ . _receiver_type ) , optional ( '.' ) ) ) ,
369
- choice ( field ( 'variable' , $ . variable_declaration ) , field ( 'variables' , $ . multi_variable_declaration ) ) ,
370
- optional ( field ( 'constraints' , $ . type_constraints ) ) ,
365
+ optional ( $ . modifiers ) ,
366
+ choice ( "val" , "var" ) ,
367
+ optional ( $ . type_parameters ) ,
368
+ optional ( seq ( $ . _receiver_type , optional ( '.' ) ) ) ,
369
+ choice ( $ . variable_declaration , $ . multi_variable_declaration ) ,
370
+ optional ( $ . type_constraints ) ,
371
371
optional ( choice (
372
- seq ( "=" , field ( 'expression' , $ . _expression ) ) ,
373
- field ( 'delegate' , $ . property_delegate )
372
+ seq ( "=" , $ . _expression ) ,
373
+ $ . property_delegate
374
374
) ) ,
375
375
optional ( ';' ) ,
376
376
choice (
377
377
// TODO: Getter-setter combinations
378
- optional ( field ( 'getter' , $ . getter ) ) ,
379
- optional ( field ( 'setter' , $ . setter ) )
378
+ optional ( $ . getter ) ,
379
+ optional ( $ . setter )
380
380
)
381
381
) ) ,
382
382
@@ -415,19 +415,19 @@ module.exports = grammar({
415
415
parameter : $ => seq ( $ . simple_identifier , ":" , $ . _type ) ,
416
416
417
417
object_declaration : $ => prec . right ( seq (
418
- optional ( field ( 'modifiers' , $ . modifiers ) ) ,
418
+ optional ( $ . modifiers ) ,
419
419
"object" ,
420
- field ( 'name' , alias ( $ . simple_identifier , $ . type_identifier ) ) ,
421
- optional ( seq ( ":" , field ( 'delegation_specifiers' , $ . _delegation_specifiers ) ) ) ,
422
- optional ( field ( 'body' , $ . class_body ) )
420
+ alias ( $ . simple_identifier , $ . type_identifier ) ,
421
+ optional ( seq ( ":" , $ . _delegation_specifiers ) ) ,
422
+ optional ( $ . class_body )
423
423
) ) ,
424
424
425
425
secondary_constructor : $ => seq (
426
- optional ( field ( 'modifiers' , $ . modifiers ) ) ,
426
+ optional ( $ . modifiers ) ,
427
427
"constructor" ,
428
- field ( 'parameters' , $ . function_value_parameters ) ,
429
- optional ( seq ( ":" , field ( 'delegation' , $ . constructor_delegation_call ) ) ) ,
430
- optional ( field ( 'body' , $ . _block ) )
428
+ $ . function_value_parameters ,
429
+ optional ( seq ( ":" , $ . constructor_delegation_call ) ) ,
430
+ optional ( $ . _block )
431
431
) ,
432
432
433
433
constructor_delegation_call : $ => seq ( choice ( "this" , "super" ) , $ . value_arguments ) ,
@@ -570,30 +570,27 @@ module.exports = grammar({
570
570
"for" ,
571
571
"(" ,
572
572
repeat ( $ . annotation ) ,
573
- choice (
574
- field ( 'variable' , $ . variable_declaration ) ,
575
- field ( 'variables' , $ . multi_variable_declaration )
576
- ) ,
573
+ choice ( $ . variable_declaration , $ . multi_variable_declaration ) ,
577
574
"in" ,
578
- field ( 'value' , $ . _expression ) ,
575
+ $ . _expression ,
579
576
")" ,
580
- optional ( field ( 'body' , $ . control_structure_body ) )
577
+ optional ( $ . control_structure_body )
581
578
) ) ,
582
579
583
580
while_statement : $ => seq (
584
581
"while" ,
585
582
"(" ,
586
- field ( 'condition' , $ . _expression ) ,
583
+ $ . _expression ,
587
584
")" ,
588
- choice ( ";" , field ( 'body' , $ . control_structure_body ) )
585
+ choice ( ";" , $ . control_structure_body )
589
586
) ,
590
587
591
588
do_while_statement : $ => prec . right ( seq (
592
589
"do" ,
593
- optional ( field ( 'body' , $ . control_structure_body ) ) ,
590
+ optional ( $ . control_structure_body ) ,
594
591
"while" ,
595
592
"(" ,
596
- field ( 'condition' , $ . _expression ) ,
593
+ $ . _expression ,
597
594
")" ,
598
595
) ) ,
599
596
@@ -778,8 +775,8 @@ module.exports = grammar({
778
775
779
776
lambda_literal : $ => prec ( PREC . LAMBDA_LITERAL , seq (
780
777
"{" ,
781
- optional ( seq ( optional ( field ( 'parameters' , $ . lambda_parameters ) ) , "->" ) ) ,
782
- optional ( field ( 'body' , $ . statements ) ) ,
778
+ optional ( seq ( optional ( $ . lambda_parameters ) , "->" ) ) ,
779
+ optional ( $ . statements ) ,
783
780
"}"
784
781
) ) ,
785
782
@@ -799,9 +796,9 @@ module.exports = grammar({
799
796
anonymous_function : $ => prec . right ( seq (
800
797
"fun" ,
801
798
optional ( seq ( sep1 ( $ . _simple_user_type , "." ) , "." ) ) , // TODO
802
- field ( 'parameters' , $ . function_value_parameters ) ,
803
- optional ( seq ( ":" , field ( 'return_type' , $ . _type ) ) ) ,
804
- optional ( field ( 'body' , $ . function_body ) )
799
+ $ . function_value_parameters ,
800
+ optional ( seq ( ":" , $ . _type ) ) ,
801
+ optional ( $ . function_body )
805
802
) ) ,
806
803
807
804
_function_literal : $ => choice (
@@ -811,8 +808,8 @@ module.exports = grammar({
811
808
812
809
object_literal : $ => seq (
813
810
"object" ,
814
- optional ( seq ( ":" , field ( 'delegation_specifiers' , $ . _delegation_specifiers ) ) ) ,
815
- field ( 'body' , $ . class_body )
811
+ optional ( seq ( ":" , $ . _delegation_specifiers ) ) ,
812
+ $ . class_body
816
813
) ,
817
814
818
815
this_expression : $ => choice (
@@ -828,15 +825,15 @@ module.exports = grammar({
828
825
829
826
if_expression : $ => prec . right ( seq (
830
827
"if" ,
831
- "(" , field ( 'condition' , $ . _expression ) , ")" ,
828
+ "(" , $ . _expression , ")" ,
832
829
choice (
833
- field ( 'consequence' , $ . control_structure_body ) ,
830
+ $ . control_structure_body ,
834
831
";" ,
835
832
seq (
836
- optional ( field ( 'consequence' , $ . control_structure_body ) ) ,
833
+ optional ( $ . control_structure_body ) ,
837
834
optional ( ";" ) ,
838
835
"else" ,
839
- choice ( field ( 'alternative' , $ . control_structure_body ) , ";" )
836
+ choice ( $ . control_structure_body , ";" )
840
837
)
841
838
)
842
839
) ) ,
@@ -855,19 +852,19 @@ module.exports = grammar({
855
852
856
853
when_expression : $ => seq (
857
854
"when" ,
858
- optional ( field ( 'subject' , $ . when_subject ) ) ,
855
+ optional ( $ . when_subject ) ,
859
856
"{" ,
860
- repeat ( field ( 'entry' , $ . when_entry ) ) ,
857
+ repeat ( $ . when_entry ) ,
861
858
"}"
862
859
) ,
863
860
864
861
when_entry : $ => seq (
865
862
choice (
866
- seq ( field ( 'condition' , $ . when_condition ) , repeat ( seq ( "," , field ( 'condition' , $ . when_condition ) ) ) ) ,
863
+ seq ( $ . when_condition , repeat ( seq ( "," , $ . when_condition ) ) ) ,
867
864
"else"
868
865
) ,
869
866
"->" ,
870
- field ( 'body' , $ . control_structure_body ) ,
867
+ $ . control_structure_body ,
871
868
optional ( $ . _semi )
872
869
) ,
873
870
@@ -883,9 +880,9 @@ module.exports = grammar({
883
880
884
881
try_expression : $ => seq (
885
882
"try" ,
886
- field ( 'body' , $ . _block ) ,
883
+ $ . _block ,
887
884
choice (
888
- seq ( repeat1 ( field ( 'catch' , $ . catch_block ) ) , optional ( field ( 'finally' , $ . finally_block ) ) ) ,
885
+ seq ( repeat1 ( $ . catch_block ) , optional ( $ . finally_block ) ) ,
889
886
$ . finally_block
890
887
)
891
888
) ,
@@ -898,10 +895,10 @@ module.exports = grammar({
898
895
":" ,
899
896
$ . _type ,
900
897
")" ,
901
- field ( 'body' , $ . _block ) ,
898
+ $ . _block ,
902
899
) ,
903
900
904
- finally_block : $ => seq ( "finally" , field ( 'body' , $ . _block ) ) ,
901
+ finally_block : $ => seq ( "finally" , $ . _block ) ,
905
902
906
903
jump_expression : $ => choice (
907
904
prec . right ( PREC . RETURN_OR_THROW , seq ( "throw" , $ . _expression ) ) ,
0 commit comments