@willbooster/tree-sitter-python 4.1.0 → 5.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 +2 -2
- package/grammar.js +8 -8
- package/package.json +1 -1
- package/tree-sitter-python.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ parser.setLanguage(await Language.load(python));
|
|
|
63
63
|
|
|
64
64
|
The package also ships the queries in `queries/` and the node types in `src/node-types.json`.
|
|
65
65
|
|
|
66
|
-
Qualified generic bases use `member_type` inside `generic_type`. Plain qualified generic arguments also expose `member_type` inside their `type` operand, so queries can capture the terminal type name while excluding its module qualifiers. Structured unpacked annotations and unpacked generic arguments use a `type` child inside `splat_type`. Expression-valued starred parameter annotations, such as `*args: *factory()`, keep a direct expression child instead. Ordinary value unpacks keep their expression tree.
|
|
66
|
+
Qualified generic bases use `member_type` inside `generic_type`. Generic bases in annotations also recognize the contextual identifier spellings `match`, `print`, `exec` and `lazy`, while ordinary value subscripts retain their expression trees. Plain qualified generic arguments also expose `member_type` inside their `type` operand, so queries can capture the terminal type name while excluding its module qualifiers. Structured unpacked annotations and unpacked generic arguments use a `type` child inside `splat_type`. Expression-valued starred parameter annotations, such as `*args: *factory()`, keep a direct expression child instead. Ordinary value unpacks keep their expression tree.
|
|
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
|
|
@@ -72,7 +72,7 @@ fuzzed with. The parser requires runtime 2.x:
|
|
|
72
72
|
```toml
|
|
73
73
|
[dependencies]
|
|
74
74
|
tree-sitter = { package = "willbooster-tree-sitter", version = "2" }
|
|
75
|
-
tree-sitter-python = { package = "willbooster-tree-sitter-python", version = "
|
|
75
|
+
tree-sitter-python = { package = "willbooster-tree-sitter-python", version = "5" }
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
```rust
|
package/grammar.js
CHANGED
|
@@ -52,6 +52,7 @@ module.exports = grammar({
|
|
|
52
52
|
[$.primary_expression, $._default_member_type],
|
|
53
53
|
[$.list, $._default_type_list],
|
|
54
54
|
[$._type_parameter_expression, $.expression],
|
|
55
|
+
[$.list_splat, $._type_parameter_expression],
|
|
55
56
|
[$.primary_expression, $.pattern],
|
|
56
57
|
[$.primary_expression, $.list_splat_pattern],
|
|
57
58
|
[$.tuple, $.tuple_pattern],
|
|
@@ -59,6 +60,7 @@ module.exports = grammar({
|
|
|
59
60
|
[$.with_item, $.tuple],
|
|
60
61
|
[$.named_expression, $.as_pattern],
|
|
61
62
|
[$.print_statement, $.primary_expression],
|
|
63
|
+
[$.print_statement, $.primary_expression, $.generic_type],
|
|
62
64
|
[$.match_statement, $.primary_expression],
|
|
63
65
|
[$.primary_expression, $.generic_type],
|
|
64
66
|
],
|
|
@@ -429,7 +431,11 @@ module.exports = grammar({
|
|
|
429
431
|
),
|
|
430
432
|
|
|
431
433
|
_type_parameter_name: ($) =>
|
|
432
|
-
choice(
|
|
434
|
+
choice(
|
|
435
|
+
$.identifier,
|
|
436
|
+
alias(choice('type', 'match', 'lazy'), $.identifier),
|
|
437
|
+
prec(-3, alias(choice('print', 'exec'), $.identifier))
|
|
438
|
+
),
|
|
433
439
|
|
|
434
440
|
_default_member_base: ($) => choice($._type_parameter_name, alias($._default_member_type, $.member_type)),
|
|
435
441
|
|
|
@@ -849,13 +855,7 @@ module.exports = grammar({
|
|
|
849
855
|
type: ($) => choice(prec(1, $.expression), $.generic_type, $.union_type, $.constrained_type, $.member_type),
|
|
850
856
|
splat_type: ($) => prec(1, seq(choice('*', '**'), $.identifier)),
|
|
851
857
|
generic_type: ($) =>
|
|
852
|
-
prec.dynamic(
|
|
853
|
-
1,
|
|
854
|
-
seq(
|
|
855
|
-
choice($.identifier, alias('type', $.identifier), alias($._default_member_type, $.member_type)),
|
|
856
|
-
alias($._generic_type_arguments, $.type_parameter)
|
|
857
|
-
)
|
|
858
|
-
),
|
|
858
|
+
prec.dynamic(1, seq($._default_member_base, alias($._generic_type_arguments, $.type_parameter))),
|
|
859
859
|
union_type: ($) => prec.left(seq($.type, '|', $.type)),
|
|
860
860
|
constrained_type: ($) => prec.right(seq($.type, ':', $.type)),
|
|
861
861
|
member_type: ($) => seq($.type, '.', $.identifier),
|
package/package.json
CHANGED
package/tree-sitter-python.wasm
CHANGED
|
Binary file
|