2001-09-07 00:55:07 -07:00
|
|
|
(* camlp4r *)
|
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Camlp4 *)
|
|
|
|
(* *)
|
|
|
|
(* Daniel de Rauglaudre, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
2001-10-01 01:03:46 -07:00
|
|
|
(* Copyright 2001 Institut National de Recherche en Informatique et *)
|
2001-09-07 00:55:07 -07:00
|
|
|
(* Automatique. Distributed only by permission. *)
|
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
|
|
|
value open_out_file () =
|
|
|
|
match Pcaml.output_file.val with
|
|
|
|
[ Some f -> open_out_bin f
|
|
|
|
| None -> do { set_binary_mode_out stdout True; stdout } ]
|
|
|
|
;
|
|
|
|
|
|
|
|
value interf ast =
|
|
|
|
let pt = Ast2pt.interf (List.map fst ast) in
|
|
|
|
let oc = open_out_file () in
|
2003-07-10 05:28:35 -07:00
|
|
|
let fname = Pcaml.input_file.val in
|
2001-09-07 00:55:07 -07:00
|
|
|
do {
|
|
|
|
output_string oc Config.ast_intf_magic_number;
|
2003-07-10 05:28:35 -07:00
|
|
|
output_value oc (if fname = "-" then "" else fname);
|
2001-09-07 00:55:07 -07:00
|
|
|
output_value oc pt;
|
|
|
|
flush oc;
|
|
|
|
match Pcaml.output_file.val with
|
|
|
|
[ Some _ -> close_out oc
|
|
|
|
| None -> () ]
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
value implem ast =
|
|
|
|
let pt = Ast2pt.implem (List.map fst ast) in
|
|
|
|
let oc = open_out_file () in
|
2003-07-10 05:28:35 -07:00
|
|
|
let fname = Pcaml.input_file.val in
|
2001-09-07 00:55:07 -07:00
|
|
|
do {
|
|
|
|
output_string oc Config.ast_impl_magic_number;
|
2003-07-10 05:28:35 -07:00
|
|
|
output_value oc (if fname = "-" then "" else fname);
|
2001-09-07 00:55:07 -07:00
|
|
|
output_value oc pt;
|
|
|
|
flush oc;
|
|
|
|
match Pcaml.output_file.val with
|
|
|
|
[ Some _ -> close_out oc
|
|
|
|
| None -> () ]
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
Pcaml.print_interf.val := interf;
|
|
|
|
Pcaml.print_implem.val := implem;
|