summaryrefslogtreecommitdiffstats
path: root/Include/Python-ast.h
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2006-02-27 00:24:13 (GMT)
committerThomas Wouters <thomas@python.org>2006-02-27 00:24:13 (GMT)
commitdca3b9c797f6dd4b08d590fa2aa1031e22ab598e (patch)
treed2b7aa53793110100965906b1266296d08bd4ec1 /Include/Python-ast.h
parentd3a5f53a27be821cfdff869fd8ad93a060497e8c (diff)
downloadcpython-dca3b9c797f6dd4b08d590fa2aa1031e22ab598e.zip
cpython-dca3b9c797f6dd4b08d590fa2aa1031e22ab598e.tar.gz
cpython-dca3b9c797f6dd4b08d590fa2aa1031e22ab598e.tar.bz2
PEP 308 implementation, including minor refdocs and some testcases. It
breaks the parser module, because it adds the if/else construct as well as two new grammar rules for backward compatibility. If no one else fixes parsermodule, I guess I'll go ahead and fix it later this week. The TeX code was checked with texcheck.py, but not rendered. There is actually a slight incompatibility: >>> (x for x in lambda:0) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: iteration over non-sequence changes into >>> (x for x in lambda: 0) File "<stdin>", line 1 (x for x in lambda: 0) ^ SyntaxError: invalid syntax Since there's no way the former version can be useful, it's probably a bugfix ;)
Diffstat (limited to 'Include/Python-ast.h')
-rw-r--r--Include/Python-ast.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/Include/Python-ast.h b/Include/Python-ast.h
index 3f07452..2059b3c 100644
--- a/Include/Python-ast.h
+++ b/Include/Python-ast.h
@@ -175,10 +175,10 @@ struct _stmt {
struct _expr {
enum { BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4,
- Dict_kind=5, ListComp_kind=6, GeneratorExp_kind=7, Yield_kind=8,
- Compare_kind=9, Call_kind=10, Repr_kind=11, Num_kind=12,
- Str_kind=13, Attribute_kind=14, Subscript_kind=15, Name_kind=16,
- List_kind=17, Tuple_kind=18 } kind;
+ IfExp_kind=5, Dict_kind=6, ListComp_kind=7, GeneratorExp_kind=8,
+ Yield_kind=9, Compare_kind=10, Call_kind=11, Repr_kind=12,
+ Num_kind=13, Str_kind=14, Attribute_kind=15, Subscript_kind=16,
+ Name_kind=17, List_kind=18, Tuple_kind=19 } kind;
union {
struct {
boolop_ty op;
@@ -202,6 +202,12 @@ struct _expr {
} Lambda;
struct {
+ expr_ty test;
+ expr_ty body;
+ expr_ty orelse;
+ } IfExp;
+
+ struct {
asdl_seq *keys;
asdl_seq *values;
} Dict;
@@ -371,6 +377,8 @@ expr_ty BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, PyArena
*arena);
expr_ty UnaryOp(unaryop_ty op, expr_ty operand, int lineno, PyArena *arena);
expr_ty Lambda(arguments_ty args, expr_ty body, int lineno, PyArena *arena);
+expr_ty IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, PyArena
+ *arena);
expr_ty Dict(asdl_seq * keys, asdl_seq * values, int lineno, PyArena *arena);
expr_ty ListComp(expr_ty elt, asdl_seq * generators, int lineno, PyArena
*arena);