@willbooster/tree-sitter-kotlin 1.5.6 → 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 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
@@ -473,7 +474,7 @@ module.exports = grammar({
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.
476
- type_arguments: ($) => prec.dynamic(1, seq('<', commaSep1($.type_projection), '>')),
477
+ type_arguments: ($) => prec.dynamic(1, seq('<', commaSep1($.type_projection), optional(','), '>')),
477
478
 
478
479
  type_projection: ($) => choice(seq(repeat($.variance_modifier), $.type), '*'),
479
480
 
@@ -631,7 +632,7 @@ module.exports = grammar({
631
632
  )
632
633
  ),
633
634
 
634
- index_expression: ($) => prec(PREC.CALL, seq($.expression, '[', commaSep($.expression), ']')),
635
+ index_expression: ($) => prec(PREC.CALL, seq($.expression, '[', commaSep1($.expression), optional(','), ']')),
635
636
 
636
637
  this_expression: ($) => seq(choice('this', seq('this@', $.identifier))),
637
638
 
@@ -672,7 +673,7 @@ module.exports = grammar({
672
673
 
673
674
  parenthesized_expression: ($) => seq('(', $.expression, ')'),
674
675
 
675
- collection_literal: ($) => seq('[', commaSep1($.expression), optional(','), ']'),
676
+ collection_literal: ($) => seq('[', optionalCommaSep1($.expression), ']'),
676
677
 
677
678
  when_expression: ($) => seq('when', optional($.when_subject), '{', repeat($.when_entry), '}'),
678
679
 
@@ -696,7 +697,7 @@ module.exports = grammar({
696
697
  try_expression: ($) =>
697
698
  seq('try', $.block, choice(seq(repeat1($.catch_block), optional($.finally_block)), $.finally_block)),
698
699
 
699
- catch_block: ($) => seq('catch', '(', repeat($.annotation), $.identifier, ':', $.type, ')', $.block),
700
+ catch_block: ($) => seq('catch', '(', repeat($.annotation), $.identifier, ':', $.type, optional(','), ')', $.block),
700
701
 
701
702
  finally_block: ($) => seq('finally', $.block),
702
703
 
@@ -898,17 +899,6 @@ function optionalSep1(rule, separator) {
898
899
  return optional(seq(rule, repeat(seq(separator, rule)), optional(separator)));
899
900
  }
900
901
 
901
- /**
902
- * Creates a rule to optionally match one or more of the rules separated by a comma
903
- *
904
- * @param {Rule} rule
905
- *
906
- * @returns {ChoiceRule}
907
- */
908
- function commaSep(rule) {
909
- return optional(commaSep1(rule));
910
- }
911
-
912
902
  /**
913
903
  * Creates a rule to match one or more of the rules separated by a comma
914
904
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-kotlin",
3
- "version": "1.5.6",
3
+ "version": "1.5.7",
4
4
  "description": "Kotlin grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -793,7 +793,7 @@
793
793
  "fields": {},
794
794
  "children": {
795
795
  "multiple": true,
796
- "required": true,
796
+ "required": false,
797
797
  "types": [
798
798
  {
799
799
  "type": "expression",
Binary file
package/tree-sitter.json CHANGED
@@ -13,7 +13,7 @@
13
13
  }
14
14
  ],
15
15
  "metadata": {
16
- "version": "1.5.6",
16
+ "version": "1.5.7",
17
17
  "license": "MIT",
18
18
  "description": "Kotlin grammar for tree-sitter",
19
19
  "authors": [