diff options
author | Shantanu <hauntsaninja@users.noreply.github.com> | 2020-05-04 05:08:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-04 05:08:14 (GMT) |
commit | 603d3546264149f323edb7952b60075fb6bc4dc2 (patch) | |
tree | a0ef9ad7c3453ac9cb48f3ed3cfa2268d565d438 /Parser | |
parent | c95e691c904bb5ebd91825efa81b93cb9e354a85 (diff) | |
download | cpython-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 'Parser')
-rw-r--r-- | Parser/pegen/parse.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index b4745ba..492b5e6 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -825,6 +825,9 @@ fstring_rule(Parser *p) // | ','.expression+ ',' '*' expression ',' '**' expression // | ','.expression+ ',' '*' expression // | ','.expression+ ',' '**' expression +// | '*' expression ',' '**' expression +// | '*' expression +// | '**' expression // | ','.expression+ static asdl_seq* type_expressions_rule(Parser *p) @@ -915,6 +918,69 @@ type_expressions_rule(Parser *p) } p->mark = mark; } + { // '*' expression ',' '**' expression + expr_ty a; + expr_ty b; + Token * literal; + Token * literal_1; + Token * literal_2; + if ( + (literal = _PyPegen_expect_token(p, 16)) + && + (a = expression_rule(p)) + && + (literal_1 = _PyPegen_expect_token(p, 12)) + && + (literal_2 = _PyPegen_expect_token(p, 35)) + && + (b = expression_rule(p)) + ) + { + res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_singleton_seq ( p , a ) ) , b ); + if (res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + return NULL; + } + goto done; + } + p->mark = mark; + } + { // '*' expression + expr_ty a; + Token * literal; + if ( + (literal = _PyPegen_expect_token(p, 16)) + && + (a = expression_rule(p)) + ) + { + res = _PyPegen_singleton_seq ( p , a ); + if (res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + return NULL; + } + goto done; + } + p->mark = mark; + } + { // '**' expression + expr_ty a; + Token * literal; + if ( + (literal = _PyPegen_expect_token(p, 35)) + && + (a = expression_rule(p)) + ) + { + res = _PyPegen_singleton_seq ( p , a ); + if (res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + return NULL; + } + goto done; + } + p->mark = mark; + } { // ','.expression+ asdl_seq * _gather_9_var; if ( |