aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShantanu <hauntsaninja@users.noreply.github.com>2020-05-03 22:08:14 -0700
committerGitHub <noreply@github.com>2020-05-03 22:08:14 -0700
commit603d3546264149f323edb7952b60075fb6bc4dc2 (patch)
treea0ef9ad7c3453ac9cb48f3ed3cfa2268d565d438 /Grammar
parentClean up unused imports for the peg generator module (GH-19891) (diff)
downloadcpython-603d3546264149f323edb7952b60075fb6bc4dc2.tar.gz
cpython-603d3546264149f323edb7952b60075fb6bc4dc2.tar.bz2
cpython-603d3546264149f323edb7952b60075fb6bc4dc2.zip
bpo-40493: fix function type comment parsing (GH-19894)
The grammar for func_type_input rejected things like `(*t1) ->t2`. This fixes that. Automerge-Triggered-By: @gvanrossum
Diffstat (limited to 'Grammar')
-rw-r--r--Grammar/python.gram4
1 files changed, 4 insertions, 0 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram
index cbd4bc010dc..8e494905cea 100644
--- a/Grammar/python.gram
+++ b/Grammar/python.gram
@@ -40,6 +40,10 @@ type_expressions[asdl_seq*]:
_PyPegen_seq_append_to_end(p, CHECK(_PyPegen_seq_append_to_end(p, a, b)), c) }
| a=','.expression+ ',' '*' b=expression { _PyPegen_seq_append_to_end(p, a, b) }
| a=','.expression+ ',' '**' b=expression { _PyPegen_seq_append_to_end(p, a, b) }
+ | '*' a=expression ',' '**' b=expression {
+ _PyPegen_seq_append_to_end(p, CHECK(_PyPegen_singleton_seq(p, a)), b) }
+ | '*' a=expression { _PyPegen_singleton_seq(p, a) }
+ | '**' a=expression { _PyPegen_singleton_seq(p, a) }
| ','.expression+
statements[asdl_seq*]: a=statement+ { _PyPegen_seq_flatten(p, a) }