about summary refs log tree commit diff stats
path: root/lua/chupacabra/repl.lua
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2024-06-09 18:27:26 -0400
committerelioat <elioat@tilde.institute>2024-06-09 18:27:26 -0400
commit48f7b2508802e031e883ecbdb802d19c807af0e2 (patch)
treec733dd044501e97934ff9570f2b7e852a081d7bd /lua/chupacabra/repl.lua
parent4dee1f562de247cb202362ab276303b0dc717453 (diff)
downloadtour-48f7b2508802e031e883ecbdb802d19c807af0e2.tar.gz
*
Diffstat (limited to 'lua/chupacabra/repl.lua')
-rw-r--r--lua/chupacabra/repl.lua36
1 files changed, 22 insertions, 14 deletions
diff --git a/lua/chupacabra/repl.lua b/lua/chupacabra/repl.lua
index 302f306..990d62a 100644
--- a/lua/chupacabra/repl.lua
+++ b/lua/chupacabra/repl.lua
@@ -1,21 +1,29 @@
-local chupacabra = require("chupacabra") 
+local chupacabra = require("chupacabra")
 
--- simple repl to interact with chupacabra
+-- FIXME: this is dog water and doesn't work...at all
+
+local function table_to_string(t)
+    local str = "{"
+    for i, v in ipairs(t) do
+        if i > 1 then
+            str = str .. ", "
+        end
+        if type(v) == "table" then
+            str = str .. table_to_string(v)
+        else
+            str = str .. tostring(v)
+        end
+    end
+    str = str .. "}"
+    return str
+end
 
 while true do
-    io.write("chupacabra> ")
+    io.write("> ")
     local input = io.read()
     if input == "exit" then
         break
     end
-    local output = chupacabra.run(input, {})
-    if type(output) == "table" then
-        local outputString = ""
-        for _, value in ipairs(output) do
-            outputString = outputString .. " " .. value -- FIXME: this is dog water
-        end
-        print("["..outputString.."]")
-    else
-        print(output)
-    end
-end
+    local stack = chupacabra.run(" " .. input .. " ", {})
+    print("Stack: " .. table_to_string(stack))
+end
\ No newline at end of file