diff options
author | Case Duckworth | 2024-04-01 22:16:24 -0500 |
---|---|---|
committer | Case Duckworth | 2024-04-01 22:16:24 -0500 |
commit | 05f3c690247f7ca1af26646bca0dd566e18dd237 (patch) | |
tree | b866b3fd378ef7f863ea451e040ff97478197c30 | |
parent | Add rest of quotes to reader (diff) | |
download | lam-05f3c690247f7ca1af26646bca0dd566e18dd237.tar.gz lam-05f3c690247f7ca1af26646bca0dd566e18dd237.zip |
Error on wrong unquote[-splicing]
-rw-r--r-- | eval.lua | 9 |
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 = |