@willbooster/tree-sitter-kotlin 1.5.8 → 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 +9 -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
|
@@ -769,23 +769,21 @@ module.exports = grammar({
|
|
|
769
769
|
)
|
|
770
770
|
),
|
|
771
771
|
|
|
772
|
-
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: ($) =>
|
|
773
778
|
choice(
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
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)
|
|
777
781
|
),
|
|
778
782
|
|
|
779
783
|
// In a string prefixed with n dollars (Kotlin 2.1), exactly n dollars start an interpolation; the scanner
|
|
780
784
|
// returns them as one token only where they do.
|
|
781
785
|
_multi_dollar_interpolation: ($) =>
|
|
782
|
-
seq(
|
|
783
|
-
$._multi_dollar_interpolation_start,
|
|
784
|
-
choice(
|
|
785
|
-
alias(token.immediate(prec(2, /[\p{L}_][\p{L}_\p{Nd}]*/u)), $.identifier),
|
|
786
|
-
seq(token.immediate('{'), $.expression, '}')
|
|
787
|
-
)
|
|
788
|
-
),
|
|
786
|
+
seq($._multi_dollar_interpolation_start, choice($._template_name, seq(token.immediate('{'), $.expression, '}'))),
|
|
789
787
|
|
|
790
788
|
character_literal: ($) => seq("'", choice(token.immediate(prec(1, /[^'\\\r\n]/)), $.escape_sequence), "'"),
|
|
791
789
|
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
package/tree-sitter-kotlin.wasm
CHANGED
|
Binary file
|