mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
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 ;)
This commit is contained in:
parent
d3a5f53a27
commit
dca3b9c797
11 changed files with 878 additions and 642 deletions
|
@ -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;
|
||||
|
@ -201,6 +201,12 @@ struct _expr {
|
|||
expr_ty body;
|
||||
} Lambda;
|
||||
|
||||
struct {
|
||||
expr_ty test;
|
||||
expr_ty body;
|
||||
expr_ty orelse;
|
||||
} IfExp;
|
||||
|
||||
struct {
|
||||
asdl_seq *keys;
|
||||
asdl_seq *values;
|
||||
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue