]> matita.cs.unibo.it Git - helm.git/blobdiff - matita/matita/matita.ml
Code clean-up
[helm.git] / matita / matita / matita.ml
index 1457862e425f243d75553b1b537c376d65d55b2e..a149829230ff96ea619936c2ed98c0160117607d 100644 (file)
@@ -47,57 +47,39 @@ let _ =
 let gui = MatitaGui.instance ()
 
 let script =
-  let s = 
-    MatitaScript.script 
-      ~source_view:gui#sourceView
-      ~mathviewer:(MatitaMathView.mathViewer ())
-      ~urichooser:(fun uris ->
-        try
-          MatitaGui.interactive_uri_choice ~selection_mode:`SINGLE
-          ~title:"Matita: URI chooser" 
-          ~msg:"Select the URI" ~hide_uri_entry:true
-          ~hide_try:true ~ok_label:"_Apply" ~ok_action:`SELECT
-          ~copy_cb:(fun s -> gui#sourceView#buffer#insert ("\n"^s^"\n"))
-          () ~id:"boh?" uris
-        with MatitaTypes.Cancel -> [])
-      ~set_star:gui#setStar
-      ~ask_confirmation:
-        (fun ~title ~message -> 
-            MatitaGtkMisc.ask_confirmation ~title ~message 
-            ~parent:gui#main#toplevel ())
-      ()
-  in
+ MatitaScript.script 
+   ~urichooser:(fun source_view uris ->
+     try
+       MatitaGui.interactive_uri_choice ~selection_mode:`SINGLE
+       ~title:"Matita: URI chooser" 
+       ~msg:"Select the URI" ~hide_uri_entry:true
+       ~hide_try:true ~ok_label:"_Apply" ~ok_action:`SELECT
+       ~copy_cb:(fun s -> source_view#buffer#insert ("\n"^s^"\n"))
+       () ~id:"boh?" uris
+     with MatitaTypes.Cancel -> [])
+   ~ask_confirmation:
+     (fun ~title ~message -> 
+         MatitaGtkMisc.ask_confirmation ~title ~message 
+         ~parent:gui#main#toplevel ())
+   ()
+
+let _ =
   Predefined_virtuals.load_predefined_virtuals ();
   Predefined_virtuals.load_predefined_classes ();
-  gui#sourceView#source_buffer#begin_not_undoable_action ();
-  s#reset (); 
-  s#template (); 
-  gui#sourceView#source_buffer#end_not_undoable_action ();
-  s
   
   (* math viewers *)
 let _ =
-  let cic_math_view = MatitaMathView.cicMathView_instance () in
   let sequents_viewer = MatitaMathView.sequentsViewer_instance () in
   sequents_viewer#load_logo;
-  cic_math_view#set_href_callback
-    (Some (fun uri ->
-      let uri =
-       try
-        `Uri (UriManager.uri_of_string uri)
-       with
-        UriManager.IllFormedUri _ ->
-         `NRef (NReference.reference_of_string uri)
-      in
-      (MatitaMathView.cicBrowser ())#load uri));
   let browser_observer _ = MatitaMathView.refresh_all_browsers () in
   let sequents_observer grafite_status =
     sequents_viewer#reset;
-    match grafite_status#proof_status with
-    | Incomplete_proof ({ stack = stack } as incomplete_proof) ->
-        sequents_viewer#load_sequents grafite_status incomplete_proof;
+    match grafite_status#ng_mode with
+       `ProofMode ->
+        sequents_viewer#nload_sequents grafite_status;
         (try
-          script#setGoal (Some (Continuationals.Stack.find_goal stack));
+          script#setGoal
+           (Some (Continuationals.Stack.find_goal grafite_status#stack));
           let goal =
            match script#goal with
               None -> assert false
@@ -105,24 +87,7 @@ let _ =
           in
            sequents_viewer#goto_sequent grafite_status goal
         with Failure _ -> script#setGoal None);
-    | Proof proof -> sequents_viewer#load_logo_with_qed
-    | No_proof ->
-       (match grafite_status#ng_mode with
-           `ProofMode ->
-            sequents_viewer#nload_sequents grafite_status;
-            (try
-              script#setGoal
-               (Some (Continuationals.Stack.find_goal grafite_status#stack));
-              let goal =
-               match script#goal with
-                  None -> assert false
-                | Some n -> n
-              in
-               sequents_viewer#goto_sequent grafite_status goal
-            with Failure _ -> script#setGoal None);
-         | `CommandMode -> sequents_viewer#load_logo
-       )
-    | Intermediate _ -> assert false (* only the engine may be in this state *)
+     | `CommandMode -> sequents_viewer#load_logo
   in
   script#addObserver sequents_observer;
   script#addObserver browser_observer
@@ -150,7 +115,7 @@ let _ =
     in
     addDebugItem "dump aliases" (fun _ ->
       let status = script#grafite_status in
-      LexiconEngine.dump_aliases prerr_endline "" status);
+      GrafiteDisambiguate.dump_aliases prerr_endline "" status);
 (* FG: DEBUGGING   
     addDebugItem "dump interpretations" (fun _ ->
       let status = script#lexicon_status in
@@ -162,45 +127,9 @@ let _ =
          (fun x l -> (LexiconAstPp.pp_command x)::l)
          (filter status.LexiconEngine.lexicon_content_rev) [])));
 *)
-    addDebugItem "print metasenv goals and stack to stderr"
-      (fun _ ->
-        prerr_endline ("metasenv goals: " ^ String.concat " "
-          (List.map (fun (g, _, _) -> string_of_int g)
-            (MatitaScript.current ())#proofMetasenv));
-        prerr_endline ("stack: " ^ Continuationals.Stack.pp
-          (GrafiteTypes.get_stack (MatitaScript.current ())#grafite_status)));
-     addDebugItem "Print current proof term" 
-       (fun _ -> 
-        HLog.debug
-          (CicPp.ppterm 
-            (match 
-            (MatitaScript.current ())#grafite_status#proof_status
-            with
-            | GrafiteTypes.No_proof -> (Cic.Implicit None)
-            | Incomplete_proof i -> 
-                 let _,_,_subst,p,_, _ = i.GrafiteTypes.proof in 
-                 Lazy.force p
-            | Proof p -> let _,_,_subst,p,_, _ = p in Lazy.force p
-            | Intermediate _ -> assert false)));
-     addDebugItem "Print current proof (natural language) to stderr" 
-       (fun _ -> 
-        prerr_endline 
-          (ApplyTransformation.txt_of_cic_object 120 [] 
-            ~map_unicode_to_tex:(Helm_registry.get_bool
-              "matita.paste_unicode_as_tex")
-            (match 
-            (MatitaScript.current ())#grafite_status#proof_status
-            with
-            | GrafiteTypes.No_proof -> assert false
-            | Incomplete_proof i -> 
-                let _,m,_subst,p,ty, attrs = i.GrafiteTypes.proof in 
-                Cic.CurrentProof ("current (incomplete) proof",m,Lazy.force p,ty,[],attrs)
-            | Proof (_,m,_subst,p,ty, attrs) -> 
-                Cic.CurrentProof ("current proof",m,Lazy.force p,ty,[],attrs)
-            | Intermediate _ -> assert false)));
     addDebugSeparator ();
     addDebugCheckbox "high level pretty printer" ~init:true
-      (fun mi () -> CicMetaSubst.use_low_level_ppterm_in_context := mi#active);
+      (fun mi () -> assert false (* MATITA 1.0 *));
     addDebugSeparator ();
     addDebugItem "always show all disambiguation errors"
       (fun _ -> MatitaGui.all_disambiguation_passes := true);
@@ -215,7 +144,7 @@ let _ =
       (fun mi () -> NCicRefiner.debug := mi#active; NCicUnification.debug :=
               mi#active; MultiPassDisambiguator.debug := mi#active; NCicMetaSubst.debug := mi#active);
     addDebugCheckbox "reduction logging"
-      (fun mi () -> NCicReduction.debug := mi#active; CicReduction.ndebug := mi#active);
+      (fun mi () -> NCicReduction.debug := mi#active);
     addDebugSeparator ();
     addDebugItem "Expand virtuals"
     (fun _ -> (MatitaScript.current ())#expandAllVirtuals);
@@ -238,6 +167,7 @@ let _ =
       (fun _ ->
         prerr_endline "Still cleaning the library: don't be impatient!"));
    prerr_endline "Matita is cleaning up. Please wait.";
+   (*CSC: MatitaScript.current () makes no sense here *)
    let baseuri = 
     (MatitaScript.current ())#grafite_status#baseuri
    in