From 86a3219e7fc3244331595819f742b365172f96ad Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 21 Jun 2018 19:12:59 -0700 Subject: 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. --- core/control_flow.nom | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'core/control_flow.nom') 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 === + -- cgit v1.2.3