summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2006-02-27 22:32:47 (GMT)
committerGuido van Rossum <guido@python.org>2006-02-27 22:32:47 (GMT)
commitc2e20744b2b7811632030470971c31630f0975e2 (patch)
treee97b1c1471fd00e4e5648ed317274c1d9005d2ca /Include
parent5fec904f84a40005f824abe295525a1710056be0 (diff)
downloadcpython-c2e20744b2b7811632030470971c31630f0975e2.zip
cpython-c2e20744b2b7811632030470971c31630f0975e2.tar.gz
cpython-c2e20744b2b7811632030470971c31630f0975e2.tar.bz2
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 'Include')
-rw-r--r--Include/Python-ast.h18
-rw-r--r--Include/graminit.h86
-rw-r--r--Include/opcode.h3
3 files changed, 58 insertions, 49 deletions
diff --git a/Include/Python-ast.h b/Include/Python-ast.h
index 2059b3c..3c5677c 100644
--- a/Include/Python-ast.h
+++ b/Include/Python-ast.h
@@ -61,11 +61,11 @@ struct _mod {
struct _stmt {
enum { FunctionDef_kind=1, ClassDef_kind=2, Return_kind=3,
Delete_kind=4, Assign_kind=5, AugAssign_kind=6, Print_kind=7,
- For_kind=8, While_kind=9, If_kind=10, Raise_kind=11,
- TryExcept_kind=12, TryFinally_kind=13, Assert_kind=14,
- Import_kind=15, ImportFrom_kind=16, Exec_kind=17,
- Global_kind=18, Expr_kind=19, Pass_kind=20, Break_kind=21,
- Continue_kind=22 } kind;
+ For_kind=8, While_kind=9, If_kind=10, With_kind=11,
+ Raise_kind=12, TryExcept_kind=13, TryFinally_kind=14,
+ Assert_kind=15, Import_kind=16, ImportFrom_kind=17,
+ Exec_kind=18, Global_kind=19, Expr_kind=20, Pass_kind=21,
+ Break_kind=22, Continue_kind=23 } kind;
union {
struct {
identifier name;
@@ -125,6 +125,12 @@ struct _stmt {
} If;
struct {
+ expr_ty context_expr;
+ expr_ty optional_vars;
+ asdl_seq *body;
+ } With;
+
+ struct {
expr_ty type;
expr_ty inst;
expr_ty tback;
@@ -355,6 +361,8 @@ stmt_ty While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno,
PyArena *arena);
stmt_ty If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno,
PyArena *arena);
+stmt_ty With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body, int
+ lineno, PyArena *arena);
stmt_ty Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, PyArena
*arena);
stmt_ty TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, int
diff --git a/Include/graminit.h b/Include/graminit.h
index e804734..9af182a 100644
--- a/Include/graminit.h
+++ b/Include/graminit.h
@@ -38,45 +38,47 @@
#define while_stmt 293
#define for_stmt 294
#define try_stmt 295
-#define except_clause 296
-#define suite 297
-#define testlist_safe 298
-#define old_test 299
-#define old_lambdef 300
-#define test 301
-#define or_test 302
-#define and_test 303
-#define not_test 304
-#define comparison 305
-#define comp_op 306
-#define expr 307
-#define xor_expr 308
-#define and_expr 309
-#define shift_expr 310
-#define arith_expr 311
-#define term 312
-#define factor 313
-#define power 314
-#define atom 315
-#define listmaker 316
-#define testlist_gexp 317
-#define lambdef 318
-#define trailer 319
-#define subscriptlist 320
-#define subscript 321
-#define sliceop 322
-#define exprlist 323
-#define testlist 324
-#define dictmaker 325
-#define classdef 326
-#define arglist 327
-#define argument 328
-#define list_iter 329
-#define list_for 330
-#define list_if 331
-#define gen_iter 332
-#define gen_for 333
-#define gen_if 334
-#define testlist1 335
-#define encoding_decl 336
-#define yield_expr 337
+#define with_stmt 296
+#define with_var 297
+#define except_clause 298
+#define suite 299
+#define testlist_safe 300
+#define old_test 301
+#define old_lambdef 302
+#define test 303
+#define or_test 304
+#define and_test 305
+#define not_test 306
+#define comparison 307
+#define comp_op 308
+#define expr 309
+#define xor_expr 310
+#define and_expr 311
+#define shift_expr 312
+#define arith_expr 313
+#define term 314
+#define factor 315
+#define power 316
+#define atom 317
+#define listmaker 318
+#define testlist_gexp 319
+#define lambdef 320
+#define trailer 321
+#define subscriptlist 322
+#define subscript 323
+#define sliceop 324
+#define exprlist 325
+#define testlist 326
+#define dictmaker 327
+#define classdef 328
+#define arglist 329
+#define argument 330
+#define list_iter 331
+#define list_for 332
+#define list_if 333
+#define gen_iter 334
+#define gen_for 335
+#define gen_if 336
+#define testlist1 337
+#define encoding_decl 338
+#define yield_expr 339
diff --git a/Include/opcode.h b/Include/opcode.h
index 868512f..d8cb2cd 100644
--- a/Include/opcode.h
+++ b/Include/opcode.h
@@ -72,13 +72,12 @@ extern "C" {
#define INPLACE_XOR 78
#define INPLACE_OR 79
#define BREAK_LOOP 80
-
+#define WITH_CLEANUP 81
#define LOAD_LOCALS 82
#define RETURN_VALUE 83
#define IMPORT_STAR 84
#define EXEC_STMT 85
#define YIELD_VALUE 86
-
#define POP_BLOCK 87
#define END_FINALLY 88
#define BUILD_CLASS 89