1 (* Copyright (C) 2004-2005, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
30 let debug_print = if debug then prerr_endline else ignore
32 (** raised when one of the script margins (top or bottom) is reached *)
35 let safe_substring s i j =
36 try String.sub s i j with Invalid_argument _ -> assert false
38 let heading_nl_RE = Pcre.regexp "^\\s*\n\\s*"
39 let heading_nl_RE' = Pcre.regexp "^(\\s*\n\\s*)((.|\n)*)"
40 let only_dust_RE = Pcre.regexp "^(\\s|\n|%%[^\n]*\n)*$"
41 let multiline_RE = Pcre.regexp "^\n[^\n]+$"
42 let newline_RE = Pcre.regexp "\n"
45 if Pcre.pmatch ~rex:multiline_RE str then
46 "\n(** " ^ (Pcre.replace ~rex:newline_RE str) ^ " *)"
48 "\n(**\n" ^ str ^ "\n*)"
51 let s = Pcre.replace ~rex:heading_nl_RE s in
53 let nl_pos = String.index s '\n' in
57 (** creates a statement AST for the Goal tactic, e.g. "goal 7" *)
59 let module A = GrafiteAst in
60 let loc = Disambiguate.dummy_floc in
61 A.Executable (loc, A.Tactical (loc, A.Tactic (loc, A.Goal (loc, n))))
64 mathviewer:MatitaTypes.mathViewer;
65 urichooser: UriManager.uri list -> UriManager.uri list;
66 ask_confirmation: title:string -> message:string -> [`YES | `NO | `CANCEL];
67 develcreator: containing:string option -> unit;
68 mutable filenamedata: string option * MatitamakeLib.development option
71 let eval_with_engine guistuff status user_goal parsed_text st =
72 let module TA = GrafiteAst in
73 let module TAPp = GrafiteAstPp in
75 match guistuff.filenamedata with
77 | None,Some devel -> [MatitamakeLib.root_for_development devel ]
79 match MatitamakeLib.development_for_dir (Filename.dirname f) with
81 | Some devel -> [MatitamakeLib.root_for_development devel ]
83 let parsed_text_length = String.length parsed_text in
85 match st with TA.Executable (loc,ex) -> loc, ex | _ -> assert false in
86 let initial_space,parsed_text =
88 let pieces = Pcre.extract ~rex:heading_nl_RE' parsed_text in
89 pieces.(1), pieces.(2)
91 Not_found -> "", parsed_text in
92 (* we add the goal command if needed *)
93 let inital_space,new_status,new_status_and_text_list' =
94 match status.proof_status with
95 | Incomplete_proof (_, goal) when goal <> user_goal ->
97 MatitaEngine.eval_ast ~include_paths:include_
98 ~do_heavy_checks:true status (goal_ast user_goal) in
100 if initial_space = "" then "\n" else initial_space
103 [status, initial_space ^ TAPp.pp_tactic (TA.Goal (loc, user_goal))]
104 | _ -> initial_space,status,[] in
106 MatitaEngine.eval_ast
107 ~include_paths:include_ ~do_heavy_checks:true new_status st
111 | TA.Command (_, TA.Alias _)
112 | TA.Command (_, TA.Include _) -> DisambiguateTypes.Environment.empty
113 | _ -> MatitaSync.alias_diff ~from:status new_status
115 (* we remove the defined object since we consider them "automatic aliases" *)
116 let initial_space,status,new_status_and_text_list_rev =
117 let module DTE = DisambiguateTypes.Environment in
118 let module UM = UriManager in
120 fun k ((v,_) as value) (initial_space,status,acc) ->
123 let v = UM.strip_xpointer (UM.uri_of_string v) in
124 List.exists (fun (s,_) -> s = v) new_status.objects
125 with UM.IllFormedUri _ -> false
128 initial_space,status,acc
132 if initial_space = "" then "\n" else initial_space in
134 DisambiguatePp.pp_environment(DTE.add k value DTE.empty) in
136 {status with aliases = DTE.add k value status.aliases}
138 "\n",new_status,((new_status, new_text)::acc)
139 ) new_aliases (initial_space,status,[]) in
140 let parsed_text = initial_space ^ parsed_text in
142 List.rev new_status_and_text_list_rev @ new_status_and_text_list' @
143 [new_status, parsed_text]
145 res,parsed_text_length
147 let eval_with_engine guistuff status user_goal parsed_text st =
149 eval_with_engine guistuff status user_goal parsed_text st
151 | MatitaEngine.UnableToInclude what
152 | MatitaEngine.IncludedFileNotCompiled what as exc ->
153 let compile_needed_and_go_on d =
156 while Glib.Main.pending () do ignore(Glib.Main.iteration false); done
158 if not(MatitamakeLib.build_development_in_bg ~target refresh_cb d) then
161 eval_with_engine guistuff status user_goal parsed_text st
163 let do_nothing () = [], 0 in
164 let handle_with_devel d =
165 let name = MatitamakeLib.name_for_development d in
166 let title = "Unable to include " ^ what in
168 what ^ " is handled by development <b>" ^ name ^ "</b>.\n\n" ^
169 "<i>Should I compile it and Its dependencies?</i>"
171 (match guistuff.ask_confirmation ~title ~message with
172 | `YES -> compile_needed_and_go_on d
174 | `CANCEL -> do_nothing ())
176 let handle_without_devel filename =
177 let title = "Unable to include " ^ what in
179 what ^ " is <b>not</b> handled by a development.\n" ^
180 "All dependencies are authomatically solved for a development.\n\n" ^
181 "<i>Do you want to set up a development?</i>"
183 (match guistuff.ask_confirmation ~title ~message with
187 guistuff.develcreator ~containing:(Some (Filename.dirname f))
188 | None -> guistuff.develcreator ~containing:None);
191 | `CANCEL -> do_nothing())
193 match guistuff.filenamedata with
194 | None,None -> handle_without_devel None
195 | None,Some d -> handle_with_devel d
197 match MatitamakeLib.development_for_dir (Filename.dirname f) with
198 | None -> handle_without_devel (Some f)
199 | Some d -> handle_with_devel d
202 let disambiguate term status =
203 let module MD = MatitaDisambiguator in
204 let dbd = MatitaDb.instance () in
205 let metasenv = MatitaMisc.get_proof_metasenv status in
206 let context = MatitaMisc.get_proof_context status in
207 let aliases = MatitaMisc.get_proof_aliases status in
208 let interps = MD.disambiguate_term dbd context metasenv aliases term in
213 let eval_macro guistuff status unparsed_text parsed_text script mac =
214 let module TA = GrafiteAst in
215 let module TAPp = GrafiteAstPp in
216 let module MQ = MetadataQuery in
217 let module MDB = MatitaDb in
218 let module CTC = CicTypeChecker in
219 let module CU = CicUniv in
220 (* no idea why ocaml wants this *)
221 let advance ?statement () = script#advance ?statement () in
222 let parsed_text_length = String.length parsed_text in
223 let dbd = MatitaDb.instance () in
226 | TA.WMatch (loc, term) ->
227 let term = disambiguate term status in
228 let l = MQ.match_term ~dbd term in
230 MatitaMisc.strip_suffix ~suffix:"."
231 (MatitaMisc.trim_blanks unparsed_text)
233 let entry = `Whelp (query_url, l) in
234 guistuff.mathviewer#show_uri_list ~reuse:true ~entry l;
235 [], parsed_text_length
236 | TA.WInstance (loc, term) ->
237 let term = disambiguate term status in
238 let l = MQ.instance ~dbd term in
239 let entry = `Whelp (TAPp.pp_macro_cic (TA.WInstance (loc, term)), l) in
240 guistuff.mathviewer#show_uri_list ~reuse:true ~entry l;
241 [], parsed_text_length
242 | TA.WLocate (loc, s) ->
243 let l = MQ.locate ~dbd s in
244 let entry = `Whelp (TAPp.pp_macro_cic (TA.WLocate (loc, s)), l) in
245 guistuff.mathviewer#show_uri_list ~reuse:true ~entry l;
246 [], parsed_text_length
247 | TA.WElim (loc, term) ->
248 let term = disambiguate term status in
251 | Cic.MutInd (uri,n,_) -> UriManager.uri_of_uriref uri n None
252 | _ -> failwith "Not a MutInd"
254 let l = MQ.elim ~dbd uri in
255 let entry = `Whelp (TAPp.pp_macro_cic (TA.WElim (loc, term)), l) in
256 guistuff.mathviewer#show_uri_list ~reuse:true ~entry l;
257 [], parsed_text_length
258 | TA.WHint (loc, term) ->
259 let term = disambiguate term status in
260 let s = ((None,[0,[],term], Cic.Meta (0,[]) ,term),0) in
261 let l = List.map fst (MQ.experimental_hint ~dbd s) in
262 let entry = `Whelp (TAPp.pp_macro_cic (TA.WHint (loc, term)), l) in
263 guistuff.mathviewer#show_uri_list ~reuse:true ~entry l;
264 [], parsed_text_length
267 let s = MatitaMisc.get_proof_status status in
268 let l = List.map fst (MQ.experimental_hint ~dbd s) in
269 let selected = guistuff.urichooser l in
271 | [] -> [], parsed_text_length
277 TA.Apply (loc, CicNotationPt.Uri (UriManager.string_of_uri uri,None))))))
279 let new_status = MatitaEngine.eval_ast status ast in
281 comment parsed_text ^
282 "\n" ^ TAPp.pp_statement ast
284 [ new_status , extra_text ], parsed_text_length
287 "The result of the urichooser should be only 1 uri, not:\n";
289 fun u -> MatitaLog.error (UriManager.string_of_uri u ^ "\n")
292 | TA.Check (_,term) ->
293 let metasenv = MatitaMisc.get_proof_metasenv status in
294 let context = MatitaMisc.get_proof_context status in
295 let aliases = MatitaMisc.get_proof_aliases status in
297 MatitaDisambiguator.disambiguate_term
298 dbd context metasenv aliases term
300 let _, metasenv , term, ugraph =
305 let ty,_ = CTC.type_of_aux' metasenv context term ugraph in
306 let t_and_ty = Cic.Cast (term,ty) in
307 guistuff.mathviewer#show_entry (`Cic (t_and_ty,metasenv));
308 [], parsed_text_length
311 let status = script#status.proof_status in
314 | _ -> script#retract ();go_back()
316 [], parsed_text_length, Some go_back
317 | TA.Redo (_, Some i) -> [], parsed_text_length,
318 Some (fun () -> for j = 1 to i do advance () done)
319 | TA.Redo (_, None) -> [], parsed_text_length,
320 Some (fun () -> advance ())
321 | TA.Undo (_, Some i) -> [], parsed_text_length,
322 Some (fun () -> for j = 1 to i do script#retract () done)
323 | TA.Undo (_, None) -> [], parsed_text_length,
324 Some (fun () -> script#retract ()) *)
326 | TA.Quit _ -> failwith "not implemented"
327 | TA.Print (_,kind) -> failwith "not implemented"
328 | TA.Search_pat (_, search_kind, str) -> failwith "not implemented"
329 | TA.Search_term (_, search_kind, term) -> failwith "not implemented"
332 let eval_executable guistuff status user_goal unparsed_text parsed_text script
335 let module TA = GrafiteAst in
336 let module TAPp = GrafiteAstPp in
337 let module MD = MatitaDisambiguator in
338 let module ML = MatitacleanLib in
339 let parsed_text_length = String.length parsed_text in
341 | TA.Command (loc, _) | TA.Tactical (loc, _) ->
343 (match MatitaMisc.baseuri_of_baseuri_decl (TA.Executable (loc,ex)) with
346 if not (MatitaMisc.is_empty u) then
348 guistuff.ask_confirmation
349 ~title:"Baseuri redefinition"
351 "Baseuri " ^ u ^ " already exists.\n" ^
352 "Do you want to redefine the corresponding "^
353 "part of the library?")
355 | `YES -> MatitacleanLib.clean_baseuris [u]
357 | `CANCEL -> raise MatitaTypes.Cancel);
359 guistuff status user_goal parsed_text (TA.Executable (loc, ex))
360 with MatitaTypes.Cancel -> [], 0)
361 | TA.Macro (_,mac) ->
362 eval_macro guistuff status unparsed_text parsed_text script mac
364 let rec eval_statement baseoffset parsedlen error_tag (buffer : GText.buffer)
365 guistuff status user_goal script unparsed_text
367 if Pcre.pmatch ~rex:only_dust_RE unparsed_text then raise Margin;
370 GrafiteParser.parse_statement (Stream.of_string unparsed_text)
372 CicNotationParser.Parse_error (floc,err) as exc ->
373 let (x, y) = CicNotationPt.loc_of_floc floc in
374 let x = parsedlen + x in
375 let y = parsedlen + y in
376 let x' = baseoffset + x in
377 let y' = baseoffset + y in
378 let x_iter = buffer#get_iter (`OFFSET x') in
379 let y_iter = buffer#get_iter (`OFFSET y') in
380 buffer#apply_tag error_tag ~start:x_iter ~stop:y_iter;
384 (buffer#connect#changed
387 buffer#remove_tag error_tag ~start:buffer#start_iter
388 ~stop:buffer#end_iter;
390 None -> assert false (* a race condition occurred *)
392 (new GObj.gobject_ops buffer#as_buffer)#disconnect id));
393 let flocb,floce = floc in
395 {flocb with Lexing.pos_cnum = x}, {floce with Lexing.pos_cnum = y } in
396 raise (CicNotationParser.Parse_error (floc,err))
398 let text_of_loc loc =
399 let parsed_text_length = snd (CicNotationPt.loc_of_floc loc) in
400 let parsed_text = safe_substring unparsed_text 0 parsed_text_length in
401 parsed_text, parsed_text_length
404 | GrafiteAst.Comment (loc, _) ->
405 let parsed_text, parsed_text_length = text_of_loc loc in
406 let remain_len = String.length unparsed_text - parsed_text_length in
407 let s = String.sub unparsed_text parsed_text_length remain_len in
409 eval_statement baseoffset (parsedlen + parsed_text_length) error_tag
410 buffer guistuff status user_goal script s
413 | (status, text) :: tl ->
414 ((status, parsed_text ^ text)::tl), (parsed_text_length + len)
416 | GrafiteAst.Executable (loc, ex) ->
417 let parsed_text, parsed_text_length = text_of_loc loc in
418 eval_executable guistuff status user_goal unparsed_text parsed_text
421 let fresh_script_id =
425 class script ~(source_view: GSourceView.source_view)
426 ~(init: MatitaTypes.status)
427 ~(mathviewer: MatitaTypes.mathViewer)
433 let buffer = source_view#buffer in
434 let source_buffer = source_view#source_buffer in
436 val scriptId = fresh_script_id ()
439 mathviewer = mathviewer;
440 urichooser = urichooser;
441 ask_confirmation = ask_confirmation;
442 develcreator = develcreator;
443 filenamedata = (None, None)}
445 method private getFilename =
446 match guistuff.filenamedata with Some f,_ -> f | _ -> assert false
448 method private ppFilename =
449 match guistuff.filenamedata with
451 | None,_ -> sprintf ".unnamed%d.ma" scriptId
454 ignore(GMain.Timeout.add ~ms:300000
455 ~callback:(fun _ -> self#_saveToBackuptFile ();true));
456 ignore(buffer#connect#modified_changed
457 (fun _ -> if buffer#modified then
458 set_star self#ppFilename true
460 set_star self#ppFilename false))
462 val mutable statements = []; (** executed statements *)
463 val mutable history = [ init ];
464 (** list of states before having executed statements. Head element of this
465 * list is the current state, last element is the state at the beginning of
467 * Invariant: this list length is 1 + length of statements *)
469 (** goal as seen by the user (i.e. metano corresponding to current tab) *)
470 val mutable userGoal = ~-1
472 (** text mark and tag representing locked part of a script *)
474 buffer#create_mark ~name:"locked" ~left_gravity:true buffer#start_iter
475 val locked_tag = buffer#create_tag [`BACKGROUND "lightblue"; `EDITABLE false]
476 val error_tag = buffer#create_tag [`UNDERLINE `SINGLE; `FOREGROUND "red"]
478 method locked_mark = locked_mark
479 method locked_tag = locked_tag
481 (* history can't be empty, the invariant above grant that it contains at
482 * least the init status *)
483 method status = match history with hd :: _ -> hd | _ -> assert false
485 method private _advance ?statement () =
486 let s = match statement with Some s -> s | None -> self#getFuture in
487 MatitaLog.debug ("evaluating: " ^ first_line s ^ " ...");
488 let (entries, parsed_len) =
489 eval_statement (buffer#get_iter_at_mark (`MARK locked_mark))#offset 0
490 error_tag buffer guistuff self#status userGoal self s
492 let (new_statuses, new_statements) = List.split entries in
493 history <- List.rev new_statuses @ history;
494 statements <- List.rev new_statements @ statements;
495 let start = buffer#get_iter_at_mark (`MARK locked_mark) in
496 let new_text = String.concat "" new_statements in
497 if statement <> None then
498 buffer#insert ~iter:start new_text
500 if new_text <> String.sub s 0 parsed_len then
502 let stop = start#copy#forward_chars parsed_len in
503 buffer#delete ~start ~stop;
504 buffer#insert ~iter:start new_text;
506 self#moveMark (String.length new_text)
508 method private _retract offset status new_statements new_history =
509 let cur_status = match history with s::_ -> s | [] -> assert false in
510 MatitaSync.time_travel ~present:cur_status ~past:status;
511 statements <- new_statements;
512 history <- new_history;
513 self#moveMark (- offset)
515 method advance ?statement () =
517 self#_advance ?statement ();
520 | Margin -> self#notify
521 | exc -> self#notify; raise exc
525 let cmp,new_statements,new_history,status =
526 match statements,history with
527 stat::statements, _::(status::_ as history) ->
528 String.length stat, statements, history, status
529 | [],[_] -> raise Margin
530 | _,_ -> assert false
532 self#_retract cmp status new_statements new_history;
535 | Margin -> self#notify
536 | exc -> self#notify; raise exc
538 method private getFuture =
539 buffer#get_text ~start:(buffer#get_iter_at_mark (`MARK locked_mark))
540 ~stop:buffer#end_iter ()
543 (** @param rel_offset relative offset from current position of locked_mark *)
544 method private moveMark rel_offset =
545 let mark = `MARK locked_mark in
546 let old_insert = buffer#get_iter_at_mark `INSERT in
547 buffer#remove_tag locked_tag ~start:buffer#start_iter ~stop:buffer#end_iter;
548 let current_mark_pos = buffer#get_iter_at_mark mark in
550 match rel_offset with
551 | 0 -> current_mark_pos
552 | n when n > 0 -> current_mark_pos#forward_chars n
553 | n (* when n < 0 *) -> current_mark_pos#backward_chars (abs n)
555 buffer#move_mark mark ~where:new_mark_pos;
556 buffer#apply_tag locked_tag ~start:buffer#start_iter ~stop:new_mark_pos;
557 buffer#move_mark `INSERT old_insert;
559 match self#status.proof_status with
560 Incomplete_proof (_,goal) -> self#setGoal goal
563 let mark_position = buffer#get_iter_at_mark mark in
564 if source_view#move_mark_onscreen mark then
566 buffer#move_mark mark mark_position;
567 source_view#scroll_to_mark ~use_align:true ~xalign:1.0 ~yalign:0.1 mark;
569 while Glib.Main.pending () do ignore(Glib.Main.iteration false); done
571 method clean_dirty_lock =
572 let lock_mark_iter = buffer#get_iter_at_mark (`MARK locked_mark) in
573 buffer#remove_tag locked_tag ~start:buffer#start_iter ~stop:buffer#end_iter;
574 buffer#apply_tag locked_tag ~start:buffer#start_iter ~stop:lock_mark_iter
576 val mutable observers = []
578 method addObserver (o: MatitaTypes.status -> unit) =
579 observers <- o :: observers
581 method private notify =
582 let status = self#status in
583 List.iter (fun o -> o status) observers
585 method loadFromFile f =
586 buffer#set_text (MatitaMisc.input_file f);
588 buffer#set_modified false
590 method assignFileName file =
591 let abspath = MatitaMisc.absolute_path file in
592 let devel = MatitamakeLib.development_for_dir (Filename.dirname abspath) in
593 guistuff.filenamedata <- Some abspath, devel
595 method saveToFile () =
596 let oc = open_out self#getFilename in
597 output_string oc (buffer#get_text ~start:buffer#start_iter
598 ~stop:buffer#end_iter ());
600 buffer#set_modified false
602 method private _saveToBackuptFile () =
603 if buffer#modified then
605 let f = self#ppFilename ^ "~" in
606 let oc = open_out f in
607 output_string oc (buffer#get_text ~start:buffer#start_iter
608 ~stop:buffer#end_iter ());
610 MatitaLog.debug ("backup " ^ f ^ " saved")
613 method private goto_top =
614 MatitaSync.time_travel ~present:self#status ~past:init;
618 buffer#remove_tag locked_tag ~start:buffer#start_iter ~stop:buffer#end_iter;
619 buffer#move_mark (`MARK locked_mark) ~where:buffer#start_iter
623 source_buffer#begin_not_undoable_action ();
624 buffer#delete ~start:buffer#start_iter ~stop:buffer#end_iter;
625 source_buffer#end_not_undoable_action ();
627 buffer#set_modified false
630 let template = MatitaMisc.input_file BuildTimeConf.script_template in
631 buffer#insert ~iter:(buffer#get_iter `START) template;
632 guistuff.filenamedata <-
633 (None,MatitamakeLib.development_for_dir (Unix.getcwd ()));
634 buffer#set_modified false;
635 set_star self#ppFilename false
637 method goto (pos: [`Top | `Bottom | `Cursor]) () =
638 let old_locked_mark =
640 (buffer#create_mark ~name:"old_locked_mark"
641 ~left_gravity:true (buffer#get_iter_at_mark (`MARK locked_mark))) in
642 let getpos _ = buffer#get_iter_at_mark (`MARK locked_mark) in
643 let getoldpos _ = buffer#get_iter_at_mark old_locked_mark in
644 let dispose_old_locked_mark () = buffer#delete_mark old_locked_mark in
646 | `Top -> dispose_old_locked_mark (); self#goto_top; self#notify
651 let newpos = getpos () in
652 if (getoldpos ())#compare newpos < 0 then
654 buffer#move_mark old_locked_mark newpos;
659 dispose_old_locked_mark ();
662 | Margin -> dispose_old_locked_mark (); self#notify
663 | exc -> dispose_old_locked_mark (); self#notify; raise exc)
665 let locked_iter () = buffer#get_iter_at_mark (`NAME "locked") in
666 let cursor_iter () = buffer#get_iter_at_mark `INSERT in
669 (buffer#create_mark ~name:"initial_insert"
670 ~left_gravity:true (cursor_iter ())) in
671 let dispose_remember () = buffer#delete_mark remember in
672 let remember_iter () =
673 buffer#get_iter_at_mark (`NAME "initial_insert") in
674 let cmp () = (locked_iter ())#offset - (remember_iter ())#offset in
676 let forward_until_cursor () = (* go forward until locked > cursor *)
679 if cmp () < 0 && (getoldpos ())#compare (getpos ()) < 0
682 buffer#move_mark old_locked_mark (getpos ());
688 let rec back_until_cursor len = (* go backward until locked < cursor *)
690 statements, (status::_ as history) when len <= 0 ->
691 self#_retract (icmp - len) status statements history
692 | statement::tl1, _::tl2 ->
693 back_until_cursor (len - String.length statement) (tl1,tl2)
694 | _,_ -> assert false
698 if icmp < 0 then (* locked < cursor *)
699 (forward_until_cursor (); self#notify)
700 else if icmp > 0 then (* locked > cursor *)
701 (back_until_cursor icmp (statements,history); self#notify)
702 else (* cursor = locked *)
706 dispose_old_locked_mark ();
708 | Margin -> dispose_remember (); dispose_old_locked_mark (); self#notify
709 | exc -> dispose_remember (); dispose_old_locked_mark ();
710 self#notify; raise exc)
712 method onGoingProof () =
713 match self#status.proof_status with
714 | No_proof | Proof _ -> false
715 | Incomplete_proof _ -> true
716 | Intermediate _ -> assert false
718 method proofStatus = MatitaMisc.get_proof_status self#status
719 method proofMetasenv = MatitaMisc.get_proof_metasenv self#status
720 method proofContext = MatitaMisc.get_proof_context self#status
721 method proofConclusion = MatitaMisc.get_proof_conclusion self#status
722 method setGoal n = userGoal <- n
725 let s = self#getFuture in
726 let rec is_there_and_executable s =
727 if Pcre.pmatch ~rex:only_dust_RE s then raise Margin;
728 let st = GrafiteParser.parse_statement (Stream.of_string s) in
730 | GrafiteAst.Comment (loc,_)->
731 let parsed_text_length = snd (CicNotationPt.loc_of_floc loc) in
732 let remain_len = String.length s - parsed_text_length in
733 let next = String.sub s parsed_text_length remain_len in
734 is_there_and_executable next
735 | GrafiteAst.Executable (loc, ex) -> false
738 is_there_and_executable s
740 | CicNotationParser.Parse_error _ -> false
747 MatitaLog.debug "script status:";
748 MatitaLog.debug ("history size: " ^ string_of_int (List.length history));
749 MatitaLog.debug (sprintf "%d statements:" (List.length statements));
750 List.iter MatitaLog.debug statements;
751 MatitaLog.debug ("Current file name: " ^
752 (match guistuff.filenamedata with
753 |None,_ -> "[ no name ]"
758 let _script = ref None
760 let script ~source_view ~init ~mathviewer ~urichooser ~develcreator ~ask_confirmation ~set_star ()
763 ~source_view ~init ~mathviewer ~ask_confirmation ~urichooser ~develcreator ~set_star ()
768 let instance () = match !_script with None -> assert false | Some s -> s