|
@ -15,9 +15,10 @@ module Crisp |
|
|
|
|
|
|
|
|
class Interpreter |
|
|
class Interpreter |
|
|
def initialize(args = nil) |
|
|
def initialize(args = nil) |
|
|
|
|
|
@printer = Printer.new |
|
|
@env = Crisp::Env.new |
|
|
@env = Crisp::Env.new |
|
|
|
|
|
|
|
|
Crisp::NameSpace.each{|k,v| @curent_env.set(k, Crisp::Type.new(v))} |
|
|
|
|
|
|
|
|
Crisp::NameSpace.each{|k,v| @env.set(k, Crisp::Type.new(v))} |
|
|
@env.set("eval", Crisp::Type.new -> (args: Array(Crisp::Type)){ eval(args[0], @env) }) |
|
|
@env.set("eval", Crisp::Type.new -> (args: Array(Crisp::Type)){ eval(args[0], @env) }) |
|
|
|
|
|
|
|
|
eval_string "(def! not (fn* (a) (if a false true)))" |
|
|
eval_string "(def! not (fn* (a) (if a false true)))" |
|
@ -35,8 +36,6 @@ module Crisp |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
@env.set("*ARGV*", Crisp::Type.new argv) |
|
|
@env.set("*ARGV*", Crisp::Type.new argv) |
|
|
|
|
|
|
|
|
@printer = Printer.new |
|
|
|
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def func_of(env, binds, body) |
|
|
def func_of(env, binds, body) |
|
@ -72,7 +71,7 @@ module Crisp |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def read(str) |
|
|
def read(str) |
|
|
read_str str |
|
|
|
|
|
|
|
|
Crisp.read_str str |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
macro pair?(list) |
|
|
macro pair?(list) |
|
@ -278,7 +277,7 @@ module Crisp |
|
|
begin |
|
|
begin |
|
|
puts eval_string(line) |
|
|
puts eval_string(line) |
|
|
rescue e |
|
|
rescue e |
|
|
o">STDERR.puts e |
|
|
|
|
|
|
|
|
b">puts e.message |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|