@willbooster/tree-sitter-python 4.0.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 +10 -10
- package/package.json +1 -1
- package/src/node-types.json +10 -10
- 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
|
|
|
@@ -740,7 +746,7 @@ module.exports = grammar({
|
|
|
740
746
|
prec.left(
|
|
741
747
|
PREC.compare,
|
|
742
748
|
seq(
|
|
743
|
-
$.primary_expression,
|
|
749
|
+
field('operands', $.primary_expression),
|
|
744
750
|
repeat1(
|
|
745
751
|
seq(
|
|
746
752
|
field(
|
|
@@ -759,7 +765,7 @@ module.exports = grammar({
|
|
|
759
765
|
alias($._is_not, 'is not')
|
|
760
766
|
)
|
|
761
767
|
),
|
|
762
|
-
$.primary_expression
|
|
768
|
+
field('operands', $.primary_expression)
|
|
763
769
|
)
|
|
764
770
|
)
|
|
765
771
|
)
|
|
@@ -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/src/node-types.json
CHANGED
|
@@ -1081,6 +1081,16 @@
|
|
|
1081
1081
|
"type": "comparison_operator",
|
|
1082
1082
|
"named": true,
|
|
1083
1083
|
"fields": {
|
|
1084
|
+
"operands": {
|
|
1085
|
+
"multiple": true,
|
|
1086
|
+
"required": true,
|
|
1087
|
+
"types": [
|
|
1088
|
+
{
|
|
1089
|
+
"type": "primary_expression",
|
|
1090
|
+
"named": true
|
|
1091
|
+
}
|
|
1092
|
+
]
|
|
1093
|
+
},
|
|
1084
1094
|
"operators": {
|
|
1085
1095
|
"multiple": true,
|
|
1086
1096
|
"required": true,
|
|
@@ -1131,16 +1141,6 @@
|
|
|
1131
1141
|
}
|
|
1132
1142
|
]
|
|
1133
1143
|
}
|
|
1134
|
-
},
|
|
1135
|
-
"children": {
|
|
1136
|
-
"multiple": true,
|
|
1137
|
-
"required": true,
|
|
1138
|
-
"types": [
|
|
1139
|
-
{
|
|
1140
|
-
"type": "primary_expression",
|
|
1141
|
-
"named": true
|
|
1142
|
-
}
|
|
1143
|
-
]
|
|
1144
1144
|
}
|
|
1145
1145
|
},
|
|
1146
1146
|
{
|
package/tree-sitter-python.wasm
CHANGED
|
Binary file
|