summaryrefslogtreecommitdiff
path: root/Grammar
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2006-02-27 22:32:47 +0000
committerGuido van Rossum <guido@python.org>2006-02-27 22:32:47 +0000
commitc2e20744b2b7811632030470971c31630f0975e2 (patch)
treee97b1c1471fd00e4e5648ed317274c1d9005d2ca /Grammar
parent5fec904f84a40005f824abe295525a1710056be0 (diff)
downloadcpython-git-c2e20744b2b7811632030470971c31630f0975e2.tar.gz
PEP 343 -- the with-statement.
This was started by Mike Bland and completed by Guido (with help from Neal). This still needs a __future__ statement added; Thomas is working on Michael's patch for that aspect. There's a small amount of code cleanup and refactoring in ast.c, compile.c and ceval.c (I fixed the lltrace behavior when EXT_POP is used -- however I had to make lltrace a static global).
Diffstat (limited to 'Grammar')
-rw-r--r--Grammar/Grammar4
1 files changed, 3 insertions, 1 deletions
diff --git a/Grammar/Grammar b/Grammar/Grammar
index b11f33e052..fd274fa2ac 100644
--- a/Grammar/Grammar
+++ b/Grammar/Grammar
@@ -70,7 +70,7 @@ global_stmt: 'global' NAME (',' NAME)*
exec_stmt: 'exec' expr ['in' test [',' test]]
assert_stmt: 'assert' test [',' test]
-compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef
+compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef
if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
while_stmt: 'while' test ':' suite ['else' ':' suite]
for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
@@ -79,6 +79,8 @@ try_stmt: ('try' ':' suite
['else' ':' suite]
['finally' ':' suite] |
'finally' ':' suite))
+with_stmt: 'with' test [ with_var ] ':' suite
+with_var: NAME expr
# NB compile.c makes sure that the default except clause is last
except_clause: 'except' [test [',' test]]
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT