ref: 778e0a846e76d2118f2917637eef1b7580331727
dir: /printer.ml/
module T = Types.Types let meta obj = match obj with | T.List { T.meta } -> meta | T.Proc { T.meta } -> meta | T.Symbol { T.meta } -> meta | T.Vector { T.meta } -> meta | T.Record { T.meta } -> meta | _ -> T.Nil let rec print obj readable = let r = readable in match obj with | T.Bool true -> "#t" | T.Bool false -> "#f" | T.Char c -> Char.escaped c | T.Nil -> "nil" | T.Comment -> "" (* TODO: this leaves a space in the output for block comments *) (* | T.Pair { T.value = one, two } -> "(" ^ one ^ " . " ^ two ^ ")" *) | T.Pair (p, q) -> "<pair unsupported>" | T.Proc p -> "#<proc>" | T.Symbol {T.value = s} -> s | T.Bytevector bv -> "<bytevector unsupported>" | T.Eof_object -> "<eof>" | T.Number n -> string_of_int n | T.Port p -> "<port unsupported>" | T.String s -> s (* need to handle escaping and stuff *) | T.List { T.value = xs } -> "(" ^ (String.concat " " (List.map (fun s -> print s r) xs)) ^ ")" | T.Vector {T.value = v} -> "#(" ^ (String.concat " " (List.map (fun s -> print s r) v)) ^ ")" | T.Record r -> "<record supported>"