@willbooster/tree-sitter-python 11.0.0 → 13.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 +9 -8
- package/grammar.js +2 -3
- package/package.json +17 -20
- package/tree-sitter-python.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/WillBooster/tree-sitter-python/actions/workflows/test.yml)
|
|
6
6
|
[](https://github.com/WillBooster/tree-sitter-python/actions/workflows/test-rust.yml)
|
|
7
7
|
[](https://github.com/semantic-release/semantic-release)
|
|
8
|
-
[](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
|
|
9
9
|
[](https://crates.io/crates/willbooster-tree-sitter-python)
|
|
10
10
|
|
|
11
11
|
Python grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
|
|
@@ -15,19 +15,20 @@ to its authors and contributors. This is not an official release of that project
|
|
|
15
15
|
This fork builds on upstream v0.25.0 with grammar, scanner, and highlighting fixes, including Python 3.15
|
|
16
16
|
unpacking comprehensions. It ships a compact parser generated by the parser generator of
|
|
17
17
|
[WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter). The parser carries that fork's own ABI number, so
|
|
18
|
-
it loads only with the WillBooster runtime (`willbooster-tree-sitter` or `@willbooster/web-tree-sitter`)
|
|
18
|
+
it loads only with the WillBooster runtime (`willbooster-tree-sitter` or `@willbooster/web-tree-sitter`) 15.0.0 or later within 15.x,
|
|
19
19
|
not with upstream's tree-sitter.
|
|
20
20
|
|
|
21
21
|
## Usage
|
|
22
22
|
|
|
23
23
|
The npm package ships `tree-sitter-python.wasm` for
|
|
24
24
|
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter), which runs in Node.js, Bun,
|
|
25
|
-
browsers, and Cloudflare Workers. The parser requires runtime
|
|
25
|
+
browsers, and Cloudflare Workers. The parser requires runtime 15.0.0 or later within 15.x.
|
|
26
26
|
|
|
27
27
|
In Node.js and Bun, load the grammar from its path:
|
|
28
28
|
|
|
29
29
|
```js
|
|
30
30
|
import { fileURLToPath } from 'node:url';
|
|
31
|
+
|
|
31
32
|
import { Language, Parser } from '@willbooster/web-tree-sitter';
|
|
32
33
|
|
|
33
34
|
await Parser.init();
|
|
@@ -40,9 +41,9 @@ const tree = parser.parse('def main():\n pass\n');
|
|
|
40
41
|
In browsers, load the grammar from its URL. With Vite:
|
|
41
42
|
|
|
42
43
|
```js
|
|
44
|
+
import pythonUrl from '@willbooster/tree-sitter-python/tree-sitter-python.wasm?url';
|
|
43
45
|
import { Language, Parser } from '@willbooster/web-tree-sitter';
|
|
44
46
|
import runtimeUrl from '@willbooster/web-tree-sitter/web-tree-sitter.wasm?url';
|
|
45
|
-
import pythonUrl from '@willbooster/tree-sitter-python/tree-sitter-python.wasm?url';
|
|
46
47
|
|
|
47
48
|
await Parser.init({ locateFile: () => runtimeUrl });
|
|
48
49
|
const parser = new Parser();
|
|
@@ -52,9 +53,9 @@ parser.setLanguage(await Language.load(pythonUrl));
|
|
|
52
53
|
In Cloudflare Workers, which do not allow compiling Wasm at run time, import both `.wasm` files as modules:
|
|
53
54
|
|
|
54
55
|
```js
|
|
56
|
+
import python from '@willbooster/tree-sitter-python/tree-sitter-python.wasm';
|
|
55
57
|
import { Language, Parser } from '@willbooster/web-tree-sitter';
|
|
56
58
|
import runtime from '@willbooster/web-tree-sitter/web-tree-sitter.wasm';
|
|
57
|
-
import python from '@willbooster/tree-sitter-python/tree-sitter-python.wasm';
|
|
58
59
|
|
|
59
60
|
await Parser.init({ wasmModule: runtime });
|
|
60
61
|
const parser = new Parser();
|
|
@@ -67,12 +68,12 @@ Qualified generic bases use `member_type` inside `generic_type`. Generic bases i
|
|
|
67
68
|
|
|
68
69
|
In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-python) and on
|
|
69
70
|
[willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
|
|
70
|
-
fuzzed with. The parser requires runtime
|
|
71
|
+
fuzzed with. The parser requires runtime 15.0.0 or later within 15.x:
|
|
71
72
|
|
|
72
73
|
```toml
|
|
73
74
|
[dependencies]
|
|
74
|
-
tree-sitter = { package = "willbooster-tree-sitter", version = "
|
|
75
|
-
tree-sitter-python = { package = "willbooster-tree-sitter-python", version = "
|
|
75
|
+
tree-sitter = { package = "willbooster-tree-sitter", version = "15.0.0" }
|
|
76
|
+
tree-sitter-python = { package = "willbooster-tree-sitter-python", version = "13" }
|
|
76
77
|
```
|
|
77
78
|
|
|
78
79
|
```rust
|
package/grammar.js
CHANGED
|
@@ -536,10 +536,9 @@ module.exports = grammar({
|
|
|
536
536
|
|
|
537
537
|
decorator: ($) => seq('@', $.expression, sym('_newline')),
|
|
538
538
|
|
|
539
|
-
_suite: ($) =>
|
|
540
|
-
choice(alias($._simple_statements, $.block), seq(sym('_indent'), $.block), alias(sym('_newline'), $.block)),
|
|
539
|
+
_suite: ($) => choice(alias($._simple_statements, $.block), $.block, alias(sym('_newline'), $.block)),
|
|
541
540
|
|
|
542
|
-
block: ($) => seq(repeat($._statement), sym('_dedent')),
|
|
541
|
+
block: ($) => seq(sym('_indent'), repeat($._statement), sym('_dedent')),
|
|
543
542
|
|
|
544
543
|
expression_list: ($) =>
|
|
545
544
|
prec.dynamic(1, prec.right(seq(choice($.expression, $.list_splat), ',', optional($._collection_elements)))),
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-python",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "Python grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
7
7
|
"parsing",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"python",
|
|
9
|
+
"tree-sitter"
|
|
10
10
|
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"author": "WillBooster Inc.",
|
|
11
13
|
"repository": {
|
|
12
14
|
"type": "git",
|
|
13
15
|
"url": "git+https://github.com/WillBooster/tree-sitter-python.git"
|
|
14
16
|
},
|
|
15
|
-
"license": "MIT",
|
|
16
|
-
"author": "WillBooster Inc.",
|
|
17
17
|
"files": [
|
|
18
18
|
"grammar.js",
|
|
19
19
|
"queries/*.scm",
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
"src/node-types.json",
|
|
22
22
|
"*.wasm"
|
|
23
23
|
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"registry": "https://registry.npmjs.org/"
|
|
27
|
+
},
|
|
24
28
|
"scripts": {
|
|
25
29
|
"build-wasm": "script/generate --build-wasm",
|
|
26
30
|
"build/ci": "bun run build-wasm",
|
|
@@ -43,33 +47,26 @@
|
|
|
43
47
|
"devDependencies": {
|
|
44
48
|
"@tsconfig/bun": "1.0.11",
|
|
45
49
|
"@types/bun": "1.4.3",
|
|
46
|
-
"@vitest/browser-playwright": "5.0.
|
|
47
|
-
"@willbooster/
|
|
48
|
-
"@willbooster/
|
|
49
|
-
"@willbooster/
|
|
50
|
-
"@willbooster/web-tree-sitter": "14.0.0",
|
|
50
|
+
"@vitest/browser-playwright": "5.0.5",
|
|
51
|
+
"@willbooster/oxlint-config": "1.4.9",
|
|
52
|
+
"@willbooster/wb": "22.29.3",
|
|
53
|
+
"@willbooster/web-tree-sitter": "15.0.0",
|
|
51
54
|
"conventional-changelog-conventionalcommits": "10.4.1",
|
|
52
55
|
"lefthook": "2.2.2",
|
|
53
|
-
"oxfmt": "0.73.0",
|
|
54
56
|
"oxlint": "1.88.0",
|
|
55
57
|
"oxlint-tsgolint": "7.0.2004",
|
|
56
|
-
"playwright": "1.64.
|
|
58
|
+
"playwright": "1.64.1",
|
|
57
59
|
"semantic-release": "25.0.9",
|
|
58
|
-
"sort-package-json": "4.0.0",
|
|
59
60
|
"vite": "8.3.4",
|
|
60
|
-
"vitest": "5.0.
|
|
61
|
-
"wrangler": "4.
|
|
61
|
+
"vitest": "5.0.5",
|
|
62
|
+
"wrangler": "4.151.1"
|
|
62
63
|
},
|
|
63
64
|
"peerDependencies": {
|
|
64
|
-
"@willbooster/web-tree-sitter": "^
|
|
65
|
+
"@willbooster/web-tree-sitter": "^15.0.0"
|
|
65
66
|
},
|
|
66
67
|
"peerDependenciesMeta": {
|
|
67
68
|
"@willbooster/web-tree-sitter": {
|
|
68
69
|
"optional": true
|
|
69
70
|
}
|
|
70
|
-
},
|
|
71
|
-
"publishConfig": {
|
|
72
|
-
"access": "public",
|
|
73
|
-
"registry": "https://registry.npmjs.org/"
|
|
74
71
|
}
|
|
75
72
|
}
|
package/tree-sitter-python.wasm
CHANGED
|
Binary file
|