diff --git a/lib/ast.ml b/lib/ast.ml index c954c1d..579084d 100644 --- a/lib/ast.ml +++ b/lib/ast.ml @@ -60,14 +60,21 @@ let reduce init f = | _ -> invalid_arg "cannot reduce over non-list!" in aux init -let rec dbg_print_one v = +let rec dbg_print_list = + let pf = Printf.sprintf in + function + | LCons (v, LNil) -> pf "%s" (dbg_print_one v) + | LCons (v, rest) -> (pf "%s " (dbg_print_one v)) ^ (dbg_print_list rest) + | v -> pf ". %s" (dbg_print_one v) + +and dbg_print_one v = let pf = Printf.sprintf in match v with | LInt x -> pf "" x | LSymbol s -> pf "" s | LString s -> pf "" s | LNil -> pf "()" - | LCons (a, b) -> pf "(%s . %s)" (dbg_print_one a) (dbg_print_one b) + | LCons _ -> pf "" (dbg_print_list v) | LDouble d -> pf "" d | LBuiltinSpecial (name, _) | LBuiltinFunction (name, _) -> pf "" name