| 1 |
open Location |
open Location |
| 2 |
open Ident |
open Ident |
| 3 |
|
|
| 4 |
|
ifdef ML_INTERFACE then module ML = Ml_ocaml;; |
| 5 |
|
|
| 6 |
exception InvalidInputFilename of string |
exception InvalidInputFilename of string |
| 7 |
exception InvalidObjectFilename of string |
exception InvalidObjectFilename of string |
| 8 |
|
|
| 278 |
let script = run Parser.prog |
let script = run Parser.prog |
| 279 |
let topinput = run Parser.top_phrases |
let topinput = run Parser.top_phrases |
| 280 |
|
|
| 281 |
|
ifdef ML_INTERFACE then |
| 282 |
|
let check_ml cu id out_dir out = |
| 283 |
|
try |
| 284 |
|
(* Load Caml .cmi file. *) |
| 285 |
|
let ml_cu = ML.CompUnit.from_bytecode (cu ^ ".cmi") |
| 286 |
|
and cd_cu = Ml_cduce.CompUnit.from_types_cu cu id in |
| 287 |
|
(* Check file interfaces. *) |
| 288 |
|
Ml_checker.run ml_cu cd_cu; |
| 289 |
|
(* Generate interface file. *) |
| 290 |
|
let out = open_out ( Filename.concat out_dir (cu ^ ".ml") ) in |
| 291 |
|
let fmt = Format.formatter_of_out_channel out in |
| 292 |
|
Ml_generator.ML.generate fmt ml_cu cd_cu; |
| 293 |
|
close_out out; |
| 294 |
|
with _ -> |
| 295 |
|
Format.eprintf "Warning: no valid Caml interface found.@." |
| 296 |
|
else |
| 297 |
|
let check_ml cu id out_dir out = ();; |
| 298 |
|
|
| 299 |
let compile src out_dir = |
let compile src out_dir = |
| 300 |
try |
try |
| 301 |
if not (Filename.check_suffix src ".cd") |
if not (Filename.check_suffix src ".cd") |
| 309 |
let id = Types.CompUnit.mk (U.mk_latin1 cu) in |
let id = Types.CompUnit.mk (U.mk_latin1 cu) in |
| 310 |
Librarian.compile !verbose id src; |
Librarian.compile !verbose id src; |
| 311 |
Librarian.save id out; |
Librarian.save id out; |
| 312 |
|
check_ml cu id out_dir out; |
| 313 |
exit 0 |
exit 0 |
| 314 |
with exn -> catch_exn Format.err_formatter exn; exit 1 |
with exn -> catch_exn Format.err_formatter exn; exit 1 |
| 315 |
|
|