diff options
Diffstat (limited to 'cparser')
-rw-r--r-- | cparser/Cprint.ml | 10 | ||||
-rw-r--r-- | cparser/Cprint.mli | 3 |
2 files changed, 13 insertions, 0 deletions
diff --git a/cparser/Cprint.ml b/cparser/Cprint.ml index 0a927873..d623ab96 100644 --- a/cparser/Cprint.ml +++ b/cparser/Cprint.ml @@ -555,3 +555,13 @@ let program pp prog = fprintf pp "@[<v 0>"; List.iter (globdecl pp) prog; fprintf pp "@]@." + +let destination : string option ref = ref None + +let print_if prog = + match !destination with + | None -> () + | Some f -> + let oc = open_out f in + program (formatter_of_out_channel oc) prog; + close_out oc diff --git a/cparser/Cprint.mli b/cparser/Cprint.mli index fe71e4fe..be7ce029 100644 --- a/cparser/Cprint.mli +++ b/cparser/Cprint.mli @@ -33,3 +33,6 @@ val storage : Format.formatter -> C.storage -> unit val field : Format.formatter -> C.field -> unit val globdecl : Format.formatter -> C.globdecl -> unit val program : Format.formatter -> C.program -> unit + +val destination : string option ref +val print_if : C.program -> unit |