From dc8851aa14eda793a45316e5c52a616662e46d51 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Wed, 8 Mar 2023 07:48:39 -0700 Subject: [PATCH] AsyncEmbeddedScript allow multiple commands in one block --- kiss/src/kiss/AsyncEmbeddedScript.hx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/kiss/src/kiss/AsyncEmbeddedScript.hx b/kiss/src/kiss/AsyncEmbeddedScript.hx index c3714930..0736eb3c 100644 --- a/kiss/src/kiss/AsyncEmbeddedScript.hx +++ b/kiss/src/kiss/AsyncEmbeddedScript.hx @@ -176,7 +176,20 @@ class AsyncEmbeddedScript { #if profileKiss Kiss.measure('Compiling kiss: $scriptFile', () -> { #end - Reader.readAndProcess(Stream.fromFile(scriptFile), k, (nextExp) -> { + function process(nextExp) { + nextExp = Kiss.macroExpand(nextExp, k); + + // Allow packing multiple commands into one exp with a (commands <...>) statement + switch (nextExp.def) { + case CallExp({pos: _, def: Symbol("commands")}, + commands): + for (exp in commands) { + process(exp); + } + return; + default: + } + var exprString = Reader.toString(nextExp.def); var expr = Kiss.readerExpToHaxeExpr(nextExp, k); if (Kiss.isEmpty(expr)) @@ -194,7 +207,8 @@ class AsyncEmbeddedScript { // This return is essential for type unification of concat() and push() above... ugh. return; - }); + } + Reader.readAndProcess(Stream.fromFile(scriptFile), k, process); null; #if profileKiss });