Main Driver Routine (main.ml
)
let () = (* Main function (caml2html: main_entry) *)
let files = ref [] in
Arg.parse
[("-inline", Arg.Int(fun i -> Inline.threshold := i), "maximum size of functions inlined");
("-iter", Arg.Int(fun i -> limit := i), "maximum number of optimizations iterated")]
(fun s -> files := !files @ [s])
("Mitou Min-Caml Compiler (C) Eijiro Sumii\n" ^
Printf.sprintf "usage: %s [-inline m] [-iter n] ...filenames without \".ml\"..." Sys.argv.(0));
List.iter
(fun f -> ignore (file f))
!files
Main Driver Core
let file f =
let inchan = open_in (f ^ ".ml") and outchan = open_out (f ^ ".s") in
try
lexbuf outchan (Lexing.from_channel inchan);
(* lexbuf is defined above *)
...
with e -> ...
let () = (* Main function (caml2html: main_entry) *)
let files = ref [] in
...
List.iter
(fun f -> ignore (file f))
!files