2015-03-16 17:17:51 +00:00
|
|
|
lookup = require './lookup'
|
|
|
|
|
2015-03-16 03:11:14 +00:00
|
|
|
lispeval = (element, scope) ->
|
|
|
|
switch element.type
|
|
|
|
when 'boolean' then element.value == '#t'
|
|
|
|
when 'number' then parseInt(element.value, 10)
|
|
|
|
when 'symbol'
|
2015-03-16 17:17:51 +00:00
|
|
|
lookup(scope, element.value)
|
2015-03-16 03:11:14 +00:00
|
|
|
when 'list'
|
|
|
|
proc = lispeval(element.value[0], scope)
|
|
|
|
args = element.value.slice(1)
|
2015-03-16 17:17:51 +00:00
|
|
|
proc args, scope
|
2015-03-16 03:11:14 +00:00
|
|
|
|
|
|
|
else throw new Error ("Unrecognized type in parse")
|
|
|
|
|
|
|
|
module.exports = lispeval
|