3 let cap = String.capitalize_ascii
6 if b then "true" else "ok"
9 let file = name ^ ".mli" in
10 if Sys.file_exists file then ()
12 let och = open_out file in
16 let write_subst st och subst =
18 let lhs = List.map (Printf.sprintf "%S :: ") words in
19 let rhs = List.map (Printf.sprintf "%S :: ") hd in
20 Printf.fprintf och " | %stl -> k %s (%souts) tl\n"
21 (String.concat "" lhs) (ok st.ET.para) (String.concat "" rhs)
25 | hd :: _ -> List.iter (iter (List.rev hd)) subst
27 let write_component st =
28 let cmod = "recommGc" ^ st.ET.cmod in
29 let och = open_out (cmod ^ ".ml") in
30 if st.ET.dmod <> "" then begin
31 Printf.fprintf och "module D = Recomm%s\n\n" (cap st.ET.dmod)
33 Printf.fprintf och "let step k ok outs ins =\n";
34 Printf.fprintf och " if ok then k ok outs ins else\n";
35 Printf.fprintf och " match ins with\n";
36 List.iter (write_subst st och) st.ET.substs;
37 Printf.fprintf och " | _ -> k %s outs ins\n\n" (ok st.ET.optn);
38 Printf.fprintf och "let main =\n";
39 Printf.fprintf och " Recomm%s.register_%s step\n" (cap st.ET.rmod) st.ET.rfun;
44 let cmod = Filename.concat st.ET.cdir "recommGc" in
45 let och = open_out (cmod ^ ".ml") in
47 Printf.fprintf och "module G%u = RecommGc%s\n" (succ i) name
49 List.iteri iter st.ET.mods;