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
Crisp::Interpreter.new.run
rescue e
o">STDERR.puts e
b">puts e
exit 1
end
else

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

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

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

@ -1,6 +1,8 @@
require "./printer"
module Crisp
extend self
class Symbol
property :str
def initialize(@str)
@ -100,10 +102,10 @@ module Crisp
end
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
class Array

Loading…
Cancel
Save