@willbooster/tree-sitter-kotlin 2.0.0 → 4.0.0
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/README.md +11 -5
- package/grammar.js +11 -2
- package/package.json +6 -5
- package/tree-sitter-kotlin.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ This fork fixes parsing bugs and raises conformance with the Kotlin grammar.
|
|
|
18
18
|
|
|
19
19
|
The npm package ships `tree-sitter-kotlin.wasm` for
|
|
20
20
|
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter), which runs in Node.js, Bun,
|
|
21
|
-
browsers, and Cloudflare Workers.
|
|
21
|
+
browsers, and Cloudflare Workers. The compact ABI 16 parser requires runtime 1.4.2 or later.
|
|
22
22
|
|
|
23
23
|
In Node.js and Bun:
|
|
24
24
|
|
|
@@ -62,13 +62,12 @@ The package also ships the node types in `src/node-types.json`.
|
|
|
62
62
|
|
|
63
63
|
In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-kotlin) and on
|
|
64
64
|
[willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
|
|
65
|
-
fuzzed with
|
|
66
|
-
malformed input):
|
|
65
|
+
fuzzed with. The compact ABI 16 parser requires runtime 1.4.2 or later:
|
|
67
66
|
|
|
68
67
|
```toml
|
|
69
68
|
[dependencies]
|
|
70
|
-
tree-sitter = { package = "willbooster-tree-sitter", version = "1" }
|
|
71
|
-
tree-sitter-kotlin = { package = "willbooster-tree-sitter-kotlin", version = "
|
|
69
|
+
tree-sitter = { package = "willbooster-tree-sitter", version = "1.4.2" }
|
|
70
|
+
tree-sitter-kotlin = { package = "willbooster-tree-sitter-kotlin", version = "4" }
|
|
72
71
|
```
|
|
73
72
|
|
|
74
73
|
```rust
|
|
@@ -93,6 +92,13 @@ locked in `Cargo.lock` (`script/tree-sitter`), whose generator and runtime have
|
|
|
93
92
|
`script/fork-cli` downloads that CLI into `.tmp/` from its GitHub Release on first use, or builds it with `cargo` when
|
|
94
93
|
the download fails or the release has no binary that runs here.
|
|
95
94
|
|
|
95
|
+
`bun run generate` records a fresh ABI 16 generation profile from the applicable `test/corpus` cases and Git-tracked
|
|
96
|
+
files in `examples/`, then generates compact parser tables. The parser also embeds metadata from `tree-sitter.json`. After changing a grammar,
|
|
97
|
+
`tree-sitter.json`, a corpus case, or a tracked example,
|
|
98
|
+
regenerate and commit `src/`. Stage added or removed examples with `git add -A examples` before generation so the profile uses the intended file list.
|
|
99
|
+
Profiles in `.tmp/generation-profiles/` are temporary and must not be committed. `bun run build-wasm`, `bun run build/ci`,
|
|
100
|
+
and the release build regenerate the parsers before compiling them.
|
|
101
|
+
|
|
96
102
|
`bun run test` runs:
|
|
97
103
|
|
|
98
104
|
- the corpus in `test/corpus`, with the native build and with the Wasm build (the first run downloads the WASI SDK);
|
package/grammar.js
CHANGED
|
@@ -137,6 +137,7 @@ module.exports = grammar({
|
|
|
137
137
|
$._infix_position,
|
|
138
138
|
$._companion_name_position,
|
|
139
139
|
$._try_continuation_position,
|
|
140
|
+
$._infix_get_identifier,
|
|
140
141
|
],
|
|
141
142
|
|
|
142
143
|
inline: ($) => [$._statements, $._identifier, $._control_structure_body],
|
|
@@ -709,7 +710,15 @@ module.exports = grammar({
|
|
|
709
710
|
range_expression: ($) => prec.left(PREC.RANGE, seq($.expression, choice('..', '..<'), $.expression)),
|
|
710
711
|
|
|
711
712
|
infix_expression: ($) =>
|
|
712
|
-
prec.left(
|
|
713
|
+
prec.left(
|
|
714
|
+
PREC.INFIX,
|
|
715
|
+
seq(
|
|
716
|
+
$.expression,
|
|
717
|
+
optional($._infix_position),
|
|
718
|
+
choice($.identifier, alias($._infix_get_identifier, $.identifier)),
|
|
719
|
+
$.expression
|
|
720
|
+
)
|
|
721
|
+
),
|
|
713
722
|
|
|
714
723
|
// Right-associative so that a trailing lambda after arguments belongs to the same call (`f(x) { … }`), as in
|
|
715
724
|
// Kotlin, instead of calling the result of `f(x)`.
|
|
@@ -964,7 +973,7 @@ module.exports = grammar({
|
|
|
964
973
|
|
|
965
974
|
label: () => token(/[a-zA-Z_][a-zA-Z_0-9]*@/),
|
|
966
975
|
|
|
967
|
-
_identifier: ($) => choice($.identifier, $._reserved_identifier),
|
|
976
|
+
_identifier: ($) => choice($.identifier, $._reserved_identifier, alias($._infix_get_identifier, $.identifier)),
|
|
968
977
|
|
|
969
978
|
identifier: () => token(choice(/[\p{L}_][\p{L}_\p{Nd}]*/u, /`[^\r\n`]+`/)),
|
|
970
979
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-kotlin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Kotlin grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -21,10 +21,11 @@
|
|
|
21
21
|
"*.wasm"
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
|
-
"build-wasm": "script/
|
|
25
|
-
"build/ci": "
|
|
24
|
+
"build-wasm": "script/generate --build-wasm",
|
|
25
|
+
"build/ci": "bun run build-wasm",
|
|
26
26
|
"cleanup": "bun wb lint --fix --format",
|
|
27
27
|
"format": "bun wb lint --format",
|
|
28
|
+
"generate": "script/generate",
|
|
28
29
|
"lint": "bun wb lint",
|
|
29
30
|
"lint-fix": "bun wb lint --fix",
|
|
30
31
|
"prepare": "(bun lefthook install || true) && (test ! -f .lefthook/normalize-bun-lockfile.sh || bash .lefthook/normalize-bun-lockfile.sh)",
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
46
47
|
"@willbooster/oxlint-config": "1.4.8",
|
|
47
48
|
"@willbooster/wb": "22.18.0",
|
|
48
|
-
"@willbooster/web-tree-sitter": "1.
|
|
49
|
+
"@willbooster/web-tree-sitter": "1.4.2",
|
|
49
50
|
"conventional-changelog-conventionalcommits": "10.4.0",
|
|
50
51
|
"lefthook": "2.1.14",
|
|
51
52
|
"oxfmt": "0.70.0",
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
"wrangler": "4.141.0"
|
|
62
63
|
},
|
|
63
64
|
"peerDependencies": {
|
|
64
|
-
"@willbooster/web-tree-sitter": "^1.
|
|
65
|
+
"@willbooster/web-tree-sitter": "^1.4.2"
|
|
65
66
|
},
|
|
66
67
|
"peerDependenciesMeta": {
|
|
67
68
|
"@willbooster/web-tree-sitter": {
|
package/tree-sitter-kotlin.wasm
CHANGED
|
Binary file
|