|
@ -10,14 +10,14 @@ module Crisp |
|
|
when Nil then "nil" |
|
|
when Nil then "nil" |
|
|
when Bool then value.to_s |
|
|
when Bool then value.to_s |
|
|
when Int32 then value.to_s |
|
|
when Int32 then value.to_s |
|
|
when Crisp::List then "(#{value.map{|v| ">pr_str(v, @print_readably) as String}.join(" ")})" |
|
|
|
|
|
when Crisp::Vector then "[#{value.map{|v| ">pr_str(v, @print_readably) as String}.join(" ")}]" |
|
|
|
|
|
|
|
|
when Crisp::List then "(#{value.map{|v| b">print(v) as String}.join(" ")})" |
|
|
|
|
|
when Crisp::Vector then "[#{value.map{|v| b">print(v) as String}.join(" ")}]" |
|
|
when Crisp::Symbol then value.str.to_s |
|
|
when Crisp::Symbol then value.str.to_s |
|
|
when Crisp::Func then "<function>" |
|
|
when Crisp::Func then "<function>" |
|
|
when Crisp::Closure then "<closure>" |
|
|
when Crisp::Closure then "<closure>" |
|
|
when Crisp::HashMap |
|
|
when Crisp::HashMap |
|
|
# step1_read_print.cr requires specifying type |
|
|
# step1_read_print.cr requires specifying type |
|
|
"{#{value.map{|k, v| "#{">pr_str(k, @print_readably)} #{">pr_str(v, @print_readably)}" as String}.join(" ")}}" |
|
|
|
|
|
|
|
|
"{#{value.map{|k, v| "#{b">print(k)} #{b">print(v)}"}.join(" ")}}" |
|
|
when String |
|
|
when String |
|
|
case |
|
|
case |
|
|
when value.empty?() |
|
|
when value.empty?() |
|
@ -28,14 +28,14 @@ module Crisp |
|
|
@print_readably ? value.inspect : value |
|
|
@print_readably ? value.inspect : value |
|
|
end |
|
|
end |
|
|
when Crisp::Atom |
|
|
when Crisp::Atom |
|
|
"(atom #{">pr_str(value.val, @print_readably)})" |
|
|
|
|
|
|
|
|
"(atom #{b">print(value.val)})" |
|
|
else |
|
|
else |
|
|
raise "invalid CrispType: #{value.to_s}" |
|
|
raise "invalid CrispType: #{value.to_s}" |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def print(t : Crisp::Type) |
|
|
def print(t : Crisp::Type) |
|
|
print(t.unwrap, @print_readably) + (t.macro? ? " (macro)" : "") |
|
|
|
|
|
|
|
|
print(t.unwrap) + (t.macro? ? " (macro)" : "") |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
end |