@willbooster/tree-sitter-kotlin 1.5.3 → 1.5.5
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 +56 -24
- package/package.json +1 -1
- package/tree-sitter-kotlin.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -122,6 +122,37 @@ module.exports = grammar({
|
|
|
122
122
|
|
|
123
123
|
word: ($) => $.identifier,
|
|
124
124
|
|
|
125
|
+
// Kotlin's hard keywords are never names. `true`, `false`, `null`, and `typeof` are hard keywords too, but this
|
|
126
|
+
// grammar has no tokens for them, so they still parse as names.
|
|
127
|
+
reserved: {
|
|
128
|
+
global: () => [
|
|
129
|
+
'as',
|
|
130
|
+
'break',
|
|
131
|
+
'class',
|
|
132
|
+
'continue',
|
|
133
|
+
'do',
|
|
134
|
+
'else',
|
|
135
|
+
'for',
|
|
136
|
+
'fun',
|
|
137
|
+
'if',
|
|
138
|
+
'in',
|
|
139
|
+
'interface',
|
|
140
|
+
'is',
|
|
141
|
+
'object',
|
|
142
|
+
'package',
|
|
143
|
+
'return',
|
|
144
|
+
'super',
|
|
145
|
+
'this',
|
|
146
|
+
'throw',
|
|
147
|
+
'try',
|
|
148
|
+
'typealias',
|
|
149
|
+
'val',
|
|
150
|
+
'var',
|
|
151
|
+
'when',
|
|
152
|
+
'while',
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
|
|
125
156
|
rules: {
|
|
126
157
|
source_file: ($) =>
|
|
127
158
|
seq(
|
|
@@ -370,39 +401,40 @@ module.exports = grammar({
|
|
|
370
401
|
statement: ($) =>
|
|
371
402
|
choice($.declaration, $.assignment, $.for_statement, $.while_statement, $.do_while_statement, $.expression),
|
|
372
403
|
|
|
404
|
+
// Modifiers before a declaration may also read as an annotated expression statement (`@A (b)`) or, for modifier
|
|
405
|
+
// keywords that `_reserved_identifier` accepts, as names, and both readings parse, so the one in which they modify
|
|
406
|
+
// the declaration takes dynamic precedence, as in Kotlin.
|
|
373
407
|
modifiers: ($) =>
|
|
374
|
-
prec.
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
408
|
+
prec.dynamic(
|
|
409
|
+
1,
|
|
410
|
+
prec.right(
|
|
411
|
+
repeat1(
|
|
412
|
+
choice(
|
|
413
|
+
$.annotation,
|
|
414
|
+
$.class_modifier,
|
|
415
|
+
$.member_modifier,
|
|
416
|
+
$.function_modifier,
|
|
417
|
+
$.property_modifier,
|
|
418
|
+
$.visibility_modifier,
|
|
419
|
+
$.inheritance_modifier,
|
|
420
|
+
$.parameter_modifier,
|
|
421
|
+
$.platform_modifier
|
|
422
|
+
)
|
|
386
423
|
)
|
|
387
424
|
)
|
|
388
425
|
),
|
|
389
426
|
|
|
390
|
-
|
|
391
|
-
// an infix call as well, since `interface` lexes as an identifier where no keyword is valid, so the modifier
|
|
392
|
-
// reading takes dynamic precedence. The name takes none: it would outweigh the modifiers again wherever a
|
|
393
|
-
// reading has more names, such as `get` calls in a class body misread as a trailing lambda.
|
|
394
|
-
class_modifier: () => prec.dynamic(1, choice('enum', 'sealed', 'annotation', 'data', 'inner', 'value')),
|
|
427
|
+
class_modifier: () => choice('enum', 'sealed', 'annotation', 'data', 'inner', 'value'),
|
|
395
428
|
|
|
396
|
-
function_modifier: () =>
|
|
397
|
-
prec.dynamic(1, prec.right(choice('tailrec', 'operator', 'infix', 'inline', 'external', 'suspend'))),
|
|
429
|
+
function_modifier: () => prec.right(choice('tailrec', 'operator', 'infix', 'inline', 'external', 'suspend')),
|
|
398
430
|
|
|
399
|
-
property_modifier: () =>
|
|
431
|
+
property_modifier: () => 'const',
|
|
400
432
|
|
|
401
|
-
visibility_modifier: () =>
|
|
433
|
+
visibility_modifier: () => choice('public', 'private', 'protected', 'internal'),
|
|
402
434
|
|
|
403
|
-
inheritance_modifier: () =>
|
|
435
|
+
inheritance_modifier: () => choice('abstract', 'final', 'open'),
|
|
404
436
|
|
|
405
|
-
member_modifier: () =>
|
|
437
|
+
member_modifier: () => choice('override', 'lateinit'),
|
|
406
438
|
|
|
407
439
|
parameter_modifiers: ($) => repeat1(choice($.annotation, $.parameter_modifier)),
|
|
408
440
|
|
|
@@ -410,7 +442,7 @@ module.exports = grammar({
|
|
|
410
442
|
|
|
411
443
|
reification_modifier: () => 'reified',
|
|
412
444
|
|
|
413
|
-
platform_modifier: () =>
|
|
445
|
+
platform_modifier: () => choice('expect', 'actual'),
|
|
414
446
|
|
|
415
447
|
type_modifiers: ($) => prec.right(repeat1(choice($.annotation, 'suspend'))),
|
|
416
448
|
|
package/package.json
CHANGED
package/tree-sitter-kotlin.wasm
CHANGED
|
Binary file
|