@willbooster/tree-sitter-kotlin 1.5.7 → 1.5.9
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 +11 -11
- package/package.json +1 -1
- package/src/node-types.json +4 -0
- 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,
|
|
@@ -767,23 +769,21 @@ module.exports = grammar({
|
|
|
767
769
|
)
|
|
768
770
|
),
|
|
769
771
|
|
|
770
|
-
interpolation: ($) =>
|
|
772
|
+
interpolation: ($) => choice(seq('$', $._template_name), seq('${', $.expression, '}')),
|
|
773
|
+
|
|
774
|
+
// Immediate so that it outranks the string content that would otherwise absorb the name. As in Kotlin, `$this`
|
|
775
|
+
// refers to `this`: with the same token precedence as the name pattern, the string token wins a match of equal
|
|
776
|
+
// length (without its `prec(2)`, `$this` lexes as a name again), while a longer name such as `$thisX` still wins.
|
|
777
|
+
_template_name: ($) =>
|
|
771
778
|
choice(
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
seq('${', $.expression, '}')
|
|
779
|
+
alias(token.immediate(prec(2, /[\p{L}_][\p{L}_\p{Nd}]*/u)), $.identifier),
|
|
780
|
+
alias(token.immediate(prec(2, 'this')), $.this_expression)
|
|
775
781
|
),
|
|
776
782
|
|
|
777
783
|
// In a string prefixed with n dollars (Kotlin 2.1), exactly n dollars start an interpolation; the scanner
|
|
778
784
|
// returns them as one token only where they do.
|
|
779
785
|
_multi_dollar_interpolation: ($) =>
|
|
780
|
-
seq(
|
|
781
|
-
$._multi_dollar_interpolation_start,
|
|
782
|
-
choice(
|
|
783
|
-
alias(token.immediate(prec(2, /[\p{L}_][\p{L}_\p{Nd}]*/u)), $.identifier),
|
|
784
|
-
seq(token.immediate('{'), $.expression, '}')
|
|
785
|
-
)
|
|
786
|
-
),
|
|
786
|
+
seq($._multi_dollar_interpolation_start, choice($._template_name, seq(token.immediate('{'), $.expression, '}'))),
|
|
787
787
|
|
|
788
788
|
character_literal: ($) => seq("'", choice(token.immediate(prec(1, /[^'\\\r\n]/)), $.escape_sequence), "'"),
|
|
789
789
|
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
package/tree-sitter-kotlin.wasm
CHANGED
|
Binary file
|