bpo-33064: lib2to3: support trailing comma after *args and **kwargs (… · python/cpython@b4c8871 (original) (raw)
1
1
`# Grammar for 2to3. This grammar supports Python 2.x and 3.x.
`
2
2
``
3
``
`-
Note: Changing the grammar specified in this file will most likely
`
4
``
`-
require corresponding changes in the parser module
`
5
``
`-
(../Modules/parsermodule.c). If you can't make the changes to
`
6
``
`-
that module yourself, please co-ordinate the required changes
`
7
``
`-
with someone who can; ask around on python-dev for help. Fred
`
8
``
`-
Drake fdrake@acm.org will probably be listening there.
`
9
``
-
10
``
`-
NOTE WELL: You should also follow all the steps listed in PEP 306,
`
11
``
`-
"How to Change Python's Grammar"
`
12
``
-
13
``
`-
Commands for Kees Blom's railroad program
`
14
``
`-
#diagram:token NAME
`
15
``
`-
#diagram:token NUMBER
`
16
``
`-
#diagram:token STRING
`
17
``
`-
#diagram:token NEWLINE
`
18
``
`-
#diagram:token ENDMARKER
`
19
``
`-
#diagram:token INDENT
`
20
``
`-
#diagram:output\input python.bla
`
21
``
`-
#diagram:token DEDENT
`
22
``
`-
#diagram:output\textwidth 20.04cm\oddsidemargin 0.0cm\evensidemargin 0.0cm
`
23
``
`-
#diagram:rules
`
``
3
`+
NOTE WELL: You should also follow all the steps listed at
`
``
4
`+
https://devguide.python.org/grammar/
`
24
5
``
25
6
`# Start symbols for the grammar:
`
26
7
`# file_input is a module or sequence of commands read from an input file;
`
`@@ -38,13 +19,13 @@ async_funcdef: 'async' funcdef
`
38
19
`funcdef: 'def' NAME parameters ['->' test] ':' suite
`
39
20
`parameters: '(' [typedargslist] ')'
`
40
21
`typedargslist: ((tfpdef ['=' test] ',')*
`
41
``
`-
('' [tname] (',' tname ['=' test]) [',' '' tname] | '' tname)
`
``
22
`+
('' [tname] (',' tname ['=' test]) [',' ['' tname [',']]] | '' tname [','])
`
42
23
` | tfpdef ['=' test] (',' tfpdef ['=' test])* [','])
`
43
24
`tname: NAME [':' test]
`
44
25
`tfpdef: tname | '(' tfplist ')'
`
45
26
`tfplist: tfpdef (',' tfpdef)* [',']
`
46
27
`varargslist: ((vfpdef ['=' test] ',')*
`
47
``
`-
('' [vname] (',' vname ['=' test]) [',' '' vname] | '' vname)
`
``
28
`+
('' [vname] (',' vname ['=' test]) [',' ['' vname [',']]] | '' vname [','])
`
48
29
` | vfpdef ['=' test] (',' vfpdef ['=' test])* [','])
`
49
30
`vname: NAME
`
50
31
`vfpdef: vname | '(' vfplist ')'
`