@willbooster/tree-sitter-python 6.0.1 → 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 +22 -28
- 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: ($) => [
|
|
@@ -392,7 +386,7 @@ module.exports = grammar({
|
|
|
392
386
|
type_alias_statement: ($) =>
|
|
393
387
|
seq('type', field('left', alias($._type_alias_name, $.type)), '=', field('right', $.type)),
|
|
394
388
|
|
|
395
|
-
_type_alias_name: ($) => choice($.identifier, alias($._generic_type_definition,
|
|
389
|
+
_type_alias_name: ($) => choice($.identifier, alias($._generic_type_definition, sym('generic_type'))),
|
|
396
390
|
|
|
397
391
|
_generic_type_definition: ($) => seq($.identifier, $.type_parameter),
|
|
398
392
|
|
|
@@ -406,7 +400,14 @@ module.exports = grammar({
|
|
|
406
400
|
field('body', $._suite)
|
|
407
401
|
),
|
|
408
402
|
type_parameter: ($) =>
|
|
409
|
-
seq(
|
|
403
|
+
seq(
|
|
404
|
+
'[',
|
|
405
|
+
commaSep1(
|
|
406
|
+
choice($.type, alias($._constrained_type_expression, $.type), $.splat_type, $.default_type_parameter)
|
|
407
|
+
),
|
|
408
|
+
optional(','),
|
|
409
|
+
']'
|
|
410
|
+
),
|
|
410
411
|
|
|
411
412
|
default_type_parameter: ($) =>
|
|
412
413
|
choice(
|
|
@@ -439,11 +440,16 @@ module.exports = grammar({
|
|
|
439
440
|
prec(-3, alias(choice('print', 'exec'), $.identifier))
|
|
440
441
|
),
|
|
441
442
|
|
|
442
|
-
_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
|
+
),
|
|
443
449
|
|
|
444
450
|
_type_parameter_expression: ($) => choice($._expression_without_named_expression, prec.dynamic(1, $._default_type)),
|
|
445
451
|
|
|
446
|
-
_default_type: ($) => choice($._default_type_primary, alias($._default_union_type,
|
|
452
|
+
_default_type: ($) => choice($._default_type_primary, alias($._default_union_type, sym('union_type'))),
|
|
447
453
|
|
|
448
454
|
_default_type_primary: ($) =>
|
|
449
455
|
choice(
|
|
@@ -451,8 +457,8 @@ module.exports = grammar({
|
|
|
451
457
|
$.keyword_identifier,
|
|
452
458
|
$.none,
|
|
453
459
|
$.string,
|
|
454
|
-
alias($._default_member_type,
|
|
455
|
-
alias($._default_generic_type,
|
|
460
|
+
alias($._default_member_type, sym('member_type')),
|
|
461
|
+
alias($._default_generic_type, sym('generic_type')),
|
|
456
462
|
alias($._default_type_list, $.list),
|
|
457
463
|
alias($._default_type_tuple, $.tuple),
|
|
458
464
|
alias($._default_parenthesized_type, $.parenthesized_expression)
|
|
@@ -473,6 +479,7 @@ module.exports = grammar({
|
|
|
473
479
|
commaSep1(
|
|
474
480
|
choice(
|
|
475
481
|
alias($._type_parameter_expression, $.type),
|
|
482
|
+
alias($._constrained_type_expression, $.type),
|
|
476
483
|
$.named_expression,
|
|
477
484
|
alias($._default_splat_argument, $.splat_type),
|
|
478
485
|
$.slice
|
|
@@ -504,16 +511,6 @@ module.exports = grammar({
|
|
|
504
511
|
|
|
505
512
|
_default_splat_type: ($) => seq('*', choice($.primary_expression, prec.dynamic(1, alias($._default_type, $.type)))),
|
|
506
513
|
|
|
507
|
-
_generic_type_arguments: ($) =>
|
|
508
|
-
seq(
|
|
509
|
-
'[',
|
|
510
|
-
commaSep1(
|
|
511
|
-
choice($.type, alias($._type_parameter_expression, $.type), alias($._default_splat_argument, $.splat_type))
|
|
512
|
-
),
|
|
513
|
-
optional(','),
|
|
514
|
-
']'
|
|
515
|
-
),
|
|
516
|
-
|
|
517
514
|
argument_list: ($) =>
|
|
518
515
|
seq(
|
|
519
516
|
'(',
|
|
@@ -858,13 +855,10 @@ module.exports = grammar({
|
|
|
858
855
|
)
|
|
859
856
|
),
|
|
860
857
|
|
|
861
|
-
type: ($) =>
|
|
858
|
+
type: ($) => $._type_parameter_expression,
|
|
862
859
|
splat_type: ($) => prec(1, seq(choice('*', '**'), $.identifier)),
|
|
863
|
-
|
|
864
|
-
prec.dynamic(1, seq($._default_member_base, alias($._generic_type_arguments, $.type_parameter))),
|
|
865
|
-
union_type: ($) => prec.left(seq($.type, '|', $.type)),
|
|
860
|
+
_constrained_type_expression: ($) => $.constrained_type,
|
|
866
861
|
constrained_type: ($) => prec.right(seq($.type, ':', $.type)),
|
|
867
|
-
member_type: ($) => seq($.type, '.', $.identifier),
|
|
868
862
|
|
|
869
863
|
keyword_argument: ($) =>
|
|
870
864
|
seq(field('name', choice($.identifier, $.keyword_identifier)), '=', field('value', $.expression)),
|
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
|