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