@willbooster/tree-sitter-python 2.3.0 → 2.3.1
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 +3 -26
- package/package.json +1 -1
- package/tree-sitter-python.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -57,6 +57,7 @@ module.exports = grammar({
|
|
|
57
57
|
[$.named_expression, $.as_pattern],
|
|
58
58
|
[$.print_statement, $.primary_expression],
|
|
59
59
|
[$.match_statement, $.primary_expression],
|
|
60
|
+
[$.primary_expression, $.generic_type],
|
|
60
61
|
],
|
|
61
62
|
|
|
62
63
|
supertypes: ($) => [
|
|
@@ -152,8 +153,6 @@ module.exports = grammar({
|
|
|
152
153
|
|
|
153
154
|
_statement: ($) => choice($._simple_statements, $._compound_statement),
|
|
154
155
|
|
|
155
|
-
// Simple statements
|
|
156
|
-
|
|
157
156
|
_simple_statements: ($) => seq(sep1($._simple_statement, SEMICOLON), optional(SEMICOLON), sym('_newline')),
|
|
158
157
|
|
|
159
158
|
_simple_statement: ($) =>
|
|
@@ -252,8 +251,6 @@ module.exports = grammar({
|
|
|
252
251
|
break_statement: () => prec.left('break'),
|
|
253
252
|
continue_statement: () => prec.left('continue'),
|
|
254
253
|
|
|
255
|
-
// Compound statements
|
|
256
|
-
|
|
257
254
|
_compound_statement: ($) =>
|
|
258
255
|
choice(
|
|
259
256
|
$.if_statement,
|
|
@@ -535,8 +532,6 @@ module.exports = grammar({
|
|
|
535
532
|
|
|
536
533
|
dotted_name: ($) => prec(1, sep1($.identifier, '.')),
|
|
537
534
|
|
|
538
|
-
// Match cases
|
|
539
|
-
|
|
540
535
|
case_pattern: ($) => prec(1, choice(alias($._as_pattern, $.as_pattern), $.keyword_pattern, $._simple_pattern)),
|
|
541
536
|
|
|
542
537
|
_simple_pattern: ($) =>
|
|
@@ -583,8 +578,6 @@ module.exports = grammar({
|
|
|
583
578
|
complex_pattern: ($) =>
|
|
584
579
|
prec(1, seq(optional('-'), choice($.integer, $.float), choice('+', '-'), choice($.integer, $.float))),
|
|
585
580
|
|
|
586
|
-
// Patterns
|
|
587
|
-
|
|
588
581
|
_parameters: ($) => seq(commaSep1($.parameter), optional(',')),
|
|
589
582
|
|
|
590
583
|
_patterns: ($) => seq(commaSep1($.pattern), optional(',')),
|
|
@@ -630,13 +623,9 @@ module.exports = grammar({
|
|
|
630
623
|
|
|
631
624
|
dictionary_splat_pattern: ($) => seq('**', choice($.identifier, $.keyword_identifier, $.subscript, $.attribute)),
|
|
632
625
|
|
|
633
|
-
// Extended patterns (patterns allowed in match statement are far more flexible than simple patterns though still a subset of "expression")
|
|
634
|
-
|
|
635
626
|
as_pattern: ($) =>
|
|
636
627
|
prec.left(seq($.expression, 'as', field('alias', alias($.expression, sym('as_pattern_target'))))),
|
|
637
628
|
|
|
638
|
-
// Expressions
|
|
639
|
-
|
|
640
629
|
_expression_within_for_in_clause: ($) => choice($.expression, alias($.lambda_within_for_in_clause, $.lambda)),
|
|
641
630
|
|
|
642
631
|
expression: ($) => choice($._expression_without_named_expression, $.named_expression, $.as_pattern),
|
|
@@ -850,7 +839,7 @@ module.exports = grammar({
|
|
|
850
839
|
type: ($) => choice(prec(1, $.expression), $.generic_type, $.union_type, $.constrained_type, $.member_type),
|
|
851
840
|
splat_type: ($) => prec(1, seq(choice('*', '**'), $.identifier)),
|
|
852
841
|
generic_type: ($) =>
|
|
853
|
-
prec(
|
|
842
|
+
prec.dynamic(
|
|
854
843
|
1,
|
|
855
844
|
seq(choice($.identifier, alias('type', $.identifier)), alias($._generic_type_arguments, $.type_parameter))
|
|
856
845
|
),
|
|
@@ -861,8 +850,6 @@ module.exports = grammar({
|
|
|
861
850
|
keyword_argument: ($) =>
|
|
862
851
|
seq(field('name', choice($.identifier, $.keyword_identifier)), '=', field('value', $.expression)),
|
|
863
852
|
|
|
864
|
-
// Literals
|
|
865
|
-
|
|
866
853
|
list: ($) => seq('[', optional($._collection_elements), ']'),
|
|
867
854
|
|
|
868
855
|
set: ($) => seq('{', $._collection_elements, '}'),
|
|
@@ -984,13 +971,7 @@ module.exports = grammar({
|
|
|
984
971
|
seq(choice('0x', '0X'), repeat1(/_?[A-Fa-f0-9]+/), optional(/[Ll]/)),
|
|
985
972
|
seq(choice('0o', '0O'), repeat1(/_?[0-7]+/), optional(/[Ll]/)),
|
|
986
973
|
seq(choice('0b', '0B'), repeat1(/_?[0-1]+/), optional(/[Ll]/)),
|
|
987
|
-
seq(
|
|
988
|
-
repeat1(/[0-9]+_?/),
|
|
989
|
-
choice(
|
|
990
|
-
optional(/[Ll]/), // long numbers
|
|
991
|
-
optional(/[jJ]/) // complex numbers
|
|
992
|
-
)
|
|
993
|
-
)
|
|
974
|
+
seq(repeat1(/[0-9]+_?/), choice(optional(/[Ll]/), optional(/[jJ]/)))
|
|
994
975
|
)
|
|
995
976
|
),
|
|
996
977
|
|
|
@@ -1041,8 +1022,6 @@ module.exports = grammar({
|
|
|
1041
1022
|
Object.assign(module.exports, { PREC });
|
|
1042
1023
|
|
|
1043
1024
|
/**
|
|
1044
|
-
* Creates a rule to match one or more of the rules separated by a comma
|
|
1045
|
-
*
|
|
1046
1025
|
* @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} rule
|
|
1047
1026
|
*
|
|
1048
1027
|
* @returns {import('@willbooster/web-tree-sitter/dsl').SeqRule}
|
|
@@ -1052,8 +1031,6 @@ function commaSep1(rule) {
|
|
|
1052
1031
|
}
|
|
1053
1032
|
|
|
1054
1033
|
/**
|
|
1055
|
-
* Creates a rule to match one or more occurrences of `rule` separated by `sep`
|
|
1056
|
-
*
|
|
1057
1034
|
* @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} rule
|
|
1058
1035
|
*
|
|
1059
1036
|
* @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} separator
|
package/package.json
CHANGED
package/tree-sitter-python.wasm
CHANGED
|
Binary file
|