about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2024-04-01 22:16:24 -0500
committerCase Duckworth2024-04-01 22:16:24 -0500
commit05f3c690247f7ca1af26646bca0dd566e18dd237 (patch)
treeb866b3fd378ef7f863ea451e040ff97478197c30
parentAdd rest of quotes to reader (diff)
downloadlam-05f3c690247f7ca1af26646bca0dd566e18dd237.tar.gz
lam-05f3c690247f7ca1af26646bca0dd566e18dd237.zip
Error on wrong unquote[-splicing]
-rw-r--r--eval.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/eval.lua b/eval.lua index 2e3a2bf..c2945bf 100644 --- a/eval.lua +++ b/eval.lua
@@ -82,9 +82,16 @@ m.specials = {
82 end 82 end
83 return type.list(QQ, fin) 83 return type.list(QQ, fin)
84 end, 84 end,
85 -- if not inside quasiquote, unquote and unquote-splicing are errors
86 unquote = function () error("Unexpected unquote") end,
87 ["unquote-splicing"] =
88 function () error("Unexpected unquote-splicing") end,
89 -- define variables
85 define = function (r, e) rawset(e, r[1], m.eval(r[2][1], e)) end, 90 define = function (r, e) rawset(e, r[1], m.eval(r[2][1], e)) end,
86 lambda = function (r, e) return m.procedure(r[1], r[2], e) end,
87 ["set!"] = function (r, e) e[r[1]] = m.eval(r[2][1], e) end, 91 ["set!"] = function (r, e) e[r[1]] = m.eval(r[2][1], e) end,
92 -- y'know, ... lambda
93 lambda = function (r, e) return m.procedure(r[1], r[2], e) end,
94 -- control flow
88 ["if"] = 95 ["if"] =
89 function (r, e) 96 function (r, e)
90 local test, conseq, alt = 97 local test, conseq, alt =