]> matita.cs.unibo.it Git - helm.git/commitdiff
added unification hint
authorEnrico Tassi <enrico.tassi@inria.fr>
Fri, 19 Dec 2008 10:09:53 +0000 (10:09 +0000)
committerEnrico Tassi <enrico.tassi@inria.fr>
Fri, 19 Dec 2008 10:09:53 +0000 (10:09 +0000)
helm/software/components/grafite_parser/grafiteDisambiguate.ml

index 29d1052ddaebf0643462083688a94c1b98f326bb..c1fd03af2225403f5fd3d5204f8a1525cdd34f88 100644 (file)
@@ -570,21 +570,7 @@ let disambiguate_obj lexicon_status ?baseuri metasenv (text,prefix_len,obj) =
          | None -> raise BaseUriNotSetYet)
     | CicNotationPt.Inductive _ -> assert false
     | CicNotationPt.Theorem _ -> None in
-  let time = Unix.gettimeofday () in 
-  let (diff, metasenv, _, cic, _) =
-    singleton "third"
-      (CicDisambiguate.disambiguate_obj 
-        ~lookup_in_library 
-        ~mk_choice:cic_mk_choice
-        ~mk_implicit
-        ~description_of_alias:LexiconAst.description_of_alias
-        ~aliases:lexicon_status.LexiconEngine.aliases
-        ~universe:(Some lexicon_status.LexiconEngine.multi_aliases) ~uri 
-        (text,prefix_len,obj)) in
-  
-  let time = Unix.gettimeofday () -. time in
-(*
-  prerr_endline ("VECCHIA DISAMBIGUAZIONE: " ^ string_of_float time);
+ let try_new cic =
   (NCicLibrary.clear_cache ();
    NCicEnvironment.invalidate ();
    OCic2NCic.clear ();
@@ -650,11 +636,44 @@ let disambiguate_obj lexicon_status ?baseuri metasenv (text,prefix_len,obj) =
 (*        | exn -> prerr_endline (Printexc.to_string exn) *)
        )
     | _ -> ())
-  ); 
+  )
+ in 
+
+(*
+ try
+  let time = Unix.gettimeofday () in 
 *)
-  
+
+  let (diff, metasenv, _, cic, _) =
+    singleton "third"
+      (CicDisambiguate.disambiguate_obj 
+        ~lookup_in_library 
+        ~mk_choice:cic_mk_choice
+        ~mk_implicit
+        ~description_of_alias:LexiconAst.description_of_alias
+        ~aliases:lexicon_status.LexiconEngine.aliases
+        ~universe:(Some lexicon_status.LexiconEngine.multi_aliases) ~uri 
+        (text,prefix_len,obj)) in
+
+(*
+  let time = Unix.gettimeofday () -. time in
+  prerr_endline ("VECCHIA DISAMBIGUAZIONE: " ^ string_of_float time);
+  try_new cic;
+*)
+
+
   let lexicon_status = LexiconEngine.set_proof_aliases lexicon_status diff in
   lexicon_status, metasenv, cic
+
+(*
+ with 
+ | Sys.Break as exn -> raise exn
+ | exn ->
+   try_new (Cic.InductiveDefinition ([],[],0,[])); 
+   raise exn
+*)
+
+;;
   
 let disambiguate_command lexicon_status ?baseuri metasenv (text,prefix_len,cmd)=
   match cmd with
@@ -677,6 +696,12 @@ let disambiguate_command lexicon_status ?baseuri metasenv (text,prefix_len,cmd)=
         disambiguate_term None text prefix_len lexicon_status_ref [] in
       let metasenv,t = disambiguate_term metasenv t in
       !lexicon_status_ref, metasenv, GrafiteAst.Coercion (loc,t,b,a,s)
+   | GrafiteAst.UnificationHint (loc, t) ->
+       let lexicon_status_ref = ref lexicon_status in 
+       let disambiguate_term =
+        disambiguate_term None text prefix_len lexicon_status_ref [] in
+      let metasenv,t = disambiguate_term metasenv t in
+      !lexicon_status_ref, metasenv, GrafiteAst.UnificationHint (loc,t)
    | GrafiteAst.Default _
    | GrafiteAst.Drop _
    | GrafiteAst.Include _