forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bpo-33064: lib2to3: support trailing comma after *args and **kwargs (p…
…ython#6096) New tests also added. I also made the comments in line with the builtin Grammar/Grammar. PEP 306 was withdrawn, Kees Blom's railroad program has been lost to the sands of time for at least 16 years now (I found a python-dev post from people looking for it).
- Loading branch information
Showing
3 changed files
with
39 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,7 @@ | ||
# Grammar for 2to3. This grammar supports Python 2.x and 3.x. | ||
|
||
# Note: Changing the grammar specified in this file will most likely | ||
# require corresponding changes in the parser module | ||
# (../Modules/parsermodule.c). If you can't make the changes to | ||
# that module yourself, please co-ordinate the required changes | ||
# with someone who can; ask around on python-dev for help. Fred | ||
# Drake <[email protected]> will probably be listening there. | ||
|
||
# NOTE WELL: You should also follow all the steps listed in PEP 306, | ||
# "How to Change Python's Grammar" | ||
|
||
# Commands for Kees Blom's railroad program | ||
#diagram:token NAME | ||
#diagram:token NUMBER | ||
#diagram:token STRING | ||
#diagram:token NEWLINE | ||
#diagram:token ENDMARKER | ||
#diagram:token INDENT | ||
#diagram:output\input python.bla | ||
#diagram:token DEDENT | ||
#diagram:output\textwidth 20.04cm\oddsidemargin 0.0cm\evensidemargin 0.0cm | ||
#diagram:rules | ||
# NOTE WELL: You should also follow all the steps listed at | ||
# https://devguide.python.org/grammar/ | ||
|
||
# Start symbols for the grammar: | ||
# file_input is a module or sequence of commands read from an input file; | ||
|
@@ -38,13 +19,13 @@ async_funcdef: 'async' funcdef | |
funcdef: 'def' NAME parameters ['->' test] ':' suite | ||
parameters: '(' [typedargslist] ')' | ||
typedargslist: ((tfpdef ['=' test] ',')* | ||
('*' [tname] (',' tname ['=' test])* [',' '**' tname] | '**' tname) | ||
('*' [tname] (',' tname ['=' test])* [',' ['**' tname [',']]] | '**' tname [',']) | ||
| tfpdef ['=' test] (',' tfpdef ['=' test])* [',']) | ||
tname: NAME [':' test] | ||
tfpdef: tname | '(' tfplist ')' | ||
tfplist: tfpdef (',' tfpdef)* [','] | ||
varargslist: ((vfpdef ['=' test] ',')* | ||
('*' [vname] (',' vname ['=' test])* [',' '**' vname] | '**' vname) | ||
('*' [vname] (',' vname ['=' test])* [',' ['**' vname [',']]] | '**' vname [',']) | ||
| vfpdef ['=' test] (',' vfpdef ['=' test])* [',']) | ||
vname: NAME | ||
vfpdef: vname | '(' vfplist ')' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/Library/2018-03-12-19-58-25.bpo-33064.LO2KIY.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
lib2to3 now properly supports trailing commas after ``*args`` and | ||
``**kwargs`` in function signatures. |