Blame camlp4/Camlp4/Printers/DumpCamlp4Ast.ml
|
Packit |
1f8b6b |
(****************************************************************************)
|
|
Packit |
1f8b6b |
(* *)
|
|
Packit |
1f8b6b |
(* OCaml *)
|
|
Packit |
1f8b6b |
(* *)
|
|
Packit |
1f8b6b |
(* INRIA Rocquencourt *)
|
|
Packit |
1f8b6b |
(* *)
|
|
Packit |
1f8b6b |
(* Copyright 2006 Institut National de Recherche en Informatique et *)
|
|
Packit |
1f8b6b |
(* en Automatique. All rights reserved. This file is distributed under *)
|
|
Packit |
1f8b6b |
(* the terms of the GNU Library General Public License, with the special *)
|
|
Packit |
1f8b6b |
(* exception on linking described in LICENSE at the top of the Camlp4 *)
|
|
Packit |
1f8b6b |
(* source tree. *)
|
|
Packit |
1f8b6b |
(* *)
|
|
Packit |
1f8b6b |
(****************************************************************************)
|
|
Packit |
1f8b6b |
|
|
Packit |
1f8b6b |
(* Authors:
|
|
Packit |
1f8b6b |
* - Daniel de Rauglaudre: initial version
|
|
Packit |
1f8b6b |
* - Nicolas Pouillard: refactoring
|
|
Packit |
1f8b6b |
*)
|
|
Packit |
1f8b6b |
|
|
Packit |
1f8b6b |
module Id = struct
|
|
Packit |
1f8b6b |
value name = "Camlp4Printers.DumpCamlp4Ast";
|
|
Packit |
1f8b6b |
value version = Sys.ocaml_version;
|
|
Packit |
1f8b6b |
end;
|
|
Packit |
1f8b6b |
|
|
Packit |
1f8b6b |
module Make (Syntax : Sig.Syntax)
|
|
Packit |
1f8b6b |
: (Sig.Printer Syntax.Ast).S
|
|
Packit |
1f8b6b |
= struct
|
|
Packit |
1f8b6b |
include Syntax;
|
|
Packit |
1f8b6b |
|
|
Packit |
1f8b6b |
value with_open_out_file x f =
|
|
Packit |
1f8b6b |
match x with
|
|
Packit |
1f8b6b |
[ Some file -> do { let oc = open_out_bin file;
|
|
Packit |
1f8b6b |
f oc;
|
|
Packit |
1f8b6b |
flush oc;
|
|
Packit |
1f8b6b |
close_out oc }
|
|
Packit |
1f8b6b |
| None -> do { set_binary_mode_out stdout True; f stdout; flush stdout } ];
|
|
Packit |
1f8b6b |
|
|
Packit |
1f8b6b |
value dump_ast magic ast oc = do {
|
|
Packit |
1f8b6b |
output_string oc magic;
|
|
Packit |
1f8b6b |
output_value oc ast;
|
|
Packit |
1f8b6b |
};
|
|
Packit |
1f8b6b |
|
|
Packit |
1f8b6b |
value print_interf ?input_file:(_) ?output_file ast =
|
|
Packit |
1f8b6b |
with_open_out_file output_file
|
|
Packit |
1f8b6b |
(dump_ast Camlp4_config.camlp4_ast_intf_magic_number ast);
|
|
Packit |
1f8b6b |
|
|
Packit |
1f8b6b |
value print_implem ?input_file:(_) ?output_file ast =
|
|
Packit |
1f8b6b |
with_open_out_file output_file
|
|
Packit |
1f8b6b |
(dump_ast Camlp4_config.camlp4_ast_impl_magic_number ast);
|
|
Packit |
1f8b6b |
|
|
Packit |
1f8b6b |
end;
|