From d9d792b710a5bf1a76a5168eb6d8d971a358dd46 Mon Sep 17 00:00:00 2001 From: rhysd Date: Thu, 4 Jun 2015 23:25:23 +0900 Subject: [PATCH] fix some regressions - some compilation error - STDERR seems not to work in Crystal 0.7.2 --- crisp.cr | 2 +- src/crisp/interpreter.cr | 9 ++++----- src/crisp/types.cr | 8 +++++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/crisp.cr b/crisp.cr index 503f6aa..8c5b909 100644 --- a/crisp.cr +++ b/crisp.cr @@ -4,7 +4,7 @@ if ARGV.empty? begin Crisp::Interpreter.new.run rescue e - STDERR.puts e + puts e exit 1 end else diff --git a/src/crisp/interpreter.cr b/src/crisp/interpreter.cr index 52e6108..6416ba1 100644 --- a/src/crisp/interpreter.cr +++ b/src/crisp/interpreter.cr @@ -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 - STDERR.puts e + puts e.message end end end diff --git a/src/crisp/types.cr b/src/crisp/types.cr index b96dac9..632fae6 100644 --- a/src/crisp/types.cr +++ b/src/crisp/types.cr @@ -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