aboutsummaryrefslogtreecommitdiff
path: root/core/control_flow.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-06-21 19:12:59 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-06-21 19:13:47 -0700
commit86a3219e7fc3244331595819f742b365172f96ad (patch)
tree948a3f308bd9c45b85efa2e130af8432bb1a97e2 /core/control_flow.nom
parent7761f715f7497e8b325a4f1134869f332848fd16 (diff)
Cleanup of some metaprogramming stuff, as well as adding support for
"package.nomsupath" to search for files in different locations, and prioritizing use of "luafilesystem" over system calls.
Diffstat (limited to 'core/control_flow.nom')
-rw-r--r--core/control_flow.nom15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/control_flow.nom b/core/control_flow.nom
index 9aae937..0cc8f4e 100644
--- a/core/control_flow.nom
+++ b/core/control_flow.nom
@@ -383,3 +383,18 @@ compile [do %action then always %final_action] to
# Inline thunk:
compile [result of %body] to
Lua value "(\(compile as: [] -> %body))()"
+
+# Recurion control flow
+using
+ compile [%var's stack] to: Lua value "stack\(%var as lua id)"
+..compile
+ parse [for %var in recursive %structure %body] as
+ with local {(%var's stack): [%structure], action: recurse % on %}
+ action [recurse %v on %x]
+ add %x to (%v's stack)
+ repeat while: (length of (%var's stack)) > 0
+ %var <- (remove 1 from (%var's stack))
+ %body
+ === next %var ==
+ === stop %var ===
+