Última atividade 17 hours ago

capitalex's Avatar capitalex revisou este gist 17 hours ago. Ir para a revisão

1 file changed, 32 insertions

stuff.lua(arquivo criado)

@@ -0,0 +1,32 @@
1 + -- quotation.lua
2 + local function quotation_call(quote, env)
3 + if rawget(quote, "namespace") then env.namespace:push(quote.namespace) end
4 + for _, item in ipairs(quote.body) do
5 + local typ = type(item)
6 + if typ == "number" or typ == "boolean" or typ == "string" or (typ == "table" and item.type == "quote") then
7 + env.data:push(item)
8 + else
9 + item(env)
10 + end
11 + end
12 + if rawget(quote, "namespace") then env.namespace:pop() end
13 + end
14 +
15 + -- gilded.lua
16 + builtins["call"] = function(env)
17 + env:assertHeight(1)
18 + local quote = env.data:pop()
19 + return quote(env)
20 + end
21 +
22 + -- snipped --
23 +
24 + local env = enviroment.new()
25 + for _, item in ipairs(program) do
26 + local typ = type(item)
27 + if typ == "number" or typ == "boolean" or typ == "string" or (typ == "table" and item.type == "quote") then
28 + env.data:push(item)
29 + else
30 + item(env)
31 + end
32 + end
Próximo Anterior