|
@ -15,11 +15,11 @@ module Crisp |
|
|
-> (args : Array(Crisp::Expr)) { |
|
|
-> (args : Array(Crisp::Expr)) { |
|
|
new_env = Crisp::Env.new(env, binds, args) |
|
|
new_env = Crisp::Env.new(env, binds, args) |
|
|
eval(body, new_env) |
|
|
eval(body, new_env) |
|
|
} as Crisp::Func |
|
|
|
|
|
|
|
|
}.as Crisp::Func |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def eval_ast(ast, env) |
|
|
def eval_ast(ast, env) |
|
|
return ast.map{|n| eval(n, env) as Crisp::Expr} if ast.is_a? Array |
|
|
|
|
|
|
|
|
return ast.map{|n| eval(n, env).as Crisp::Expr} if ast.is_a? Array |
|
|
|
|
|
|
|
|
val = ast.unwrap |
|
|
val = ast.unwrap |
|
|
|
|
|
|
|
@ -94,8 +94,8 @@ module Crisp |
|
|
while macro_call?(ast, env) |
|
|
while macro_call?(ast, env) |
|
|
|
|
|
|
|
|
# Already checked in macro_call? |
|
|
# Already checked in macro_call? |
|
|
list = ast.unwrap as Crisp::List |
|
|
|
|
|
func_sym = list[0].unwrap as Crisp::Symbol |
|
|
|
|
|
|
|
|
list = ast.unwrap.as Crisp::List |
|
|
|
|
|
func_sym = list[0].unwrap.as Crisp::Symbol |
|
|
func = env.get(func_sym.str).unwrap |
|
|
func = env.get(func_sym.str).unwrap |
|
|
|
|
|
|
|
|
case func |
|
|
case func |
|
@ -113,7 +113,7 @@ module Crisp |
|
|
|
|
|
|
|
|
macro invoke_list(l, env) |
|
|
macro invoke_list(l, env) |
|
|
f = eval({{l}}.first, {{env}}).unwrap |
|
|
f = eval({{l}}.first, {{env}}).unwrap |
|
|
args = eval_ast({{l}}[1..-1], {{env}}) as Array |
|
|
|
|
|
|
|
|
args = eval_ast({{l}}[1..-1], {{env}}).as Array |
|
|
|
|
|
|
|
|
case f |
|
|
case f |
|
|
when Crisp::Closure |
|
|
when Crisp::Closure |
|
|