aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2017-10-31 18:35:40 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2017-10-31 18:35:40 -0700
commitb0072e6dcf3525365977cd4ba9f4f19c745fa16e (patch)
tree776d577bb7053235839652a53261d315f0e8fb1f
parent6ba79a8ff1015c3d2b5c28bc61c27275f5abc2af (diff)
Added local var persistence for REPL.
-rw-r--r--nomsu.lua3
-rwxr-xr-xnomsu.moon3
2 files changed, 4 insertions, 2 deletions
diff --git a/nomsu.lua b/nomsu.lua
index 055c8a2..da0c699 100644
--- a/nomsu.lua
+++ b/nomsu.lua
@@ -1188,6 +1188,7 @@ if arg then
end
end
if args.flags["-i"] then
+ local vars = { }
c:run('require "lib/core.nom"', "stdin")
while true do
local buff = ""
@@ -1203,7 +1204,7 @@ if arg then
break
end
local ok, ret = pcall(function()
- return c:run(buff, "stdin")
+ return c:run(buff, "stdin", vars)
end)
if ok and ret ~= nil then
print("= " .. repr(ret))
diff --git a/nomsu.moon b/nomsu.moon
index 90b017c..eb376fc 100755
--- a/nomsu.moon
+++ b/nomsu.moon
@@ -810,6 +810,7 @@ if arg
if args.flags["-i"]
-- REPL
+ vars = {}
c\run('require "lib/core.nom"', "stdin")
while true
buff = ""
@@ -821,7 +822,7 @@ if arg
buff ..= line
if #buff == 0
break
- ok, ret = pcall(-> c\run(buff, "stdin"))
+ ok, ret = pcall(-> c\run(buff, "stdin", vars))
if ok and ret != nil
print "= "..repr(ret)