diff Include/Python-ast.h @ 36695:b6d2f6fd3e11 legacy-trunk

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).
author Guido van Rossum <guido@python.org>
date Mon, 27 Feb 2006 22:32:47 +0000
parents 6165927431d6
children 5c36c222e7ca
line wrap: on
line diff
--- a/Include/Python-ast.h	Mon Feb 27 21:41:03 2006 +0000
+++ b/Include/Python-ast.h	Mon Feb 27 22:32:47 2006 +0000
@@ -61,11 +61,11 @@
 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 @@
                 } 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 @@
               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