aboutsummaryrefslogtreecommitdiff
path: root/core/coroutines.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-06-14 23:25:05 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-06-14 23:25:34 -0700
commitb12744d831c4158671fc22401590eaac00f7c141 (patch)
tree203b80de68d89c7333172337f8def46ba11294d3 /core/coroutines.nom
parent49f1eb3d08caf7605046373b7b3a001f28aa8aab (diff)
Some cleanup and fixes. Simplifying a lot of code, and extending the
flexibility of scoping. Redesigned Object system too.
Diffstat (limited to 'core/coroutines.nom')
-rw-r--r--core/coroutines.nom17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/coroutines.nom b/core/coroutines.nom
new file mode 100644
index 0000000..d0d9c36
--- /dev/null
+++ b/core/coroutines.nom
@@ -0,0 +1,17 @@
+#
+ This file defines the code that creates and manipulates coroutines
+
+use "core/metaprogramming.nom"
+
+compile [coroutine %body, generator %body] to
+ Lua value ".."
+ (function()
+ \(%body as lua statements)
+ end)
+compile [->] to: Lua value "coroutine.yield(true)"
+compile [-> %] to: Lua value "coroutine.yield(true, \(% as lua expr))"
+compile [for % in coroutine %co %body] to
+ Lua ".."
+ for junk,\(% as lua expr) in coroutine.wrap(\(%co as lua expr)) do
+ \(%body as lua statements)
+ end