aboutsummaryrefslogtreecommitdiff
path: root/core/control_flow.nom
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-11-02 14:38:24 -0700
committerBruce Hill <bruce@bruce-hill.com>2018-11-02 14:39:23 -0700
commit307dea18815ba4a06a3098edb170d7ad90708815 (patch)
treebce78eb28fa03c9939a92e08e47564afc984c988 /core/control_flow.nom
parentd0c3c57f7b25c8d912c426e48cb5ab09cd738f65 (diff)
Changed stub convention to (foo 1 baz 2) -> foo_1_baz instead of
foo_1_baz_2, removed "smext", made some cleanup changes.
Diffstat (limited to 'core/control_flow.nom')
-rw-r--r--core/control_flow.nom32
1 files changed, 16 insertions, 16 deletions
diff --git a/core/control_flow.nom b/core/control_flow.nom
index 0cabf95..bbc98f1 100644
--- a/core/control_flow.nom
+++ b/core/control_flow.nom
@@ -102,8 +102,20 @@ test:
.."
# Basic loop control
-(do next) compiles to (Lua "goto continue")
-(stop) compiles to (Lua "break")
+(stop %var) compiles to:
+ if %var:
+ return (..)
+ Lua "goto stop_\((%var.stub if (%var.type == "action") else %var) as lua identifier)"
+ ..else: return (Lua "break")
+(do next %var) compiles to:
+ if %var:
+ return (..)
+ Lua "goto continue_\((%var.stub if (%var.type == "action") else %var) as lua identifier)"
+ ..else: return (Lua "goto continue")
+[===stop %var ===, ---stop %var ---, ***stop %var ***] all compile to (..)
+ Lua "::stop_\((%var.stub if (%var.type == "action") else %var) as lua identifier)::"
+[===next %var ===, ---next %var ---, ***next %var ***] all compile to (..)
+ Lua "::continue_\((%var.stub if (%var.type == "action") else %var) as lua identifier)::"
# While loops
test:
@@ -177,16 +189,6 @@ test:
return %lua
-# For loop control flow
-(stop %var) compiles to (..)
- Lua "goto stop_\((%var.stub if (%var.type == "Action") else %var) as lua identifier)"
-(do next %var) compiles to (..)
- Lua "goto continue_\((%var.stub if (%var.type == "Action") else %var) as lua identifier)"
-[===stop %var ===, ---stop %var ---, ***stop %var ***] all compile to (..)
- Lua "::stop_\((%var.stub if (%var.type == "Action") else %var) as lua identifier)::"
-[===next %var ===, ---next %var ---, ***next %var ***] all compile to (..)
- Lua "::continue_\((%var.stub if (%var.type == "Action") else %var) as lua identifier)::"
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test:
@@ -365,7 +367,7 @@ test:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test:
- if:
+ when:
(1 == 2) (100 < 0):
barf "bad conditional"
(1 == 0) (1 == 1) %not_a_variable.x: do nothing
@@ -377,7 +379,7 @@ test:
barf "bad conditional"
# Multi-branch conditional (if..elseif..else)
-[if %body, when %body] all compile to:
+(when %body) compiles to:
%code = (Lua "")
%clause = "if"
%else_allowed = (yes)
@@ -512,8 +514,6 @@ test:
%d.x = "bad"
barf
..then always: %d.x = "good"
- ..and if it barfs: do nothing
-
assume (%d.x == "good")
(do %action then always %final_action) compiles to:
define mangler