From df395991f6341be037a5c6df9b14d924d5ac9e95 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Wed, 12 Aug 2015 08:00:06 +1200 Subject: Issue #9232: Support trailing commas in function declarations. For example, "def f(*, a = 3,): pass" is now legal. Patch from Mark Dickinson. --- Grammar/Grammar | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'Grammar') diff --git a/Grammar/Grammar b/Grammar/Grammar index 99fcea026a..14bdecd0e2 100644 --- a/Grammar/Grammar +++ b/Grammar/Grammar @@ -27,13 +27,18 @@ async_funcdef: ASYNC funcdef funcdef: 'def' NAME parameters ['->' test] ':' suite parameters: '(' [typedargslist] ')' -typedargslist: (tfpdef ['=' test] (',' tfpdef ['=' test])* [',' - ['*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef]] - | '*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef) +typedargslist: (tfpdef ['=' test] (',' tfpdef ['=' test])* [',' [ + '*' [tfpdef] (',' tfpdef ['=' test])* [',' ['**' tfpdef [',']]] + | '**' tfpdef [',']]] + | '*' [tfpdef] (',' tfpdef ['=' test])* [',' ['**' tfpdef [',']]] + | '**' tfpdef [',']) tfpdef: NAME [':' test] -varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [',' - ['*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef]] - | '*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef) +varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [',' [ + '*' [vfpdef] (',' vfpdef ['=' test])* [',' ['**' vfpdef [',']]] + | '**' vfpdef [',']]] + | '*' [vfpdef] (',' vfpdef ['=' test])* [',' ['**' vfpdef [',']]] + | '**' vfpdef [','] +) vfpdef: NAME stmt: simple_stmt | compound_stmt -- cgit v1.2.1