summaryrefslogtreecommitdiffstats
path: root/Grammar
diff options
context:
space:
mode:
authorRobert Collins <rbtcollins@hp.com>2015-08-11 20:00:06 (GMT)
committerRobert Collins <rbtcollins@hp.com>2015-08-11 20:00:06 (GMT)
commitdf395991f6341be037a5c6df9b14d924d5ac9e95 (patch)
tree5b0bf65fee4d6b2fc5b8f69cacc50a4bddb6d3f0 /Grammar
parent5b9cd7fa2e4b73bf97a1b28c3f3a7b15c9302941 (diff)
downloadcpython-df395991f6341be037a5c6df9b14d924d5ac9e95.zip
cpython-df395991f6341be037a5c6df9b14d924d5ac9e95.tar.gz
cpython-df395991f6341be037a5c6df9b14d924d5ac9e95.tar.bz2
Issue #9232: Support trailing commas in function declarations.
For example, "def f(*, a = 3,): pass" is now legal. Patch from Mark Dickinson.
Diffstat (limited to 'Grammar')
-rw-r--r--Grammar/Grammar17
1 files changed, 11 insertions, 6 deletions
diff --git a/Grammar/Grammar b/Grammar/Grammar
index 99fcea0..14bdecd 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