diff Include/Python-ast.h @ 36666:6165927431d6 legacy-trunk

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 ;)
author Thomas Wouters <thomas@python.org>
date Mon, 27 Feb 2006 00:24:13 +0000
parents 3c0b26113df6
children b6d2f6fd3e11
line wrap: on
line diff
--- a/Include/Python-ast.h	Mon Feb 27 00:09:50 2006 +0000
+++ b/Include/Python-ast.h	Mon Feb 27 00:24:13 2006 +0000
@@ -175,10 +175,10 @@
 
 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 @@
                 } Lambda;
                 
                 struct {
+                        expr_ty test;
+                        expr_ty body;
+                        expr_ty orelse;
+                } IfExp;
+                
+                struct {
                         asdl_seq *keys;
                         asdl_seq *values;
                 } Dict;
@@ -371,6 +377,8 @@
               *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);