Browse Source

fix some regressions

- some compilation error
- STDERR seems not to work in Crystal 0.7.2
master
rhysd 9 years ago
parent
commit
d9d792b710
3 changed files with 10 additions and 9 deletions
  1. +1
    -1
      crisp.cr
  2. +4
    -5
      src/crisp/interpreter.cr
  3. +5
    -3
      src/crisp/types.cr

+ 1
- 1
crisp.cr View File

@ -4,7 +4,7 @@ if ARGV.empty?
begin begin
Crisp::Interpreter.new.run Crisp::Interpreter.new.run
rescue e rescue e
o">STDERR.puts e
b">puts e
exit 1 exit 1
end end
else else

+ 4
- 5
src/crisp/interpreter.cr View File

@ -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

+ 5
- 3
src/crisp/types.cr View File

@ -1,6 +1,8 @@
require "./printer" require "./printer"
module Crisp module Crisp
extend self
class Symbol class Symbol
property :str property :str
def initialize(@str) def initialize(@str)
@ -100,10 +102,10 @@ module Crisp
end end
alias Func = Type::Func alias Func = Type::Func
end
macro gen_type(t, *args)
Crisp::Type.new {{t.id}}.new({{*args}})
end
macro gen_type(t, *args)
Crisp::Type.new {{t.id}}.new({{*args}})
end end
class Array class Array

Loading…
Cancel
Save