aboutsummaryrefslogtreecommitdiff
path: root/core/coroutines.nom
diff options
context:
space:
mode:
Diffstat (limited to 'core/coroutines.nom')
-rw-r--r--core/coroutines.nom33
1 files changed, 16 insertions, 17 deletions
diff --git a/core/coroutines.nom b/core/coroutines.nom
index f34f0c9..9f6f6f4 100644
--- a/core/coroutines.nom
+++ b/core/coroutines.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.12.12.8
+#!/usr/bin/env nomsu -V5.12.12.8
#
This file defines the code that creates and manipulates coroutines
@@ -9,28 +9,27 @@ use "core/control_flow.nom"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test:
- %co = (..)
+ $co = (..)
->:
yield 4
yield 5
repeat 3 times:
yield 6
- %nums = []
- for % in coroutine %co:
- %nums::add %
- assume (%nums == [4, 5, 6, 6, 6]) or barf "Coroutine iteration failed"
- %d = {x: 0}
- %co2 = (..)
+ $nums = []
+ for $ in coroutine $co: $nums|add $
+ assume ($nums == [4, 5, 6, 6, 6]) or barf "Coroutine iteration failed"
+ $d = {x: 0}
+ $co2 = (..)
coroutine:
- %d.x += 1
+ $d.x += 1
yield 1
- %d.x += 1
+ $d.x += 1
yield
- %d.x += 1
- repeat while ((coroutine status of %co2) != "dead"): resume %co2
- assume %d.x == 3
-(coroutine %body) parses as (coroutine from (-> %body))
-(for % in coroutine %co %body) compiles to "\
- ..for \(% as lua expr) in coroutine_wrap(\(%co as lua expr)) do
- \(%body as lua)
+ $d.x += 1
+ repeat while ((coroutine status of $co2) != "dead"): resume $co2
+ assume $d.x == 3
+(coroutine $body) parses as (coroutine from (-> $body))
+(for $ in coroutine $co $body) compiles to "
+ for \($ as lua expr) in coroutine_wrap(\($co as lua expr)) do
+ \($body as lua)
end"