]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/matita/matitacLib.ml
alias declarations are now put in the .moo file.
[helm.git] / helm / matita / matitacLib.ml
index d82d3f7555db5a5c8335d62b290b0fc93c36137c..b7afff475d89143cc6dcb259ea63043811c09e20 100644 (file)
@@ -38,7 +38,7 @@ let usage =
 
 let status = ref None
 
-let run_script is eval_function  =
+let run_script output is eval_function  =
   let status = 
     match !status with
     | None -> assert false
@@ -58,7 +58,7 @@ let run_script is eval_function  =
     MatitaLog.debug ("Executing: ``" ^ stm ^ "''")
   in
   try
-    eval_function status is cb
+    eval_function output status is cb
   with
   | MatitaEngine.Drop  
   | CicTextualParser2.Parse_error _ as exn -> raise exn
@@ -84,7 +84,7 @@ let pp_ocaml_mode () =
 let rec go () = 
  let str = Stream.of_channel stdin in
   try
-    run_script str MatitaEngine.eval_from_stream_greedy
+    run_script ignore str MatitaEngine.eval_from_stream_greedy
   with 
   | MatitaEngine.Drop -> pp_ocaml_mode ()
   | Sys.Break -> MatitaLog.error "user break!"; go ()
@@ -124,7 +124,10 @@ let main ~mode =
         | "stdin" -> stdin
         | fname -> open_in fname)
     in
-    run_script is MatitaEngine.eval_from_stream;
+    let os = open_out (MatitaMisc.obj_file_of_script fname) in
+    let output s = output_string os s in
+    output "(* GENERATED FILE: DO NOT EDIT! *)\n\n";
+    run_script output is MatitaEngine.eval_from_stream;
     let elapsed = Unix.time () -. time in
     let tm = Unix.gmtime elapsed in
     let sec = 
@@ -151,7 +154,7 @@ let main ~mode =
      begin
        MatitaLog.message 
          (sprintf "execution of %s completed in %s." fname (hou^min^sec));
-         close_out (open_out (MatitaMisc.obj_file_of_script fname));
+       close_out os;
        exit 0
      end
   with