(* this disambiguation step should be deferred to support tacticals *)
eval status st
-let eval_from_stream status str =
- let st = CicTextualParser2.parse_statement str in
- eval_ast status st
+let eval_from_stream status str cb =
+ let stl = CicTextualParser2.parse_statements str in
+ List.fold_left
+ (fun status ast -> cb status ast;eval_ast status ast) status
+ stl
let eval_string status str =
- eval_from_stream status (Stream.of_string str)
+ eval_from_stream status (Stream.of_string str) (fun _ _ -> ())
let default_options () =
let options =
val eval_string: MatitaTypes.status -> string -> MatitaTypes.status
-val eval_from_stream: MatitaTypes.status -> char Stream.t -> MatitaTypes.status
+val eval_from_stream:
+ MatitaTypes.status -> char Stream.t ->
+ (MatitaTypes.status -> (CicAst.term,string) TacticAst.statement -> unit) ->
+ MatitaTypes.status
val eval_ast:
MatitaTypes.status -> (CicAst.term, string) TacticAst.statement ->
| fname -> open_in fname)
in
let status = ref (Lazy.force MatitaEngine.initial_status) in
+ let slash_n_RE = Pcre.regexp "\\n" in
+ let cb status stm =
+ (* dump_status status; *)
+ let stm = TacticAstPp.pp_statement stm in
+ let stm = Pcre.replace ~rex:slash_n_RE stm in
+ let stm =
+ if String.length stm > 50 then
+ String.sub stm 0 50 ^ " ..."
+ else
+ stm
+ in
+ MatitaLog.debug ("Executing: ``" ^ stm ^ "''")
+ in
try
- while true do
- dump_status !status;
- try
- status := MatitaEngine.eval_from_stream !status is
- with
- | CicTextualParser2.Parse_error _ as exn ->
- try
- Stream.empty is;
- raise End_of_file
- with Stream.Failure -> raise exn
- | exn ->
- MatitaLog.error (Printexc.to_string exn);
- raise exn
- done
- with
- | End_of_file ->
- MatitaLog.message (sprintf "execution of %s completed." fname);
- Http_getter.sync_dump_file ();
- exit(0)
- | CicTextualParser2.Parse_error (floc,err) ->
- let (x, y) = CicAst.loc_of_floc floc in
- MatitaLog.message (sprintf "Parse error at %d-%d: %s" x y err);
- Http_getter.sync_dump_file ();
- exit 1
+ status := MatitaEngine.eval_from_stream !status is cb
+ with
+ | CicTextualParser2.Parse_error (floc,err) ->
+ let (x, y) = CicAst.loc_of_floc floc in
+ MatitaLog.message (sprintf "Parse error at %d-%d: %s" x y err);
+ Http_getter.sync_dump_file ();
+ exit 1
+ | exn ->
+ MatitaLog.error (Printexc.to_string exn);
+ raise exn
-
-let _ = List.iter run_script scripts
+let _ =
+ List.iter (fun fname ->
+ run_script fname;
+ MatitaLog.message (sprintf "execution of %s completed." fname)) scripts;
+ Http_getter.sync_dump_file ();
+ exit(0)
+