Skip to content

Commit

Permalink
Improve async with for syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
evhub committed May 28, 2023
1 parent aaf6925 commit 9d7d11c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions coconut/compiler/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2132,8 +2132,8 @@ class Grammar(object):
| labeled_group(
(any_len_perm(
keyword("match"),
required=(keyword("async"),)
) + keyword("with") + keyword("for")).suppress()
required=(keyword("async"), keyword("with")),
) + keyword("for")).suppress()
+ many_match + keyword("in").suppress()
- test
- suite_with_else_tokens,
Expand Down
6 changes: 6 additions & 0 deletions coconut/tests/src/cocotest/target_35/py35_test.coco
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ def py35_test() -> bool:
got.append(i)
assert got == range(5) |> list

# with for match syntax 4
got = []
async with match for int(i) in aclosing(arange(5)):
got.append(i)
assert got == range(5) |> list

return True
loop.run_until_complete(afor_test())

Expand Down

0 comments on commit 9d7d11c

Please sign in to comment.