summaryrefslogtreecommitdiffstats
path: root/Include
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
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')
-rw-r--r--Include/Python-ast.h16
-rw-r--r--Include/graminit.h77
2 files changed, 52 insertions, 41 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);
diff --git a/Include/graminit.h b/Include/graminit.h
index 2c855ea..e804734 100644
--- a/Include/graminit.h
+++ b/Include/graminit.h
@@ -40,40 +40,43 @@
#define try_stmt 295
#define except_clause 296
#define suite 297
-#define test 298
-#define and_test 299
-#define not_test 300
-#define comparison 301
-#define comp_op 302
-#define expr 303
-#define xor_expr 304
-#define and_expr 305
-#define shift_expr 306
-#define arith_expr 307
-#define term 308
-#define factor 309
-#define power 310
-#define atom 311
-#define listmaker 312
-#define testlist_gexp 313
-#define lambdef 314
-#define trailer 315
-#define subscriptlist 316
-#define subscript 317
-#define sliceop 318
-#define exprlist 319
-#define testlist 320
-#define testlist_safe 321
-#define dictmaker 322
-#define classdef 323
-#define arglist 324
-#define argument 325
-#define list_iter 326
-#define list_for 327
-#define list_if 328
-#define gen_iter 329
-#define gen_for 330
-#define gen_if 331
-#define testlist1 332
-#define encoding_decl 333
-#define yield_expr 334
+#define testlist_safe 298
+#define old_test 299
+#define old_lambdef 300
+#define test 301
+#define or_test 302
+#define and_test 303
+#define not_test 304
+#define comparison 305
+#define comp_op 306
+#define expr 307
+#define xor_expr 308
+#define and_expr 309
+#define shift_expr 310
+#define arith_expr 311
+#define term 312
+#define factor 313
+#define power 314
+#define atom 315
+#define listmaker 316
+#define testlist_gexp 317
+#define lambdef 318
+#define trailer 319
+#define subscriptlist 320
+#define subscript 321
+#define sliceop 322
+#define exprlist 323
+#define testlist 324
+#define dictmaker 325
+#define classdef 326
+#define arglist 327
+#define argument 328
+#define list_iter 329
+#define list_for 330
+#define list_if 331
+#define gen_iter 332
+#define gen_for 333
+#define gen_if 334
+#define testlist1 335
+#define encoding_decl 336
+#define yield_expr 337