@willbooster/tree-sitter-python 9.0.0 → 11.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 CHANGED
@@ -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`) 10.0.2 or later within 10.x,
18
+ it loads only with the WillBooster runtime (`willbooster-tree-sitter` or `@willbooster/web-tree-sitter`) 14.0.0 or later within 14.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 10.0.2 or later within 10.x.
25
+ browsers, and Cloudflare Workers. The parser requires runtime 14.0.0 or later within 14.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 10.0.2 or later within 10.x:
70
+ fuzzed with. The parser requires runtime 14.0.0 or later within 14.x:
71
71
 
72
72
  ```toml
73
73
  [dependencies]
74
- tree-sitter = { package = "willbooster-tree-sitter", version = "10.0.2" }
75
- tree-sitter-python = { package = "willbooster-tree-sitter-python", version = "9" }
74
+ tree-sitter = { package = "willbooster-tree-sitter", version = "14.0.0" }
75
+ tree-sitter-python = { package = "willbooster-tree-sitter-python", version = "11" }
76
76
  ```
77
77
 
78
78
  ```rust
package/grammar.js CHANGED
@@ -40,7 +40,7 @@ const SEMICOLON = ';';
40
40
  module.exports = grammar({
41
41
  name: 'python',
42
42
 
43
- extras: ($) => [$.comment, /[\s\f\uFEFF\u2060\u200B]|\r?\n/, $.line_continuation],
43
+ extras: ($) => [$.comment, /[ \t\f\uFEFF\u2060\u200B]/, sym('line_continuation'), sym('_line_break')],
44
44
 
45
45
  conflicts: ($) => [
46
46
  [$.default_type_parameter, $._default_type_primary, $.primary_expression],
@@ -76,11 +76,6 @@ module.exports = grammar({
76
76
  sym('escape_interpolation'),
77
77
  sym('string_end'),
78
78
 
79
- // Mark comments as external tokens so that the external scanner is always
80
- // invoked, even if no external token is expected. This allows for better
81
- // error recovery, because the external scanner can maintain the overall
82
- // structure by returning dedent tokens whenever a dedent occurs, even
83
- // if no dedent is expected.
84
79
  sym('comment'),
85
80
 
86
81
  '(',
@@ -91,6 +86,8 @@ module.exports = grammar({
91
86
  '}',
92
87
  'except',
93
88
  sym('_format_specifier_content'),
89
+ sym('_line_break'),
90
+ sym('line_continuation'),
94
91
  ],
95
92
 
96
93
  inline: ($) => [
@@ -962,7 +959,7 @@ module.exports = grammar({
962
959
  /U[a-fA-F\d]{8}/,
963
960
  /x[a-fA-F\d]{2}/,
964
961
  /\d{1,3}/,
965
- /\r?\n/,
962
+ /\r\n?|\n/,
966
963
  /['"abfrntv\\]/,
967
964
  /N\{[^}]+\}/
968
965
  )
@@ -1022,9 +1019,7 @@ module.exports = grammar({
1022
1019
 
1023
1020
  await: ($) => prec(PREC.unary, seq('await', $.primary_expression)),
1024
1021
 
1025
- comment: () => token(seq('#', /.*/)),
1026
-
1027
- line_continuation: () => token(seq('\\', choice(seq(optional('\r'), '\n'), '\0'))),
1022
+ comment: () => token(seq('#', /[^\r\n]*/)),
1028
1023
 
1029
1024
  positional_separator: () => '/',
1030
1025
  keyword_separator: () => '*',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-python",
3
- "version": "9.0.0",
3
+ "version": "11.0.0",
4
4
  "description": "Python grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -47,7 +47,7 @@
47
47
  "@willbooster/oxfmt-config": "1.2.2",
48
48
  "@willbooster/oxlint-config": "1.4.8",
49
49
  "@willbooster/wb": "22.26.2",
50
- "@willbooster/web-tree-sitter": "10.0.2",
50
+ "@willbooster/web-tree-sitter": "14.0.0",
51
51
  "conventional-changelog-conventionalcommits": "10.4.1",
52
52
  "lefthook": "2.2.2",
53
53
  "oxfmt": "0.73.0",
@@ -61,7 +61,7 @@
61
61
  "wrangler": "4.149.0"
62
62
  },
63
63
  "peerDependencies": {
64
- "@willbooster/web-tree-sitter": "^10.0.2"
64
+ "@willbooster/web-tree-sitter": "^14.0.0"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@willbooster/web-tree-sitter": {
Binary file
package/tree-sitter.json CHANGED
@@ -19,7 +19,7 @@
19
19
  }
20
20
  ],
21
21
  "metadata": {
22
- "version": "9.0.0",
22
+ "version": "11.0.0",
23
23
  "license": "MIT",
24
24
  "description": "Python grammar for tree-sitter",
25
25
  "authors": [