mlcduce_wrapper.ml 644 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
let loc = (Lexing.dummy_pos, Lexing.dummy_pos)

let usage =
"Usage: mlcduce_wrapper <primitive file>
" 

let err s = prerr_endline s; prerr_endline usage; exit 1

let () =
  if Array.length Sys.argv != 2 then err "";
  let fn = Sys.argv.(1) in
  let ic = 
    try open_in fn
    with Sys_error s -> err s in
  let v = ref [] in
  (try while true do 
     let s = input_line ic in
     if s = "" then raise End_of_file;
     match s.[0] with
       | 'A'..'Z' -> v := s :: !v 
       | _ -> err "Names must start with a capitalized letter"
   done 
   with End_of_file -> ());
  let s = Mlstub.gen_wrapper !v in
  !Pcaml.print_implem [ s,loc ]