Add option --light-debug

This commit is contained in:
Théophile Bastian 2018-02-15 22:19:14 +01:00
parent 6c5580d550
commit 324e32c15e

View file

@ -5,6 +5,9 @@
let debug =
ref false
let light_debug =
ref false
let filenames =
ref []
@ -14,6 +17,7 @@ let record filename =
let options =
Arg.align [
"--debug", Arg.Set debug, " Enable debugging output";
"--light-debug", Arg.Set light_debug, " Enable debugging output";
]
let usage =
@ -24,6 +28,8 @@ let () =
let debug =
!debug
let light_debug =
!light_debug
let filenames =
List.rev !filenames
@ -36,8 +42,8 @@ let print_delimiter () =
Printf.eprintf "----------------------------------------";
Printf.eprintf "----------------------------------------\n"
let dump (phase : string) (show : 'term -> string) (t : 'term) =
if debug then begin
let dump (phase : string) (show : 'term -> string) (light: bool) (t : 'term) =
if debug || (light_debug && light) then begin
print_delimiter();
Printf.eprintf "%s:\n\n%s\n\n%!" phase (show t)
end;
@ -82,17 +88,17 @@ let output (p : C.program) : unit =
let process filename =
filename
|> read
|> dump "RawLambda" RawLambda.show_term
|> dump "RawLambda" RawLambda.show_term false
|> Cook.cook_term
|> dump "Lambda" Lambda.show_term
|> dump "Lambda" Lambda.show_term false
|> CPS.cps_term
|> dump "Tail" Tail.show_term
|> dump "PrettyTail" PrettyTail.show
|> dump "Tail" Tail.show_term false
|> dump "PrettyTail" PrettyTail.show true
|> Defun.defun_term
|> dump "Top" Top.show_program
|> dump "PrettyTop" PrettyTop.show
|> dump "Top" Top.show_program false
|> dump "PrettyTop" PrettyTop.show true
|> Finish.finish_program
|> dump "C" C.show_program
|> dump "C" C.show_program false
|> output
(* -------------------------------------------------------------------------- *)