| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 93b2dee commit 52c4e7c
20 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -146,7 +146,7 @@ argument: ( test [comp_for] | | |||
| 146 | 146 | '*' test ) | |
| 147 | 147 | ||
| 148 | 148 | comp_iter: comp_for | comp_if | |
| 149 | - comp_for: 'for' exprlist 'in' or_test [comp_iter] | ||
| 149 | + comp_for: [ASYNC] 'for' exprlist 'in' or_test [comp_iter] | ||
| 150 | 150 | comp_if: 'if' test_nocond [comp_iter] | |
| 151 | 151 | ||
| 152 | 152 | # not used in grammar, but may appear in "node" passed from Parser to Compiler | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -389,6 +389,7 @@ struct _comprehension { | |||
| 389 | 389 | expr_ty target; | |
| 390 | 390 | expr_ty iter; | |
| 391 | 391 | asdl_seq *ifs; | |
| 392 | + int is_async; | ||
| 392 | 393 | }; | |
| 393 | 394 | ||
| 394 | 395 | enum _excepthandler_kind {ExceptHandler_kind=1}; | |
@@ -609,9 +610,9 @@ slice_ty _Py_Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena); | |||
| 609 | 610 | slice_ty _Py_ExtSlice(asdl_seq * dims, PyArena *arena); | |
| 610 | 611 | #define Index(a0, a1) _Py_Index(a0, a1) | |
| 611 | 612 | slice_ty _Py_Index(expr_ty value, PyArena *arena); | |
| 612 | - #define comprehension(a0, a1, a2, a3) _Py_comprehension(a0, a1, a2, a3) | ||
| 613 | + #define comprehension(a0, a1, a2, a3, a4) _Py_comprehension(a0, a1, a2, a3, a4) | ||
| 613 | 614 | comprehension_ty _Py_comprehension(expr_ty target, expr_ty iter, asdl_seq * | |
| 614 | - ifs, PyArena *arena); | ||
| 615 | + ifs, int is_async, PyArena *arena); | ||
| 615 | 616 | #define ExceptHandler(a0, a1, a2, a3, a4, a5) _Py_ExceptHandler(a0, a1, a2, a3, a4, a5) | |
| 616 | 617 | excepthandler_ty _Py_ExceptHandler(expr_ty type, identifier name, asdl_seq * | |
| 617 | 618 | body, int lineno, int col_offset, PyArena | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -150,7 +150,7 @@ arglist: (argument ',')* (argument [','] | |||
| 150 | 150 | argument: test [comp_for] | test '=' test # Really [keyword '='] test | |
| 151 | 151 | ||
| 152 | 152 | comp_iter: comp_for | comp_if | |
| 153 | - comp_for: 'for' exprlist 'in' testlist_safe [comp_iter] | ||
| 153 | + comp_for: [ASYNC] 'for' exprlist 'in' testlist_safe [comp_iter] | ||
| 154 | 154 | comp_if: 'if' old_test [comp_iter] | |
| 155 | 155 | ||
| 156 | 156 | testlist1: test (',' test)* | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -133,6 +133,24 @@ def test_await_expr(self): | |||
| 133 | 133 | await x | |
| 134 | 134 | """) | |
| 135 | 135 | ||
| 136 | + self.validate("""async def foo(): | ||
| 137 | + [i async for i in b] | ||
| 138 | + """) | ||
| 139 | + | ||
| 140 | + self.validate("""async def foo(): | ||
| 141 | + {i for i in b | ||
| 142 | + async for i in a if await i | ||
| 143 | + for b in i} | ||
| 144 | + """) | ||
| 145 | + | ||
| 146 | + self.validate("""async def foo(): | ||
| 147 | + [await i for i in b if await c] | ||
| 148 | + """) | ||
| 149 | + | ||
| 150 | + self.validate("""async def foo(): | ||
| 151 | + [ i for i in b if c] | ||
| 152 | + """) | ||
| 153 | + | ||
| 136 | 154 | self.validate("""async def foo(): | |
| 137 | 155 | ||
| 138 | 156 | def foo(): pass | |
| Back | FazBrowse Home | New Git URL |
0 commit comments