Fix the grammar in PEP 3129.
This commit is contained in:
parent
204b9762a8
commit
6b77a7f8e2
22
pep-3129.txt
22
pep-3129.txt
|
@ -65,13 +65,25 @@ For a detailed examination of decorators, please refer to PEP 318.
|
||||||
Implementation
|
Implementation
|
||||||
==============
|
==============
|
||||||
|
|
||||||
The grammar for class declarations changes from ::
|
Adapating Python's grammar to support class decorators requires
|
||||||
|
modifying two rules and adding a new rule ::
|
||||||
|
|
||||||
classdef: 'class' NAME ['(' [testlist] ')'] ':' suite
|
funcdef: [decorators] 'def' NAME parameters ['->' test] ':' suite
|
||||||
|
|
||||||
to ::
|
compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt |
|
||||||
|
with_stmt | funcdef | classdef
|
||||||
|
|
||||||
|
need to be changed to ::
|
||||||
|
|
||||||
|
decorated: decorators (classdef | funcdef)
|
||||||
|
|
||||||
classdef: [decorators] 'class' NAME ['(' [testlist] ')'] ':' suite
|
funcdef: 'def' NAME parameters ['->' test] ':' suite
|
||||||
|
|
||||||
|
compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt |
|
||||||
|
with_stmt | funcdef | classdef | decorated
|
||||||
|
|
||||||
|
Adding ``decorated`` is necessary to avoid an ambiguity in the
|
||||||
|
grammar.
|
||||||
|
|
||||||
The Python AST and bytecode must be modified accordingly.
|
The Python AST and bytecode must be modified accordingly.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue