From 05f3c690247f7ca1af26646bca0dd566e18dd237 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 1 Apr 2024 22:16:24 -0500 Subject: Error on wrong unquote[-splicing] --- eval.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/eval.lua b/eval.lua index 2e3a2bf..c2945bf 100644 --- a/eval.lua +++ b/eval.lua @@ -82,9 +82,16 @@ m.specials = { end return type.list(QQ, fin) end, + -- if not inside quasiquote, unquote and unquote-splicing are errors + unquote = function () error("Unexpected unquote") end, + ["unquote-splicing"] = + function () error("Unexpected unquote-splicing") end, + -- define variables define = function (r, e) rawset(e, r[1], m.eval(r[2][1], e)) end, - lambda = function (r, e) return m.procedure(r[1], r[2], e) end, ["set!"] = function (r, e) e[r[1]] = m.eval(r[2][1], e) end, + -- y'know, ... lambda + lambda = function (r, e) return m.procedure(r[1], r[2], e) end, + -- control flow ["if"] = function (r, e) local test, conseq, alt = -- cgit 1.4.1-21-gabe81