about summary refs log tree commit diff stats
path: root/lua/chupacabra/chupacabra.lua
diff options
context:
space:
mode:
authorelioat <hi@eli.li>2024-06-09 15:07:05 -0400
committerelioat <hi@eli.li>2024-06-09 15:07:05 -0400
commit14880745b383bd86596b0600c05d673a8834a403 (patch)
treeac9d461833d0c839b681761108d949a979678f31 /lua/chupacabra/chupacabra.lua
parent0804a54d04e62672e02c850b50caa987eda46b67 (diff)
downloadtour-14880745b383bd86596b0600c05d673a8834a403.tar.gz
*
Diffstat (limited to 'lua/chupacabra/chupacabra.lua')
-rw-r--r--lua/chupacabra/chupacabra.lua24
1 files changed, 22 insertions, 2 deletions
diff --git a/lua/chupacabra/chupacabra.lua b/lua/chupacabra/chupacabra.lua
index 80a8d22..107a832 100644
--- a/lua/chupacabra/chupacabra.lua
+++ b/lua/chupacabra/chupacabra.lua
@@ -33,8 +33,28 @@ function chupacabra.evaluate(tokens, context)
                 table.insert(array, tonumber(number))
             end
             table.insert(stack, array)
-        elseif token == "pop" then
-            table.remove(stack) -- testing is fun
+        elseif token == ".." then
+            local array = {}
+            for i = 1, #stack do
+                table.insert(array, stack[i])
+            end
+            table.insert(stack, array)
+        elseif token == "@.." then
+            local result = {}
+            for i = 1, #stack do
+                local value = stack[i]
+                if type(value) == "table" then
+                    for j = 1, #value do
+                        table.insert(result, value[j])
+                    end
+                else
+                    table.insert(result, value)
+                end
+            end
+            table.insert(stack, result)    
+        elseif token == "." then
+            table.remove(stack)
+            --TODO: add the ability for this keywor, or a paired @. keyword to remove an array from the stack
         elseif token == "+" then
             local b = table.remove(stack)
             local a = table.remove(stack)