@willbooster/tree-sitter-python 6.0.0 → 7.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/grammar.js +28 -32
- package/package.json +1 -1
- package/src/node-types.json +29 -5
- package/tree-sitter-python.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -43,16 +43,12 @@ module.exports = grammar({
|
|
|
43
43
|
extras: ($) => [$.comment, /[\s\f\uFEFF\u2060\u200B]|\r?\n/, $.line_continuation],
|
|
44
44
|
|
|
45
45
|
conflicts: ($) => [
|
|
46
|
-
[$.default_type_parameter, $.primary_expression],
|
|
46
|
+
[$.default_type_parameter, $._default_type_primary, $.primary_expression],
|
|
47
47
|
[$.primary_expression, $._default_type_primary],
|
|
48
48
|
[$.primary_expression, $._default_generic_type],
|
|
49
|
-
[$._default_generic_type, $.primary_expression, $.generic_type],
|
|
50
|
-
[$._default_type_arguments, $.expression],
|
|
51
|
-
[$._default_type_arguments, $._generic_type_arguments],
|
|
52
49
|
[$.primary_expression, $._default_member_type],
|
|
53
50
|
[$.list, $._default_type_list],
|
|
54
51
|
[$._type_parameter_expression, $.expression],
|
|
55
|
-
[$.list_splat, $._type_parameter_expression],
|
|
56
52
|
[$.primary_expression, $.pattern],
|
|
57
53
|
[$.primary_expression, $.list_splat_pattern],
|
|
58
54
|
[$.tuple, $.tuple_pattern],
|
|
@@ -60,9 +56,7 @@ module.exports = grammar({
|
|
|
60
56
|
[$.with_item, $.tuple],
|
|
61
57
|
[$.named_expression, $.as_pattern],
|
|
62
58
|
[$.print_statement, $.primary_expression],
|
|
63
|
-
[$.print_statement, $.primary_expression, $.generic_type],
|
|
64
59
|
[$.match_statement, $.primary_expression],
|
|
65
|
-
[$.primary_expression, $.generic_type],
|
|
66
60
|
],
|
|
67
61
|
|
|
68
62
|
supertypes: ($) => [
|
|
@@ -90,12 +84,14 @@ module.exports = grammar({
|
|
|
90
84
|
// if no dedent is expected.
|
|
91
85
|
sym('comment'),
|
|
92
86
|
|
|
93
|
-
|
|
94
|
-
// so that it can avoid returning dedent tokens between brackets.
|
|
95
|
-
']',
|
|
87
|
+
'(',
|
|
96
88
|
')',
|
|
89
|
+
'[',
|
|
90
|
+
']',
|
|
91
|
+
'{',
|
|
97
92
|
'}',
|
|
98
93
|
'except',
|
|
94
|
+
sym('_format_specifier_content'),
|
|
99
95
|
],
|
|
100
96
|
|
|
101
97
|
inline: ($) => [
|
|
@@ -390,7 +386,7 @@ module.exports = grammar({
|
|
|
390
386
|
type_alias_statement: ($) =>
|
|
391
387
|
seq('type', field('left', alias($._type_alias_name, $.type)), '=', field('right', $.type)),
|
|
392
388
|
|
|
393
|
-
_type_alias_name: ($) => choice($.identifier, alias($._generic_type_definition,
|
|
389
|
+
_type_alias_name: ($) => choice($.identifier, alias($._generic_type_definition, sym('generic_type'))),
|
|
394
390
|
|
|
395
391
|
_generic_type_definition: ($) => seq($.identifier, $.type_parameter),
|
|
396
392
|
|
|
@@ -404,7 +400,14 @@ module.exports = grammar({
|
|
|
404
400
|
field('body', $._suite)
|
|
405
401
|
),
|
|
406
402
|
type_parameter: ($) =>
|
|
407
|
-
seq(
|
|
403
|
+
seq(
|
|
404
|
+
'[',
|
|
405
|
+
commaSep1(
|
|
406
|
+
choice($.type, alias($._constrained_type_expression, $.type), $.splat_type, $.default_type_parameter)
|
|
407
|
+
),
|
|
408
|
+
optional(','),
|
|
409
|
+
']'
|
|
410
|
+
),
|
|
408
411
|
|
|
409
412
|
default_type_parameter: ($) =>
|
|
410
413
|
choice(
|
|
@@ -437,11 +440,16 @@ module.exports = grammar({
|
|
|
437
440
|
prec(-3, alias(choice('print', 'exec'), $.identifier))
|
|
438
441
|
),
|
|
439
442
|
|
|
440
|
-
_default_member_base: ($) =>
|
|
443
|
+
_default_member_base: ($) =>
|
|
444
|
+
choice(
|
|
445
|
+
$._type_parameter_name,
|
|
446
|
+
alias($._default_member_type, sym('member_type')),
|
|
447
|
+
alias($._default_generic_type, sym('generic_type'))
|
|
448
|
+
),
|
|
441
449
|
|
|
442
450
|
_type_parameter_expression: ($) => choice($._expression_without_named_expression, prec.dynamic(1, $._default_type)),
|
|
443
451
|
|
|
444
|
-
_default_type: ($) => choice($._default_type_primary, alias($._default_union_type,
|
|
452
|
+
_default_type: ($) => choice($._default_type_primary, alias($._default_union_type, sym('union_type'))),
|
|
445
453
|
|
|
446
454
|
_default_type_primary: ($) =>
|
|
447
455
|
choice(
|
|
@@ -449,8 +457,8 @@ module.exports = grammar({
|
|
|
449
457
|
$.keyword_identifier,
|
|
450
458
|
$.none,
|
|
451
459
|
$.string,
|
|
452
|
-
alias($._default_member_type,
|
|
453
|
-
alias($._default_generic_type,
|
|
460
|
+
alias($._default_member_type, sym('member_type')),
|
|
461
|
+
alias($._default_generic_type, sym('generic_type')),
|
|
454
462
|
alias($._default_type_list, $.list),
|
|
455
463
|
alias($._default_type_tuple, $.tuple),
|
|
456
464
|
alias($._default_parenthesized_type, $.parenthesized_expression)
|
|
@@ -471,6 +479,7 @@ module.exports = grammar({
|
|
|
471
479
|
commaSep1(
|
|
472
480
|
choice(
|
|
473
481
|
alias($._type_parameter_expression, $.type),
|
|
482
|
+
alias($._constrained_type_expression, $.type),
|
|
474
483
|
$.named_expression,
|
|
475
484
|
alias($._default_splat_argument, $.splat_type),
|
|
476
485
|
$.slice
|
|
@@ -502,16 +511,6 @@ module.exports = grammar({
|
|
|
502
511
|
|
|
503
512
|
_default_splat_type: ($) => seq('*', choice($.primary_expression, prec.dynamic(1, alias($._default_type, $.type)))),
|
|
504
513
|
|
|
505
|
-
_generic_type_arguments: ($) =>
|
|
506
|
-
seq(
|
|
507
|
-
'[',
|
|
508
|
-
commaSep1(
|
|
509
|
-
choice($.type, alias($._type_parameter_expression, $.type), alias($._default_splat_argument, $.splat_type))
|
|
510
|
-
),
|
|
511
|
-
optional(','),
|
|
512
|
-
']'
|
|
513
|
-
),
|
|
514
|
-
|
|
515
514
|
argument_list: ($) =>
|
|
516
515
|
seq(
|
|
517
516
|
'(',
|
|
@@ -856,13 +855,10 @@ module.exports = grammar({
|
|
|
856
855
|
)
|
|
857
856
|
),
|
|
858
857
|
|
|
859
|
-
type: ($) =>
|
|
858
|
+
type: ($) => $._type_parameter_expression,
|
|
860
859
|
splat_type: ($) => prec(1, seq(choice('*', '**'), $.identifier)),
|
|
861
|
-
|
|
862
|
-
prec.dynamic(1, seq($._default_member_base, alias($._generic_type_arguments, $.type_parameter))),
|
|
863
|
-
union_type: ($) => prec.left(seq($.type, '|', $.type)),
|
|
860
|
+
_constrained_type_expression: ($) => $.constrained_type,
|
|
864
861
|
constrained_type: ($) => prec.right(seq($.type, ':', $.type)),
|
|
865
|
-
member_type: ($) => seq($.type, '.', $.identifier),
|
|
866
862
|
|
|
867
863
|
keyword_argument: ($) =>
|
|
868
864
|
seq(field('name', choice($.identifier, $.keyword_identifier)), '=', field('value', $.expression)),
|
|
@@ -977,7 +973,7 @@ module.exports = grammar({
|
|
|
977
973
|
format_specifier: ($) =>
|
|
978
974
|
seq(
|
|
979
975
|
token(prec(1, ':')),
|
|
980
|
-
repeat(choice(
|
|
976
|
+
repeat(choice(sym('_format_specifier_content'), alias($.interpolation, sym('format_expression'))))
|
|
981
977
|
),
|
|
982
978
|
|
|
983
979
|
type_conversion: () => /![a-z]/,
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
|
@@ -2030,6 +2030,10 @@
|
|
|
2030
2030
|
"multiple": true,
|
|
2031
2031
|
"required": true,
|
|
2032
2032
|
"types": [
|
|
2033
|
+
{
|
|
2034
|
+
"type": "generic_type",
|
|
2035
|
+
"named": true
|
|
2036
|
+
},
|
|
2033
2037
|
{
|
|
2034
2038
|
"type": "identifier",
|
|
2035
2039
|
"named": true
|
|
@@ -2576,15 +2580,15 @@
|
|
|
2576
2580
|
"required": true,
|
|
2577
2581
|
"types": [
|
|
2578
2582
|
{
|
|
2579
|
-
"type": "
|
|
2583
|
+
"type": "generic_type",
|
|
2580
2584
|
"named": true
|
|
2581
2585
|
},
|
|
2582
2586
|
{
|
|
2583
|
-
"type": "
|
|
2587
|
+
"type": "identifier",
|
|
2584
2588
|
"named": true
|
|
2585
2589
|
},
|
|
2586
2590
|
{
|
|
2587
|
-
"type": "
|
|
2591
|
+
"type": "member_type",
|
|
2588
2592
|
"named": true
|
|
2589
2593
|
}
|
|
2590
2594
|
]
|
|
@@ -3242,21 +3246,41 @@
|
|
|
3242
3246
|
"required": true,
|
|
3243
3247
|
"types": [
|
|
3244
3248
|
{
|
|
3245
|
-
"type": "
|
|
3249
|
+
"type": "boolean_operator",
|
|
3246
3250
|
"named": true
|
|
3247
3251
|
},
|
|
3248
3252
|
{
|
|
3249
|
-
"type": "
|
|
3253
|
+
"type": "comparison_operator",
|
|
3254
|
+
"named": true
|
|
3255
|
+
},
|
|
3256
|
+
{
|
|
3257
|
+
"type": "conditional_expression",
|
|
3258
|
+
"named": true
|
|
3259
|
+
},
|
|
3260
|
+
{
|
|
3261
|
+
"type": "constrained_type",
|
|
3250
3262
|
"named": true
|
|
3251
3263
|
},
|
|
3252
3264
|
{
|
|
3253
3265
|
"type": "generic_type",
|
|
3254
3266
|
"named": true
|
|
3255
3267
|
},
|
|
3268
|
+
{
|
|
3269
|
+
"type": "lambda",
|
|
3270
|
+
"named": true
|
|
3271
|
+
},
|
|
3256
3272
|
{
|
|
3257
3273
|
"type": "member_type",
|
|
3258
3274
|
"named": true
|
|
3259
3275
|
},
|
|
3276
|
+
{
|
|
3277
|
+
"type": "not_operator",
|
|
3278
|
+
"named": true
|
|
3279
|
+
},
|
|
3280
|
+
{
|
|
3281
|
+
"type": "primary_expression",
|
|
3282
|
+
"named": true
|
|
3283
|
+
},
|
|
3260
3284
|
{
|
|
3261
3285
|
"type": "union_type",
|
|
3262
3286
|
"named": true
|
package/tree-sitter-python.wasm
CHANGED
|
Binary file
|