Merge pull request #358 from bjh21/bjh21-extra-tests
[jackhill/mal.git] / guile / printer.scm
index 35d0a07..c3400cf 100644 (file)
@@ -25,7 +25,7 @@
       (string-join
        (hash-map->list
         (lambda (k v)
-          (format #f "~a ~a" (pr_str k #t) (pr_str v #t)))
+          (format #f "~a ~a" (p k) (p v)))
         hm)
        " ")
       port)
      (string-sub
       (string-sub s "\\\\" "\\\\")
       "\"" "\\\"")
-     "\n" "\\\n"))
+     "\n" "\\n"))
   (define (%pr_str o) (pr_str o readable?))
   (match obj
-    ((? box?) (pr_str (unbox obj) readable?))
+    ((? box?) (%pr_str (unbox obj)))
     ((? is-func?) "#<function>")
     ((? is-macro?) "#<macro>")
     ((? list?) (format #f "(~{~a~^ ~})" (map %pr_str obj)))
     ((? hash-table?) (print-hashmap obj %pr_str))
     ((? string?)
      (cond
-      ((string-match "^\u029e(.*)" obj)
-       => (lambda (m) (format #f ":~a" (match:substring m 1))))
+      ((_keyword? obj)
+       => (lambda (m) (format #f ":~a" (substring obj 1))))
       (else (if readable? (format #f "\"~a\"" (->str obj)) obj))))
     ;;((? number?) (format #f "~a" obj))
     ;;((? symbol?) (format #f "~a" obj))
-    ((? atom?) (format #f "(atom ~a)" (atom-val obj)))
-    ;;((? _nil?) (format #f "~a" nil))
+    ((? atom?) (format #f "(atom ~a)" (%pr_str (atom-val obj))))
+    ((? _nil?) "nil")
     (#t "true")
     (#f "false")
     (else (format #f "~a" obj))))