@willbooster/tree-sitter-python 7.0.0 → 9.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 +6 -6
- package/grammar.js +6 -4
- package/package.json +8 -8
- package/queries/highlights.scm +0 -5
- package/src/node-types.json +5 -9
- 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,14 +15,14 @@ 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`) 10.0.2 or later within 10.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 10.0.2 or later within 10.x.
|
|
26
26
|
|
|
27
27
|
In Node.js and Bun, load the grammar from its path:
|
|
28
28
|
|
|
@@ -67,12 +67,12 @@ Qualified generic bases use `member_type` inside `generic_type`. Generic bases i
|
|
|
67
67
|
|
|
68
68
|
In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-python) and on
|
|
69
69
|
[willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
|
|
70
|
-
fuzzed with. The parser requires runtime
|
|
70
|
+
fuzzed with. The parser requires runtime 10.0.2 or later within 10.x:
|
|
71
71
|
|
|
72
72
|
```toml
|
|
73
73
|
[dependencies]
|
|
74
|
-
tree-sitter = { package = "willbooster-tree-sitter", version = "
|
|
75
|
-
tree-sitter-python = { package = "willbooster-tree-sitter-python", version = "
|
|
74
|
+
tree-sitter = { package = "willbooster-tree-sitter", version = "10.0.2" }
|
|
75
|
+
tree-sitter-python = { package = "willbooster-tree-sitter-python", version = "9" }
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
```rust
|
package/grammar.js
CHANGED
|
@@ -54,7 +54,6 @@ module.exports = grammar({
|
|
|
54
54
|
[$.tuple, $.tuple_pattern],
|
|
55
55
|
[$.list, $.list_pattern],
|
|
56
56
|
[$.with_item, $.tuple],
|
|
57
|
-
[$.named_expression, $.as_pattern],
|
|
58
57
|
[$.print_statement, $.primary_expression],
|
|
59
58
|
[$.match_statement, $.primary_expression],
|
|
60
59
|
],
|
|
@@ -339,7 +338,10 @@ module.exports = grammar({
|
|
|
339
338
|
optional(token(prec(1, '*'))),
|
|
340
339
|
optional(
|
|
341
340
|
choice(
|
|
342
|
-
seq(
|
|
341
|
+
seq(
|
|
342
|
+
field('value', $.expression),
|
|
343
|
+
optional(seq('as', field('alias', choice($.identifier, $.keyword_identifier))))
|
|
344
|
+
),
|
|
343
345
|
commaSep1(field('value', $.expression))
|
|
344
346
|
)
|
|
345
347
|
),
|
|
@@ -354,7 +356,7 @@ module.exports = grammar({
|
|
|
354
356
|
with_clause: ($) =>
|
|
355
357
|
choice(seq(commaSep1($.with_item), optional(',')), seq('(', commaSep1($.with_item), optional(','), ')')),
|
|
356
358
|
|
|
357
|
-
with_item: ($) => prec.dynamic(1,
|
|
359
|
+
with_item: ($) => prec.dynamic(1, field('value', choice($.expression, $.as_pattern))),
|
|
358
360
|
|
|
359
361
|
function_definition: ($) =>
|
|
360
362
|
seq(
|
|
@@ -643,7 +645,7 @@ module.exports = grammar({
|
|
|
643
645
|
|
|
644
646
|
_expression_within_for_in_clause: ($) => choice($.expression, alias($.lambda_within_for_in_clause, $.lambda)),
|
|
645
647
|
|
|
646
|
-
expression: ($) => choice($._expression_without_named_expression, $.named_expression
|
|
648
|
+
expression: ($) => choice($._expression_without_named_expression, $.named_expression),
|
|
647
649
|
|
|
648
650
|
_expression_without_named_expression: ($) =>
|
|
649
651
|
choice(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-python",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Python grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@tsconfig/bun": "1.0.11",
|
|
45
|
-
"@types/bun": "1.4.
|
|
45
|
+
"@types/bun": "1.4.3",
|
|
46
46
|
"@vitest/browser-playwright": "5.0.3",
|
|
47
47
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
48
48
|
"@willbooster/oxlint-config": "1.4.8",
|
|
49
|
-
"@willbooster/wb": "22.26.
|
|
50
|
-
"@willbooster/web-tree-sitter": "
|
|
49
|
+
"@willbooster/wb": "22.26.2",
|
|
50
|
+
"@willbooster/web-tree-sitter": "10.0.2",
|
|
51
51
|
"conventional-changelog-conventionalcommits": "10.4.1",
|
|
52
|
-
"lefthook": "2.2.
|
|
53
|
-
"oxfmt": "0.
|
|
54
|
-
"oxlint": "1.
|
|
52
|
+
"lefthook": "2.2.2",
|
|
53
|
+
"oxfmt": "0.73.0",
|
|
54
|
+
"oxlint": "1.88.0",
|
|
55
55
|
"oxlint-tsgolint": "7.0.2004",
|
|
56
56
|
"playwright": "1.64.0",
|
|
57
57
|
"semantic-release": "25.0.9",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"wrangler": "4.149.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@willbooster/web-tree-sitter": "^
|
|
64
|
+
"@willbooster/web-tree-sitter": "^10.0.2"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@willbooster/web-tree-sitter": {
|
package/queries/highlights.scm
CHANGED
|
@@ -50,11 +50,6 @@
|
|
|
50
50
|
(identifier) @constructor
|
|
51
51
|
(tuple (identifier) @constructor)
|
|
52
52
|
(parenthesized_expression (identifier) @constructor)
|
|
53
|
-
(as_pattern [
|
|
54
|
-
(identifier) @constructor
|
|
55
|
-
(tuple (identifier) @constructor)
|
|
56
|
-
(parenthesized_expression (identifier) @constructor)
|
|
57
|
-
])
|
|
58
53
|
])
|
|
59
54
|
(#match? @constructor "^[0-9_]*[A-Z][A-Z_0-9]*$"))
|
|
60
55
|
|
package/src/node-types.json
CHANGED
|
@@ -3,10 +3,6 @@
|
|
|
3
3
|
"type": "expression",
|
|
4
4
|
"named": true,
|
|
5
5
|
"subtypes": [
|
|
6
|
-
{
|
|
7
|
-
"type": "as_pattern",
|
|
8
|
-
"named": true
|
|
9
|
-
},
|
|
10
6
|
{
|
|
11
7
|
"type": "boolean_operator",
|
|
12
8
|
"named": true
|
|
@@ -306,10 +302,6 @@
|
|
|
306
302
|
"multiple": false,
|
|
307
303
|
"required": true,
|
|
308
304
|
"types": [
|
|
309
|
-
{
|
|
310
|
-
"type": "as_pattern",
|
|
311
|
-
"named": true
|
|
312
|
-
},
|
|
313
305
|
{
|
|
314
306
|
"type": "boolean_operator",
|
|
315
307
|
"named": true
|
|
@@ -1643,7 +1635,7 @@
|
|
|
1643
1635
|
"required": false,
|
|
1644
1636
|
"types": [
|
|
1645
1637
|
{
|
|
1646
|
-
"type": "
|
|
1638
|
+
"type": "identifier",
|
|
1647
1639
|
"named": true
|
|
1648
1640
|
}
|
|
1649
1641
|
]
|
|
@@ -3603,6 +3595,10 @@
|
|
|
3603
3595
|
"multiple": false,
|
|
3604
3596
|
"required": true,
|
|
3605
3597
|
"types": [
|
|
3598
|
+
{
|
|
3599
|
+
"type": "as_pattern",
|
|
3600
|
+
"named": true
|
|
3601
|
+
},
|
|
3606
3602
|
{
|
|
3607
3603
|
"type": "expression",
|
|
3608
3604
|
"named": true
|
package/tree-sitter-python.wasm
CHANGED
|
Binary file
|