[Python-checkins] r55058 - peps/trunk/pep-3129.txt
collin.winter
python-checkins at python.org
Tue May 1 22:14:29 CEST 2007
Author: collin.winter
Date: Tue May 1 22:14:28 2007
New Revision: 55058
Modified:
peps/trunk/pep-3129.txt
Log:
Fix the grammar in PEP 3129.
Modified: peps/trunk/pep-3129.txt
==============================================================================
--- peps/trunk/pep-3129.txt (original)
+++ peps/trunk/pep-3129.txt Tue May 1 22:14:28 2007
@@ -65,13 +65,25 @@
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
-
-to ::
+ funcdef: [decorators] 'def' NAME parameters ['->' test] ':' suite
+
+ compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt |
+ with_stmt | funcdef | classdef
+
+need to be changed to ::
+
+ decorated: decorators (classdef | funcdef)
+
+ funcdef: 'def' NAME parameters ['->' test] ':' suite
+
+ compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt |
+ with_stmt | funcdef | classdef | decorated
- classdef: [decorators] 'class' NAME ['(' [testlist] ')'] ':' suite
+Adding ``decorated`` is necessary to avoid an ambiguity in the
+grammar.
The Python AST and bytecode must be modified accordingly.
More information about the Python-checkins
mailing list