diff options
-rw-r--r-- | eval.lua | 10 | ||||
-rw-r--r-- | read.lua | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/eval.lua b/eval.lua index e3e21c3..867a704 100644 --- a/eval.lua +++ b/eval.lua | |||
@@ -1,7 +1,6 @@ | |||
1 | --- lam.eval | 1 | --- lam.eval |
2 | 2 | ||
3 | local m = {} | 3 | local m = {} |
4 | local core = require "core" | ||
5 | local type = require "type" | 4 | local type = require "type" |
6 | local assert_arity = require("util").assert_arity | 5 | local assert_arity = require("util").assert_arity |
7 | 6 | ||
@@ -122,9 +121,9 @@ m.specials = { | |||
122 | assert_arity(r, 3, 3) | 121 | assert_arity(r, 3, 3) |
123 | local test, conseq, alt = | 122 | local test, conseq, alt = |
124 | r[1], r[2][1], r[2][2][1] | 123 | r[1], r[2][1], r[2][2][1] |
125 | if m.eval(test) | 124 | if m.eval(test, e) |
126 | then return m.eval(conseq) | 125 | then return m.eval(conseq, e) |
127 | else return m.eval(alt) | 126 | else return m.eval(alt, e) |
128 | end | 127 | end |
129 | end, | 128 | end, |
130 | -- TODO: include, import, define-syntax, ... | 129 | -- TODO: include, import, define-syntax, ... |
@@ -133,8 +132,7 @@ m.specials = { | |||
133 | m.specials.lam = m.specials.lambda | 132 | m.specials.lam = m.specials.lambda |
134 | m.specials.def = m.specials.define | 133 | m.specials.def = m.specials.define |
135 | 134 | ||
136 | function m.eval (x, env) | 135 | function m.eval (x, env) -- TODO: specify ENV on all calls |
137 | local env = env or core.env | ||
138 | if type.isa(x, "symbol") then | 136 | if type.isa(x, "symbol") then |
139 | if env[x] == nil then | 137 | if env[x] == nil then |
140 | error(string.format("Unbound variable: %s", x)) | 138 | error(string.format("Unbound variable: %s", x)) |
diff --git a/read.lua b/read.lua index 35f5b57..332c919 100644 --- a/read.lua +++ b/read.lua | |||
@@ -193,6 +193,8 @@ function m.scan (cs) | |||
193 | token, toktype, cs = m.readtable[cs[1]](cs) | 193 | token, toktype, cs = m.readtable[cs[1]](cs) |
194 | return token, toktype, cs | 194 | return token, toktype, cs |
195 | elseif cs[1]:match("%s") then | 195 | elseif cs[1]:match("%s") then |
196 | --- should this just continue the loop? | ||
197 | -- i.e., remove `return' | ||
196 | return consume_whitespace(cs) | 198 | return consume_whitespace(cs) |
197 | elseif cs[1]:match("[%d.+-]") then | 199 | elseif cs[1]:match("[%d.+-]") then |
198 | -- numbers, +, -, ., ... | 200 | -- numbers, +, -, ., ... |