@willbooster/tree-sitter-kotlin 1.5.6 → 1.5.8
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 +8 -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
|
@@ -82,6 +82,8 @@ module.exports = grammar({
|
|
|
82
82
|
$._semi,
|
|
83
83
|
$._class_member_semi,
|
|
84
84
|
$.block_comment,
|
|
85
|
+
// also lexed by the scanner, since the generated lexer stops at a NUL character
|
|
86
|
+
$.line_comment,
|
|
85
87
|
$._not_is,
|
|
86
88
|
$._in,
|
|
87
89
|
$._q_dot,
|
|
@@ -242,7 +244,7 @@ module.exports = grammar({
|
|
|
242
244
|
|
|
243
245
|
constructor_delegation_call: ($) => seq(choice('this', 'super'), $.value_arguments),
|
|
244
246
|
|
|
245
|
-
type_parameters: ($) => seq('<', commaSep1($.type_parameter), '>'),
|
|
247
|
+
type_parameters: ($) => seq('<', commaSep1($.type_parameter), optional(','), '>'),
|
|
246
248
|
|
|
247
249
|
type_parameter: ($) => seq(optional($.type_parameter_modifiers), $.identifier, optional(seq(':', $.type))),
|
|
248
250
|
|
|
@@ -323,6 +325,7 @@ module.exports = grammar({
|
|
|
323
325
|
$.identifier,
|
|
324
326
|
optional(seq(':', $.type)),
|
|
325
327
|
optional(seq('=', $.expression)),
|
|
328
|
+
optional(','),
|
|
326
329
|
')',
|
|
327
330
|
optional(seq(':', $.type)),
|
|
328
331
|
$.function_body
|
|
@@ -473,7 +476,7 @@ module.exports = grammar({
|
|
|
473
476
|
seq(optional($.type_modifiers), choice($.user_type, 'dynamic', $.parenthesized_type, $.nullable_type)),
|
|
474
477
|
|
|
475
478
|
// `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), '>')),
|
|
479
|
+
type_arguments: ($) => prec.dynamic(1, seq('<', commaSep1($.type_projection), optional(','), '>')),
|
|
477
480
|
|
|
478
481
|
type_projection: ($) => choice(seq(repeat($.variance_modifier), $.type), '*'),
|
|
479
482
|
|
|
@@ -631,7 +634,7 @@ module.exports = grammar({
|
|
|
631
634
|
)
|
|
632
635
|
),
|
|
633
636
|
|
|
634
|
-
index_expression: ($) => prec(PREC.CALL, seq($.expression, '[',
|
|
637
|
+
index_expression: ($) => prec(PREC.CALL, seq($.expression, '[', commaSep1($.expression), optional(','), ']')),
|
|
635
638
|
|
|
636
639
|
this_expression: ($) => seq(choice('this', seq('this@', $.identifier))),
|
|
637
640
|
|
|
@@ -672,7 +675,7 @@ module.exports = grammar({
|
|
|
672
675
|
|
|
673
676
|
parenthesized_expression: ($) => seq('(', $.expression, ')'),
|
|
674
677
|
|
|
675
|
-
collection_literal: ($) => seq('[',
|
|
678
|
+
collection_literal: ($) => seq('[', optionalCommaSep1($.expression), ']'),
|
|
676
679
|
|
|
677
680
|
when_expression: ($) => seq('when', optional($.when_subject), '{', repeat($.when_entry), '}'),
|
|
678
681
|
|
|
@@ -696,7 +699,7 @@ module.exports = grammar({
|
|
|
696
699
|
try_expression: ($) =>
|
|
697
700
|
seq('try', $.block, choice(seq(repeat1($.catch_block), optional($.finally_block)), $.finally_block)),
|
|
698
701
|
|
|
699
|
-
catch_block: ($) => seq('catch', '(', repeat($.annotation), $.identifier, ':', $.type, ')', $.block),
|
|
702
|
+
catch_block: ($) => seq('catch', '(', repeat($.annotation), $.identifier, ':', $.type, optional(','), ')', $.block),
|
|
700
703
|
|
|
701
704
|
finally_block: ($) => seq('finally', $.block),
|
|
702
705
|
|
|
@@ -898,17 +901,6 @@ function optionalSep1(rule, separator) {
|
|
|
898
901
|
return optional(seq(rule, repeat(seq(separator, rule)), optional(separator)));
|
|
899
902
|
}
|
|
900
903
|
|
|
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
904
|
/**
|
|
913
905
|
* Creates a rule to match one or more of the rules separated by a comma
|
|
914
906
|
*
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
package/tree-sitter-kotlin.wasm
CHANGED
|
Binary file
|