@willbooster/tree-sitter-kotlin 1.5.4 → 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 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,8 +401,9 @@ module.exports = grammar({
370
401
  statement: ($) =>
371
402
  choice($.declaration, $.assignment, $.for_statement, $.while_statement, $.do_while_statement, $.expression),
372
403
 
373
- // An annotation before a declaration may also read as an annotated expression statement (`@A (b)`), and both
374
- // readings parse, so the one in which it modifies the declaration takes dynamic precedence, as in Kotlin.
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.
375
407
  modifiers: ($) =>
376
408
  prec.dynamic(
377
409
  1,
@@ -392,22 +424,17 @@ module.exports = grammar({
392
424
  )
393
425
  ),
394
426
 
395
- // A modifier keyword that `_reserved_identifier` also accepts as a name makes `@A\nsealed interface B` parse as
396
- // an infix call as well, since `interface` lexes as an identifier where no keyword is valid, so the modifier
397
- // reading takes dynamic precedence. The name takes none: it would outweigh the modifiers again wherever a
398
- // reading has more names, such as `get` calls in a class body misread as a trailing lambda.
399
- class_modifier: () => prec.dynamic(1, choice('enum', 'sealed', 'annotation', 'data', 'inner', 'value')),
427
+ class_modifier: () => choice('enum', 'sealed', 'annotation', 'data', 'inner', 'value'),
400
428
 
401
- function_modifier: () =>
402
- prec.dynamic(1, prec.right(choice('tailrec', 'operator', 'infix', 'inline', 'external', 'suspend'))),
429
+ function_modifier: () => prec.right(choice('tailrec', 'operator', 'infix', 'inline', 'external', 'suspend')),
403
430
 
404
- property_modifier: () => prec.dynamic(1, 'const'),
431
+ property_modifier: () => 'const',
405
432
 
406
- visibility_modifier: () => prec.dynamic(1, choice('public', 'private', 'protected', 'internal')),
433
+ visibility_modifier: () => choice('public', 'private', 'protected', 'internal'),
407
434
 
408
- inheritance_modifier: () => prec.dynamic(1, choice('abstract', 'final', 'open')),
435
+ inheritance_modifier: () => choice('abstract', 'final', 'open'),
409
436
 
410
- member_modifier: () => prec.dynamic(1, choice('override', 'lateinit')),
437
+ member_modifier: () => choice('override', 'lateinit'),
411
438
 
412
439
  parameter_modifiers: ($) => repeat1(choice($.annotation, $.parameter_modifier)),
413
440
 
@@ -415,7 +442,7 @@ module.exports = grammar({
415
442
 
416
443
  reification_modifier: () => 'reified',
417
444
 
418
- platform_modifier: () => prec.dynamic(1, choice('expect', 'actual')),
445
+ platform_modifier: () => choice('expect', 'actual'),
419
446
 
420
447
  type_modifiers: ($) => prec.right(repeat1(choice($.annotation, 'suspend'))),
421
448
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-kotlin",
3
- "version": "1.5.4",
3
+ "version": "1.5.5",
4
4
  "description": "Kotlin grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
Binary file
package/tree-sitter.json CHANGED
@@ -13,7 +13,7 @@
13
13
  }
14
14
  ],
15
15
  "metadata": {
16
- "version": "1.5.4",
16
+ "version": "1.5.5",
17
17
  "license": "MIT",
18
18
  "description": "Kotlin grammar for tree-sitter",
19
19
  "authors": [