1 (* Title: Pure/ML-Systems/polyml_old_compiler4.ML
4 Runtime compilation -- for old PolyML.compiler (version 4.x).
7 fun use_text (tune: string -> string) (line: int, name) (print, err) verbose txt =
9 val in_buffer = ref (explode (tune txt));
10 val out_buffer = ref ([]: string list);
11 fun output () = implode (rev (case ! out_buffer of "\n" :: cs => cs | cs => cs));
16 | c :: cs => (in_buffer := cs; c));
17 fun put s = out_buffer := s :: ! out_buffer;
22 | _ => (PolyML.compiler (get, put) (); exec ()));
25 (err ((if name = "" then "" else "Error in " ^ name ^ "\n") ^ output ()); raise exn);
26 if verbose then print (output ()) else ()
29 fun use_file tune output verbose name =
31 val instream = TextIO.openIn name;
32 val txt = Exn.release (Exn.capture TextIO.inputAll instream before TextIO.closeIn instream);
33 in use_text tune (1, name) output verbose txt end;