diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-06-14 23:25:05 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-06-14 23:25:34 -0700 |
| commit | b12744d831c4158671fc22401590eaac00f7c141 (patch) | |
| tree | 203b80de68d89c7333172337f8def46ba11294d3 /core/control_flow.nom | |
| parent | 49f1eb3d08caf7605046373b7b3a001f28aa8aab (diff) | |
Some cleanup and fixes. Simplifying a lot of code, and extending the
flexibility of scoping. Redesigned Object system too.
Diffstat (limited to 'core/control_flow.nom')
| -rw-r--r-- | core/control_flow.nom | 59 |
1 files changed, 2 insertions, 57 deletions
diff --git a/core/control_flow.nom b/core/control_flow.nom index e760b00..15c1ca1 100644 --- a/core/control_flow.nom +++ b/core/control_flow.nom @@ -359,51 +359,6 @@ immediately end --when % = ? return %code -# Try/except -immediately - compile [..] - try %action and if it succeeds %success or if it barfs %msg %fallback - try %action and if it barfs %msg %fallback or if it succeeds %success - ..to - Lua ".." - do - local fell_through = false - local err, erred = nil, false - local ok, ret = xpcall(function() - \(%action as lua statements) - fell_through = true - end, function(\(%msg as lua expr)) - local ok, ret = pcall(function() - \(%fallback as lua statements) - end) - if not ok then err, erred = ret, true end - end) - if ok then - \(%success as lua statements) - if not fell_through then - return ret - end - elseif erred then - error(err, 0) - end - end -immediately - parse [..] - try %action and if it succeeds %success or if it barfs %fallback - try %action and if it barfs %fallback or if it succeeds %success - ..as: try %action and if it succeeds %success or if it barfs (=lua "") %fallback -immediately - parse [try %action] as - try %action and if it succeeds: do nothing - ..or if it barfs: do nothing - parse [try %action and if it barfs %fallback] as - try %action and if it succeeds: do nothing - ..or if it barfs %fallback - parse [try %action and if it barfs %msg %fallback] as - try %action and if it succeeds: do nothing - ..or if it barfs %msg %fallback - parse [try %action and if it succeeds %success] as - try %action and if it succeeds %success or if it barfs: do nothing # Do/finally immediately @@ -433,17 +388,7 @@ immediately declare locals in %body return Lua value ".." - ((function() + (function() \%body - end)()) + end)() -# Coroutines: -immediately - compile [values %body, coroutine %body, generator %body] to - Lua value ".." - (function() - \(%body as lua statements) - end) - compile [->] to: Lua "coroutine.yield(true);" - compile [-> %] to: Lua "coroutine.yield(true, \(% as lua expr));" - compile [-> %k = %v] to: Lua "coroutine.yield(\(%k as lua expr), \(%v as lua expr));" |
