activated improved use_ml, which captures output and reports source positions;
authorwenzelm
Thu, 14 Dec 2006 21:46:59 +0100
changeset 21853 ae3707892310
parent 21852 7f2853bd54bf
child 21854 42e9fd3ec1a3
activated improved use_ml, which captures output and reports source positions; define use_file in terms of use_ml;
src/Pure/ML-Systems/polyml-5.0.ML
--- a/src/Pure/ML-Systems/polyml-5.0.ML	Thu Dec 14 21:46:58 2006 +0100
+++ b/src/Pure/ML-Systems/polyml-5.0.ML	Thu Dec 14 21:46:59 2006 +0100
@@ -11,9 +11,11 @@
 
 
 (* improved versions of use_text/file *)
-(*
+
 local
 
+fun std_output s = (TextIO.output (TextIO.stdOut, s); TextIO.flushOut TextIO.stdOut);
+
 fun use_ml name (print, err) verbose txt =
   let
     val in_buffer = ref (explode txt);
@@ -26,15 +28,16 @@
       (case ! in_buffer of
         [] => ""
       | c :: cs => (in_buffer := cs; if c = "\n" then line_no := ! line_no + 1 else (); c));
-    fun put s = out_buffer := s :: ! out_buffer;
+    val put_fn = ref (fn s => out_buffer := s :: ! out_buffer);
 
     fun exec () =
       (case ! in_buffer of
         [] => ()
-      | _ => (PolyML.compilerEx (get, put, line, name) (); exec ()));
+      | _ => (PolyML.compilerEx (get, fn s => ! put_fn s, line, name) (); exec ()));
   in
     exec () handle exn => (err (output ()); raise exn);
-    if verbose then print (output ()) else ()
+    if verbose then print (output ()) else ();
+    put_fn := std_output   (*run-time output, e.g. PolyML.print*)
   end;
 
 in
@@ -48,4 +51,3 @@
   in use_ml name output verbose txt end;
 
 end;
-*)