From 7f47d4204039258cec78c767f489b7809b4257ff Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 17 Nov 2018 14:38:05 -0800 Subject: In-progress (but working) overhaul of some elements including: function calls, lib/thing.nom API, multi-assignments, varargs, etc. --- nomsu.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'nomsu.lua') diff --git a/nomsu.lua b/nomsu.lua index 4cbaf7c..b4e031b 100644 --- a/nomsu.lua +++ b/nomsu.lua @@ -202,12 +202,12 @@ run = function() for chunk_no, chunk in ipairs(tree) do local lua = nomsu_environment.compile(chunk) lua:declare_locals() - nomsu_environment.run_1_in(chunk, nomsu_environment) - output:write((chunk_no > 1) and '\n' or '', "-- File " .. tostring(filename) .. " chunk #" .. tostring(chunk_no) .. "\n") - output:write(tostring(lua), "\n") + lua:prepend((chunk_no > 1) and '\n' or '', "-- File " .. tostring(filename) .. " chunk #" .. tostring(chunk_no) .. "\n") if args.verbose then - print(tostring(lua)) + print(lua:text()) end + nomsu_environment.run_1_in(chunk, nomsu_environment) + output:write(lua:text(), "\n") end print(("Compiled %-25s -> %s"):format(filename, filename:gsub("%.nom$", ".lua"))) output:close() @@ -221,12 +221,12 @@ run = function() tree } end - for _index_1 = 1, #tree do - local chunk = tree[_index_1] + for chunk_no, chunk in ipairs(tree) do local lua = nomsu_environment.compile(chunk) lua:declare_locals() - nomsu_environment.run_1_in(chunk, nomsu_environment) - print(tostring(lua)) + lua:prepend((chunk_no > 1) and '\n' or '', "-- File " .. tostring(filename) .. " chunk #" .. tostring(chunk_no) .. "\n") + print(lua:text()) + nomsu_environment.run_1_in(lua, nomsu_environment) end else nomsu_environment.run_file_1_in(filename, nomsu_environment, 0) -- cgit v1.2.3