@willbooster/tree-sitter-kotlin 1.7.5 → 3.0.0

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
@@ -136,6 +136,8 @@ module.exports = grammar({
136
136
  $._unseparated_member_start,
137
137
  $._infix_position,
138
138
  $._companion_name_position,
139
+ $._try_continuation_position,
140
+ $._infix_get_identifier,
139
141
  ],
140
142
 
141
143
  inline: ($) => [$._statements, $._identifier, $._control_structure_body],
@@ -708,7 +710,15 @@ module.exports = grammar({
708
710
  range_expression: ($) => prec.left(PREC.RANGE, seq($.expression, choice('..', '..<'), $.expression)),
709
711
 
710
712
  infix_expression: ($) =>
711
- prec.left(PREC.INFIX, seq($.expression, optional($._infix_position), $.identifier, $.expression)),
713
+ prec.left(
714
+ PREC.INFIX,
715
+ seq(
716
+ $.expression,
717
+ optional($._infix_position),
718
+ choice($.identifier, alias($._infix_get_identifier, $.identifier)),
719
+ $.expression
720
+ )
721
+ ),
712
722
 
713
723
  // Right-associative so that a trailing lambda after arguments belongs to the same call (`f(x) { … }`), as in
714
724
  // Kotlin, instead of calling the result of `f(x)`.
@@ -820,11 +830,19 @@ module.exports = grammar({
820
830
  type_test: ($) => seq(choice('is', alias($._not_is, '!is')), $.type),
821
831
 
822
832
  try_expression: ($) =>
823
- seq('try', $.block, choice(seq(repeat1($.catch_block), optional($.finally_block)), $.finally_block)),
833
+ seq(
834
+ 'try',
835
+ $.block,
836
+ choice(
837
+ seq(repeat1(seq($.catch_block, optional($._try_continuation_position))), optional($.finally_block)),
838
+ $.finally_block
839
+ )
840
+ ),
824
841
 
825
842
  catch_block: ($) => seq('catch', '(', repeat($.annotation), $.identifier, ':', $.type, optional(','), ')', $.block),
826
843
 
827
- finally_block: ($) => seq('finally', $.block),
844
+ finally_block: ($) =>
845
+ choice(prec(1, seq($._try_continuation_position, 'finally', $.block)), seq('finally', $.block)),
828
846
 
829
847
  return_expression: ($) =>
830
848
  prec.right(seq(choice('return', seq('return@', field('label', $.identifier))), optional($.expression))),
@@ -955,7 +973,7 @@ module.exports = grammar({
955
973
 
956
974
  label: () => token(/[a-zA-Z_][a-zA-Z_0-9]*@/),
957
975
 
958
- _identifier: ($) => choice($.identifier, $._reserved_identifier),
976
+ _identifier: ($) => choice($.identifier, $._reserved_identifier, alias($._infix_get_identifier, $.identifier)),
959
977
 
960
978
  identifier: () => token(choice(/[\p{L}_][\p{L}_\p{Nd}]*/u, /`[^\r\n`]+`/)),
961
979
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-kotlin",
3
- "version": "1.7.5",
3
+ "version": "3.0.0",
4
4
  "description": "Kotlin grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
Binary file
package/tree-sitter.json CHANGED
@@ -13,7 +13,7 @@
13
13
  }
14
14
  ],
15
15
  "metadata": {
16
- "version": "1.7.5",
16
+ "version": "3.0.0",
17
17
  "license": "MIT",
18
18
  "description": "Kotlin grammar for tree-sitter",
19
19
  "authors": [