From f58dc0fcb7979ae9f67ab3b5daebc8c4a4d652ca Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 5 Feb 2018 15:09:44 -0800 Subject: [PATCH] Reverted "use %" to expr-like behavior with return values preserved. --- nomsu.lua | 6 ++++-- nomsu.moon | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/nomsu.lua b/nomsu.lua index b1f49d0..94eec80 100644 --- a/nomsu.lua +++ b/nomsu.lua @@ -1352,13 +1352,15 @@ do } end) self:define_action("run file %filename", get_line_no(), function(_filename) - return nomsu:run_file(_filename) + return { + expr = "nomsu:run_file(" .. tostring(nomsu:tree_to_lua(filename).expr) .. ")" + } end) return self:define_compile_action("use %filename", get_line_no(), function(_filename) local filename = nomsu:tree_to_value(_filename) nomsu:require_file(filename) return { - statements = "nomsu:require_file(" .. tostring(repr(filename)) .. ");" + expr = "nomsu:require_file(" .. tostring(repr(filename)) .. ");" } end) end diff --git a/nomsu.moon b/nomsu.moon index a214857..cb2efdd 100755 --- a/nomsu.moon +++ b/nomsu.moon @@ -929,12 +929,12 @@ class NomsuCompiler return expr: repr("#{tree.filename}:#{tree.start},#{tree.stop}") @define_action "run file %filename", get_line_no!, (_filename)-> - nomsu\run_file(_filename) + return expr:"nomsu:run_file(#{nomsu\tree_to_lua(filename).expr})" @define_compile_action "use %filename", get_line_no!, (_filename)-> filename = nomsu\tree_to_value(_filename) nomsu\require_file(filename) - return statements:"nomsu:require_file(#{repr filename});" + return expr:"nomsu:require_file(#{repr filename});" -- Only run this code if this file was run directly with command line arguments, and not require()'d: if arg and debug.getinfo(2).func != require