From 307dea18815ba4a06a3098edb170d7ad90708815 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 2 Nov 2018 14:38:24 -0700 Subject: Changed stub convention to (foo 1 baz 2) -> foo_1_baz instead of foo_1_baz_2, removed "smext", made some cleanup changes. --- core/control_flow.nom | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'core/control_flow.nom') 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 -- cgit v1.2.3