diff options
author | Alexandre Vassalotti <alexandre@peadrop.com> | 2010-01-11 22:36:12 (GMT) |
---|---|---|
committer | Alexandre Vassalotti <alexandre@peadrop.com> | 2010-01-11 22:36:12 (GMT) |
commit | b646547bb45fe1df6abefd94f892c633798d91d2 (patch) | |
tree | ef1add045741d309129266726f5ba45562184091 /Include | |
parent | 0ca7452794bef03b66f56cc996a73cac066d0ec1 (diff) | |
download | cpython-b646547bb45fe1df6abefd94f892c633798d91d2.zip cpython-b646547bb45fe1df6abefd94f892c633798d91d2.tar.gz cpython-b646547bb45fe1df6abefd94f892c633798d91d2.tar.bz2 |
Issue #2333: Backport set and dict comprehensions syntax.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/Python-ast.h | 25 | ||||
-rw-r--r-- | Include/graminit.h | 8 | ||||
-rw-r--r-- | Include/opcode.h | 3 | ||||
-rw-r--r-- | Include/symtable.h | 1 |
4 files changed, 29 insertions, 8 deletions
diff --git a/Include/Python-ast.h b/Include/Python-ast.h index f50fb22..3f35bbb 100644 --- a/Include/Python-ast.h +++ b/Include/Python-ast.h @@ -186,10 +186,10 @@ struct _stmt { enum _expr_kind {BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4, IfExp_kind=5, Dict_kind=6, Set_kind=7, ListComp_kind=8, - GeneratorExp_kind=9, Yield_kind=10, Compare_kind=11, - Call_kind=12, Repr_kind=13, Num_kind=14, Str_kind=15, - Attribute_kind=16, Subscript_kind=17, Name_kind=18, - List_kind=19, Tuple_kind=20}; + SetComp_kind=9, DictComp_kind=10, GeneratorExp_kind=11, + Yield_kind=12, Compare_kind=13, Call_kind=14, Repr_kind=15, + Num_kind=16, Str_kind=17, Attribute_kind=18, + Subscript_kind=19, Name_kind=20, List_kind=21, Tuple_kind=22}; struct _expr { enum _expr_kind kind; union { @@ -237,6 +237,17 @@ struct _expr { struct { expr_ty elt; asdl_seq *generators; + } SetComp; + + struct { + expr_ty key; + expr_ty value; + asdl_seq *generators; + } DictComp; + + struct { + expr_ty elt; + asdl_seq *generators; } GeneratorExp; struct { @@ -458,6 +469,12 @@ expr_ty _Py_Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena); #define ListComp(a0, a1, a2, a3, a4) _Py_ListComp(a0, a1, a2, a3, a4) expr_ty _Py_ListComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, PyArena *arena); +#define SetComp(a0, a1, a2, a3, a4) _Py_SetComp(a0, a1, a2, a3, a4) +expr_ty _Py_SetComp(expr_ty elt, asdl_seq * generators, int lineno, int + col_offset, PyArena *arena); +#define DictComp(a0, a1, a2, a3, a4, a5) _Py_DictComp(a0, a1, a2, a3, a4, a5) +expr_ty _Py_DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int + lineno, int col_offset, PyArena *arena); #define GeneratorExp(a0, a1, a2, a3, a4) _Py_GeneratorExp(a0, a1, a2, a3, a4) expr_ty _Py_GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, PyArena *arena); diff --git a/Include/graminit.h b/Include/graminit.h index fdc6481..ce597d9 100644 --- a/Include/graminit.h +++ b/Include/graminit.h @@ -64,7 +64,7 @@ #define power 317 #define atom 318 #define listmaker 319 -#define testlist_gexp 320 +#define testlist_comp 320 #define lambdef 321 #define trailer 322 #define subscriptlist 323 @@ -80,9 +80,9 @@ #define list_iter 333 #define list_for 334 #define list_if 335 -#define gen_iter 336 -#define gen_for 337 -#define gen_if 338 +#define comp_iter 336 +#define comp_for 337 +#define comp_if 338 #define testlist1 339 #define encoding_decl 340 #define yield_expr 341 diff --git a/Include/opcode.h b/Include/opcode.h index 3824f7f..9764109 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -147,6 +147,9 @@ extern "C" { /* Support for opargs more than 16 bits long */ #define EXTENDED_ARG 145 +#define SET_ADD 146 +#define MAP_ADD 147 + enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py_LE, PyCmp_EQ=Py_EQ, PyCmp_NE=Py_NE, PyCmp_GT=Py_GT, PyCmp_GE=Py_GE, PyCmp_IN, PyCmp_NOT_IN, PyCmp_IS, PyCmp_IS_NOT, PyCmp_EXC_MATCH, PyCmp_BAD}; diff --git a/Include/symtable.h b/Include/symtable.h index a5f7652..081fd3b 100644 --- a/Include/symtable.h +++ b/Include/symtable.h @@ -42,6 +42,7 @@ typedef struct _symtable_entry { an argument */ int ste_lineno; /* first line of block */ int ste_opt_lineno; /* lineno of last exec or import * */ + int ste_tmpname; /* counter for listcomp temp vars */ struct symtable *ste_table; } PySTEntryObject; |