summaryrefslogtreecommitdiffstats
path: root/Grammar/python.gram
diff options
context:
space:
mode:
authorShantanu <hauntsaninja@users.noreply.github.com>2020-05-04 05:08:14 (GMT)
committerGitHub <noreply@github.com>2020-05-04 05:08:14 (GMT)
commit603d3546264149f323edb7952b60075fb6bc4dc2 (patch)
treea0ef9ad7c3453ac9cb48f3ed3cfa2268d565d438 /Grammar/python.gram
parentc95e691c904bb5ebd91825efa81b93cb9e354a85 (diff)
downloadcpython-603d3546264149f323edb7952b60075fb6bc4dc2.zip
cpython-603d3546264149f323edb7952b60075fb6bc4dc2.tar.gz
cpython-603d3546264149f323edb7952b60075fb6bc4dc2.tar.bz2
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/python.gram')
-rw-r--r--Grammar/python.gram4
1 files changed, 4 insertions, 0 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram
index cbd4bc0..8e49490 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) }