@@ -177,12 +177,12 @@ module.exports = grammar({
177177 top_level_object : $ => seq ( $ . _declaration , optional ( $ . _semi ) ) ,
178178
179179 type_alias : $ => seq (
180- optional ( field ( 'modifiers' , $ . modifiers ) ) ,
180+ optional ( $ . modifiers ) ,
181181 "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 ) ,
184184 "=" ,
185- field ( 'type' , $ . _type )
185+ $ . _type
186186 ) ,
187187
188188 _declaration : $ => choice (
@@ -208,30 +208,30 @@ module.exports = grammar({
208208
209209 class_declaration : $ => prec . right ( choice (
210210 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 )
219219 ) ,
220220 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 )
229229 )
230230 ) ) ,
231231
232232 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
235235 ) ,
236236
237237 class_body : $ => seq ( "{" , optional ( $ . _class_member_declarations ) , "}" ) ,
@@ -308,15 +308,15 @@ module.exports = grammar({
308308 $ . secondary_constructor
309309 ) ,
310310
311- anonymous_initializer : $ => seq ( "init" , field ( 'body' , $ . _block ) ) ,
311+ anonymous_initializer : $ => seq ( "init" , $ . _block ) ,
312312
313313 companion_object : $ => seq (
314- optional ( field ( 'modifiers' , $ . modifiers ) ) ,
314+ optional ( $ . modifiers ) ,
315315 "companion" ,
316316 "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 )
320320 ) ,
321321
322322 function_value_parameters : $ => seq (
@@ -342,15 +342,15 @@ module.exports = grammar({
342342 ) ,
343343
344344 function_declaration : $ => prec . right ( seq ( // TODO
345- optional ( field ( 'modifiers' , $ . modifiers ) ) ,
345+ optional ( $ . modifiers ) ,
346346 "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 )
354354 ) ) ,
355355
356356 function_body : $ => choice ( $ . _block , seq ( "=" , $ . _expression ) ) ,
@@ -362,21 +362,21 @@ module.exports = grammar({
362362 ) ) ,
363363
364364 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 ) ,
371371 optional ( choice (
372- seq ( "=" , field ( 'expression' , $ . _expression ) ) ,
373- field ( 'delegate' , $ . property_delegate )
372+ seq ( "=" , $ . _expression ) ,
373+ $ . property_delegate
374374 ) ) ,
375375 optional ( ';' ) ,
376376 choice (
377377 // TODO: Getter-setter combinations
378- optional ( field ( 'getter' , $ . getter ) ) ,
379- optional ( field ( 'setter' , $ . setter ) )
378+ optional ( $ . getter ) ,
379+ optional ( $ . setter )
380380 )
381381 ) ) ,
382382
@@ -415,19 +415,19 @@ module.exports = grammar({
415415 parameter : $ => seq ( $ . simple_identifier , ":" , $ . _type ) ,
416416
417417 object_declaration : $ => prec . right ( seq (
418- optional ( field ( 'modifiers' , $ . modifiers ) ) ,
418+ optional ( $ . modifiers ) ,
419419 "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 )
423423 ) ) ,
424424
425425 secondary_constructor : $ => seq (
426- optional ( field ( 'modifiers' , $ . modifiers ) ) ,
426+ optional ( $ . modifiers ) ,
427427 "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 )
431431 ) ,
432432
433433 constructor_delegation_call : $ => seq ( choice ( "this" , "super" ) , $ . value_arguments ) ,
@@ -570,30 +570,27 @@ module.exports = grammar({
570570 "for" ,
571571 "(" ,
572572 repeat ( $ . annotation ) ,
573- choice (
574- field ( 'variable' , $ . variable_declaration ) ,
575- field ( 'variables' , $ . multi_variable_declaration )
576- ) ,
573+ choice ( $ . variable_declaration , $ . multi_variable_declaration ) ,
577574 "in" ,
578- field ( 'value' , $ . _expression ) ,
575+ $ . _expression ,
579576 ")" ,
580- optional ( field ( 'body' , $ . control_structure_body ) )
577+ optional ( $ . control_structure_body )
581578 ) ) ,
582579
583580 while_statement : $ => seq (
584581 "while" ,
585582 "(" ,
586- field ( 'condition' , $ . _expression ) ,
583+ $ . _expression ,
587584 ")" ,
588- choice ( ";" , field ( 'body' , $ . control_structure_body ) )
585+ choice ( ";" , $ . control_structure_body )
589586 ) ,
590587
591588 do_while_statement : $ => prec . right ( seq (
592589 "do" ,
593- optional ( field ( 'body' , $ . control_structure_body ) ) ,
590+ optional ( $ . control_structure_body ) ,
594591 "while" ,
595592 "(" ,
596- field ( 'condition' , $ . _expression ) ,
593+ $ . _expression ,
597594 ")" ,
598595 ) ) ,
599596
@@ -778,8 +775,8 @@ module.exports = grammar({
778775
779776 lambda_literal : $ => prec ( PREC . LAMBDA_LITERAL , seq (
780777 "{" ,
781- optional ( seq ( optional ( field ( 'parameters' , $ . lambda_parameters ) ) , "->" ) ) ,
782- optional ( field ( 'body' , $ . statements ) ) ,
778+ optional ( seq ( optional ( $ . lambda_parameters ) , "->" ) ) ,
779+ optional ( $ . statements ) ,
783780 "}"
784781 ) ) ,
785782
@@ -799,9 +796,9 @@ module.exports = grammar({
799796 anonymous_function : $ => prec . right ( seq (
800797 "fun" ,
801798 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 )
805802 ) ) ,
806803
807804 _function_literal : $ => choice (
@@ -811,8 +808,8 @@ module.exports = grammar({
811808
812809 object_literal : $ => seq (
813810 "object" ,
814- optional ( seq ( ":" , field ( 'delegation_specifiers' , $ . _delegation_specifiers ) ) ) ,
815- field ( 'body' , $ . class_body )
811+ optional ( seq ( ":" , $ . _delegation_specifiers ) ) ,
812+ $ . class_body
816813 ) ,
817814
818815 this_expression : $ => choice (
@@ -828,15 +825,15 @@ module.exports = grammar({
828825
829826 if_expression : $ => prec . right ( seq (
830827 "if" ,
831- "(" , field ( 'condition' , $ . _expression ) , ")" ,
828+ "(" , $ . _expression , ")" ,
832829 choice (
833- field ( 'consequence' , $ . control_structure_body ) ,
830+ $ . control_structure_body ,
834831 ";" ,
835832 seq (
836- optional ( field ( 'consequence' , $ . control_structure_body ) ) ,
833+ optional ( $ . control_structure_body ) ,
837834 optional ( ";" ) ,
838835 "else" ,
839- choice ( field ( 'alternative' , $ . control_structure_body ) , ";" )
836+ choice ( $ . control_structure_body , ";" )
840837 )
841838 )
842839 ) ) ,
@@ -855,19 +852,19 @@ module.exports = grammar({
855852
856853 when_expression : $ => seq (
857854 "when" ,
858- optional ( field ( 'subject' , $ . when_subject ) ) ,
855+ optional ( $ . when_subject ) ,
859856 "{" ,
860- repeat ( field ( 'entry' , $ . when_entry ) ) ,
857+ repeat ( $ . when_entry ) ,
861858 "}"
862859 ) ,
863860
864861 when_entry : $ => seq (
865862 choice (
866- seq ( field ( 'condition' , $ . when_condition ) , repeat ( seq ( "," , field ( 'condition' , $ . when_condition ) ) ) ) ,
863+ seq ( $ . when_condition , repeat ( seq ( "," , $ . when_condition ) ) ) ,
867864 "else"
868865 ) ,
869866 "->" ,
870- field ( 'body' , $ . control_structure_body ) ,
867+ $ . control_structure_body ,
871868 optional ( $ . _semi )
872869 ) ,
873870
@@ -883,9 +880,9 @@ module.exports = grammar({
883880
884881 try_expression : $ => seq (
885882 "try" ,
886- field ( 'body' , $ . _block ) ,
883+ $ . _block ,
887884 choice (
888- seq ( repeat1 ( field ( 'catch' , $ . catch_block ) ) , optional ( field ( 'finally' , $ . finally_block ) ) ) ,
885+ seq ( repeat1 ( $ . catch_block ) , optional ( $ . finally_block ) ) ,
889886 $ . finally_block
890887 )
891888 ) ,
@@ -898,10 +895,10 @@ module.exports = grammar({
898895 ":" ,
899896 $ . _type ,
900897 ")" ,
901- field ( 'body' , $ . _block ) ,
898+ $ . _block ,
902899 ) ,
903900
904- finally_block : $ => seq ( "finally" , field ( 'body' , $ . _block ) ) ,
901+ finally_block : $ => seq ( "finally" , $ . _block ) ,
905902
906903 jump_expression : $ => choice (
907904 prec . right ( PREC . RETURN_OR_THROW , seq ( "throw" , $ . _expression ) ) ,
0 commit comments