@willbooster/tree-sitter-kotlin 1.4.0 → 1.4.1
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 +50 -26
- package/package.json +1 -1
- package/tree-sitter-kotlin.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -49,6 +49,8 @@ module.exports = grammar({
|
|
|
49
49
|
[$.parameter_modifiers, $.type_modifiers],
|
|
50
50
|
[$.function_modifier, $.type_modifiers],
|
|
51
51
|
[$.function_modifier, $._reserved_identifier],
|
|
52
|
+
[$.function_modifier, $.type_modifiers, $._reserved_identifier],
|
|
53
|
+
[$.type_modifiers, $._reserved_identifier],
|
|
52
54
|
[$.variable_declaration, $.type_modifiers],
|
|
53
55
|
[$.variable_declaration, $.type_modifiers, $.modifiers, $.annotated_expression],
|
|
54
56
|
[$.variable_declaration, $.type_modifiers, $.annotated_expression],
|
|
@@ -61,6 +63,9 @@ module.exports = grammar({
|
|
|
61
63
|
[$.class_modifier, $._reserved_identifier],
|
|
62
64
|
[$.platform_modifier, $._reserved_identifier],
|
|
63
65
|
[$.property_modifier, $._reserved_identifier],
|
|
66
|
+
[$.inheritance_modifier, $._reserved_identifier],
|
|
67
|
+
[$.visibility_modifier, $._reserved_identifier],
|
|
68
|
+
[$.member_modifier, $._reserved_identifier],
|
|
64
69
|
|
|
65
70
|
[$.explicit_delegation, $.expression],
|
|
66
71
|
[$.qualified_identifier],
|
|
@@ -87,6 +92,8 @@ module.exports = grammar({
|
|
|
87
92
|
'set',
|
|
88
93
|
// used to check if we can parse a comment
|
|
89
94
|
'$',
|
|
95
|
+
// used to check if a modifier alone on its line belongs to a declaration on the next line
|
|
96
|
+
'val',
|
|
90
97
|
],
|
|
91
98
|
|
|
92
99
|
inline: ($) => [$._statements, $._identifier, $._control_structure_body],
|
|
@@ -371,17 +378,22 @@ module.exports = grammar({
|
|
|
371
378
|
)
|
|
372
379
|
),
|
|
373
380
|
|
|
374
|
-
|
|
381
|
+
// A modifier keyword that `_reserved_identifier` also accepts as a name makes `@A\nsealed interface B` parse as
|
|
382
|
+
// an infix call as well, since `interface` lexes as an identifier where no keyword is valid, so the modifier
|
|
383
|
+
// reading takes dynamic precedence. The name takes none: it would outweigh the modifiers again wherever a
|
|
384
|
+
// reading has more names, such as `get` calls in a class body misread as a trailing lambda.
|
|
385
|
+
class_modifier: () => prec.dynamic(1, choice('enum', 'sealed', 'annotation', 'data', 'inner', 'value')),
|
|
375
386
|
|
|
376
|
-
function_modifier: () =>
|
|
387
|
+
function_modifier: () =>
|
|
388
|
+
prec.dynamic(1, prec.right(choice('tailrec', 'operator', 'infix', 'inline', 'external', 'suspend'))),
|
|
377
389
|
|
|
378
|
-
property_modifier: () => 'const',
|
|
390
|
+
property_modifier: () => prec.dynamic(1, 'const'),
|
|
379
391
|
|
|
380
|
-
visibility_modifier: () => choice('public', 'private', 'protected', 'internal'),
|
|
392
|
+
visibility_modifier: () => prec.dynamic(1, choice('public', 'private', 'protected', 'internal')),
|
|
381
393
|
|
|
382
|
-
inheritance_modifier: () => choice('abstract', 'final', 'open'),
|
|
394
|
+
inheritance_modifier: () => prec.dynamic(1, choice('abstract', 'final', 'open')),
|
|
383
395
|
|
|
384
|
-
member_modifier: () => choice('override', 'lateinit'),
|
|
396
|
+
member_modifier: () => prec.dynamic(1, choice('override', 'lateinit')),
|
|
385
397
|
|
|
386
398
|
parameter_modifiers: ($) => repeat1(choice($.annotation, $.parameter_modifier)),
|
|
387
399
|
|
|
@@ -389,7 +401,7 @@ module.exports = grammar({
|
|
|
389
401
|
|
|
390
402
|
reification_modifier: () => 'reified',
|
|
391
403
|
|
|
392
|
-
platform_modifier: () => choice('expect', 'actual'),
|
|
404
|
+
platform_modifier: () => prec.dynamic(1, choice('expect', 'actual')),
|
|
393
405
|
|
|
394
406
|
type_modifiers: ($) => prec.right(repeat1(choice($.annotation, 'suspend'))),
|
|
395
407
|
|
|
@@ -746,25 +758,37 @@ module.exports = grammar({
|
|
|
746
758
|
identifier: () => token(choice(/[\p{L}_][\p{L}_\p{Nd}]*/u, /`[^\r\n`]+`/)),
|
|
747
759
|
|
|
748
760
|
_reserved_identifier: ($) =>
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
761
|
+
alias(
|
|
762
|
+
choice(
|
|
763
|
+
'abstract',
|
|
764
|
+
'actual',
|
|
765
|
+
'annotation',
|
|
766
|
+
'const',
|
|
767
|
+
'constructor',
|
|
768
|
+
'data',
|
|
769
|
+
'enum',
|
|
770
|
+
'expect',
|
|
771
|
+
'external',
|
|
772
|
+
'final',
|
|
773
|
+
'get',
|
|
774
|
+
'infix',
|
|
775
|
+
'inline',
|
|
776
|
+
'inner',
|
|
777
|
+
'internal',
|
|
778
|
+
'lateinit',
|
|
779
|
+
'open',
|
|
780
|
+
'operator',
|
|
781
|
+
'override',
|
|
782
|
+
'private',
|
|
783
|
+
'protected',
|
|
784
|
+
'public',
|
|
785
|
+
'sealed',
|
|
786
|
+
'set',
|
|
787
|
+
'suspend',
|
|
788
|
+
'tailrec',
|
|
789
|
+
'value'
|
|
790
|
+
),
|
|
791
|
+
$.identifier
|
|
768
792
|
),
|
|
769
793
|
|
|
770
794
|
shebang: () => /#!.*/,
|
package/package.json
CHANGED
package/tree-sitter-kotlin.wasm
CHANGED
|
Binary file
|