crystal: basic implementation of step1
[jackhill/mal.git] / crystal / printer.cr
1 require "./types"
2
3 def pr_str(value)
4 case value
5 when Nil then "nil"
6 when Bool then value.to_s
7 when Int32 then value.to_s
8 when String then value.inspect
9 when Array then "(#{value.map{|v| pr_str(v) as String}.join(" ")})"
10 when Mal::Symbol then value.val.to_s
11 else raise "invalid MalType: #{value.to_s}"
12 end
13 end