diff options
author | Matthew Rahtz <matthew.rahtz@gmail.com> | 2022-03-26 16:55:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-26 16:55:35 (GMT) |
commit | e8e737bcf6d22927caebc30c5d57ac4634063219 (patch) | |
tree | 6c0d4d51e8216f02fa0e6874aa4d78e20dd9397a /Grammar | |
parent | 26cca8067bf5306e372c0e90036d832c5021fd90 (diff) | |
download | cpython-e8e737bcf6d22927caebc30c5d57ac4634063219.zip cpython-e8e737bcf6d22927caebc30c5d57ac4634063219.tar.gz cpython-e8e737bcf6d22927caebc30c5d57ac4634063219.tar.bz2 |
bpo-43224: Implement PEP 646 grammar changes (GH-31018)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Diffstat (limited to 'Grammar')
-rw-r--r-- | Grammar/python.gram | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram index 696f6a1..b9965d2 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -309,6 +309,8 @@ star_etc[StarEtc*]: | invalid_star_etc | '*' a=param_no_default b=param_maybe_default* c=[kwds] { _PyPegen_star_etc(p, a, b, c) } + | '*' a=param_no_default_star_annotation b=param_maybe_default* c=[kwds] { + _PyPegen_star_etc(p, a, b, c) } | '*' ',' b=param_maybe_default+ c=[kwds] { _PyPegen_star_etc(p, NULL, b, c) } | a=kwds { _PyPegen_star_etc(p, NULL, NULL, a) } @@ -333,6 +335,9 @@ kwds[arg_ty]: param_no_default[arg_ty]: | a=param ',' tc=TYPE_COMMENT? { _PyPegen_add_type_comment_to_arg(p, a, tc) } | a=param tc=TYPE_COMMENT? &')' { _PyPegen_add_type_comment_to_arg(p, a, tc) } +param_no_default_star_annotation[arg_ty]: + | a=param_star_annotation ',' tc=TYPE_COMMENT? { _PyPegen_add_type_comment_to_arg(p, a, tc) } + | a=param_star_annotation tc=TYPE_COMMENT? &')' { _PyPegen_add_type_comment_to_arg(p, a, tc) } param_with_default[NameDefaultPair*]: | a=param c=default ',' tc=TYPE_COMMENT? { _PyPegen_name_default_pair(p, a, c, tc) } | a=param c=default tc=TYPE_COMMENT? &')' { _PyPegen_name_default_pair(p, a, c, tc) } @@ -340,7 +345,9 @@ param_maybe_default[NameDefaultPair*]: | a=param c=default? ',' tc=TYPE_COMMENT? { _PyPegen_name_default_pair(p, a, c, tc) } | a=param c=default? tc=TYPE_COMMENT? &')' { _PyPegen_name_default_pair(p, a, c, tc) } param[arg_ty]: a=NAME b=annotation? { _PyAST_arg(a->v.Name.id, b, NULL, EXTRA) } +param_star_annotation[arg_ty]: a=NAME b=star_annotation { _PyAST_arg(a->v.Name.id, b, NULL, EXTRA) } annotation[expr_ty]: ':' a=expression { a } +star_annotation[expr_ty]: ':' a=star_expression { a } default[expr_ty]: '=' a=expression { a } | invalid_default # If statement @@ -782,7 +789,7 @@ primary[expr_ty]: slices[expr_ty]: | a=slice !',' { a } - | a[asdl_expr_seq*]=','.slice+ [','] { _PyAST_Tuple(a, Load, EXTRA) } + | a[asdl_expr_seq*]=','.(slice | starred_expression)+ [','] { _PyAST_Tuple(a, Load, EXTRA) } slice[expr_ty]: | a=[expression] ':' b=[expression] c=[':' d=[expression] { d }] { _PyAST_Slice(a, b, c, EXTRA) } |