From b12744d831c4158671fc22401590eaac00f7c141 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 14 Jun 2018 23:25:05 -0700 Subject: Some cleanup and fixes. Simplifying a lot of code, and extending the flexibility of scoping. Redesigned Object system too. --- core/coroutines.nom | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 core/coroutines.nom (limited to 'core/coroutines.nom') 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 -- cgit v1.2.3