summaryrefslogtreecommitdiffstats
path: root/Include/Python-ast.h
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2007-02-27 06:50:52 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2007-02-27 06:50:52 (GMT)
commit81e9502df69394821416309c7c4b5357af51f4d5 (patch)
treead38831cbebfb32890c0c57cb8b36f653300c69f /Include/Python-ast.h
parent8b41c3dc28a16da97af50cc5f7b884db2cea7b0c (diff)
downloadcpython-81e9502df69394821416309c7c4b5357af51f4d5.zip
cpython-81e9502df69394821416309c7c4b5357af51f4d5.tar.gz
cpython-81e9502df69394821416309c7c4b5357af51f4d5.tar.bz2
Provisional implementation of PEP 3104.
Add nonlocal_stmt to Grammar and Nonlocal node to AST. They both parallel the definitions for globals. The symbol table treats variables declared as nonlocal just like variables that are free implicitly. This change is missing the language spec changes, but makes some decisions about what the spec should say via the unittests. The PEP is silent on a number of decisions, so we should review those before claiming that nonlocal is complete. Thomas Wouters made the grammer and ast changes. Jeremy Hylton added the symbol table changes and the tests. Pete Shinners and Neal Norwitz helped review the code.
Diffstat (limited to 'Include/Python-ast.h')
-rw-r--r--Include/Python-ast.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/Include/Python-ast.h b/Include/Python-ast.h
index 66d7b52..233a576 100644
--- a/Include/Python-ast.h
+++ b/Include/Python-ast.h
@@ -66,7 +66,8 @@ enum _stmt_kind {FunctionDef_kind=1, ClassDef_kind=2, Return_kind=3,
While_kind=8, If_kind=9, With_kind=10, Raise_kind=11,
TryExcept_kind=12, TryFinally_kind=13, Assert_kind=14,
Import_kind=15, ImportFrom_kind=16, Global_kind=17,
- Expr_kind=18, Pass_kind=19, Break_kind=20, Continue_kind=21};
+ Nonlocal_kind=18, Expr_kind=19, Pass_kind=20, Break_kind=21,
+ Continue_kind=22};
struct _stmt {
enum _stmt_kind kind;
union {
@@ -165,6 +166,10 @@ struct _stmt {
} Global;
struct {
+ asdl_seq *names;
+ } Nonlocal;
+
+ struct {
expr_ty value;
} Expr;
@@ -422,6 +427,9 @@ stmt_ty _Py_ImportFrom(identifier module, asdl_seq * names, int level, int
#define Global(a0, a1, a2, a3) _Py_Global(a0, a1, a2, a3)
stmt_ty _Py_Global(asdl_seq * names, int lineno, int col_offset, PyArena
*arena);
+#define Nonlocal(a0, a1, a2, a3) _Py_Nonlocal(a0, a1, a2, a3)
+stmt_ty _Py_Nonlocal(asdl_seq * names, int lineno, int col_offset, PyArena
+ *arena);
#define Expr(a0, a1, a2, a3) _Py_Expr(a0, a1, a2, a3)
stmt_ty _Py_Expr(expr_ty value, int lineno, int col_offset, PyArena *arena);
#define Pass(a0, a1, a2) _Py_Pass(a0, a1, a2)