@willbooster/tree-sitter-kotlin 1.5.5 → 1.5.7
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/grammar.js +7 -16
- package/package.json +1 -1
- package/src/node-types.json +1 -1
- package/tree-sitter-kotlin.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -242,7 +242,7 @@ module.exports = grammar({
|
|
|
242
242
|
|
|
243
243
|
constructor_delegation_call: ($) => seq(choice('this', 'super'), $.value_arguments),
|
|
244
244
|
|
|
245
|
-
type_parameters: ($) => seq('<', commaSep1($.type_parameter), '>'),
|
|
245
|
+
type_parameters: ($) => seq('<', commaSep1($.type_parameter), optional(','), '>'),
|
|
246
246
|
|
|
247
247
|
type_parameter: ($) => seq(optional($.type_parameter_modifiers), $.identifier, optional(seq(':', $.type))),
|
|
248
248
|
|
|
@@ -323,6 +323,7 @@ module.exports = grammar({
|
|
|
323
323
|
$.identifier,
|
|
324
324
|
optional(seq(':', $.type)),
|
|
325
325
|
optional(seq('=', $.expression)),
|
|
326
|
+
optional(','),
|
|
326
327
|
')',
|
|
327
328
|
optional(seq(':', $.type)),
|
|
328
329
|
$.function_body
|
|
@@ -472,7 +473,8 @@ module.exports = grammar({
|
|
|
472
473
|
_receiver_type: ($) =>
|
|
473
474
|
seq(optional($.type_modifiers), choice($.user_type, 'dynamic', $.parenthesized_type, $.nullable_type)),
|
|
474
475
|
|
|
475
|
-
|
|
476
|
+
// `a<B>(c)` also reads as comparisons (`a < B > (c)`); like Kotlin's parser, prefer the type arguments.
|
|
477
|
+
type_arguments: ($) => prec.dynamic(1, seq('<', commaSep1($.type_projection), optional(','), '>')),
|
|
476
478
|
|
|
477
479
|
type_projection: ($) => choice(seq(repeat($.variance_modifier), $.type), '*'),
|
|
478
480
|
|
|
@@ -630,7 +632,7 @@ module.exports = grammar({
|
|
|
630
632
|
)
|
|
631
633
|
),
|
|
632
634
|
|
|
633
|
-
index_expression: ($) => prec(PREC.CALL, seq($.expression, '[',
|
|
635
|
+
index_expression: ($) => prec(PREC.CALL, seq($.expression, '[', commaSep1($.expression), optional(','), ']')),
|
|
634
636
|
|
|
635
637
|
this_expression: ($) => seq(choice('this', seq('this@', $.identifier))),
|
|
636
638
|
|
|
@@ -671,7 +673,7 @@ module.exports = grammar({
|
|
|
671
673
|
|
|
672
674
|
parenthesized_expression: ($) => seq('(', $.expression, ')'),
|
|
673
675
|
|
|
674
|
-
collection_literal: ($) => seq('[',
|
|
676
|
+
collection_literal: ($) => seq('[', optionalCommaSep1($.expression), ']'),
|
|
675
677
|
|
|
676
678
|
when_expression: ($) => seq('when', optional($.when_subject), '{', repeat($.when_entry), '}'),
|
|
677
679
|
|
|
@@ -695,7 +697,7 @@ module.exports = grammar({
|
|
|
695
697
|
try_expression: ($) =>
|
|
696
698
|
seq('try', $.block, choice(seq(repeat1($.catch_block), optional($.finally_block)), $.finally_block)),
|
|
697
699
|
|
|
698
|
-
catch_block: ($) => seq('catch', '(', repeat($.annotation), $.identifier, ':', $.type, ')', $.block),
|
|
700
|
+
catch_block: ($) => seq('catch', '(', repeat($.annotation), $.identifier, ':', $.type, optional(','), ')', $.block),
|
|
699
701
|
|
|
700
702
|
finally_block: ($) => seq('finally', $.block),
|
|
701
703
|
|
|
@@ -897,17 +899,6 @@ function optionalSep1(rule, separator) {
|
|
|
897
899
|
return optional(seq(rule, repeat(seq(separator, rule)), optional(separator)));
|
|
898
900
|
}
|
|
899
901
|
|
|
900
|
-
/**
|
|
901
|
-
* Creates a rule to optionally match one or more of the rules separated by a comma
|
|
902
|
-
*
|
|
903
|
-
* @param {Rule} rule
|
|
904
|
-
*
|
|
905
|
-
* @returns {ChoiceRule}
|
|
906
|
-
*/
|
|
907
|
-
function commaSep(rule) {
|
|
908
|
-
return optional(commaSep1(rule));
|
|
909
|
-
}
|
|
910
|
-
|
|
911
902
|
/**
|
|
912
903
|
* Creates a rule to match one or more of the rules separated by a comma
|
|
913
904
|
*
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
package/tree-sitter-kotlin.wasm
CHANGED
|
Binary file
|