X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fmatita%2FmatitaDisambiguator.ml;h=325e290a74f4636d231d136b2b2f2995808cc597;hb=78d6c353f0288a1b3b86aeb43b22a483c34822d9;hp=cd4d42420de20f6ddc815d7bbbaa80a60f43955f;hpb=b12aa2f7dc56d9915603339e9a1e1ba23d834b4a;p=helm.git diff --git a/helm/matita/matitaDisambiguator.ml b/helm/matita/matitaDisambiguator.ml index cd4d42420..325e290a7 100644 --- a/helm/matita/matitaDisambiguator.ml +++ b/helm/matita/matitaDisambiguator.ml @@ -28,6 +28,9 @@ open Printf open MatitaTypes exception Ambiguous_input +(* the integer is an offset to be added to each location *) +exception DisambiguationError of + int * (Token.flocation option * string Lazy.t) list list type choose_uris_callback = id:string -> UriManager.uri list -> UriManager.uri list @@ -79,8 +82,8 @@ let disambiguate_thing ~aliases ~universe = assert (universe <> None); let library = false, DisambiguateTypes.Environment.empty, None in - let multi_aliases=false, DisambiguateTypes.Environment.empty, universe in - let mono_aliases = true, aliases, None in + let multi_aliases = false, DisambiguateTypes.Environment.empty, universe in + let mono_aliases = true, aliases, Some DisambiguateTypes.Environment.empty in let passes = (* *) [ (false, mono_aliases, false); (false, multi_aliases, false); @@ -103,18 +106,23 @@ let disambiguate_thing ~aliases ~universe else drop_aliases_and_clear_diff res in - let rec aux = + let rec aux errors = function - | [ pass ] -> set_aliases pass (try_pass pass) + | [ pass ] -> + (try + set_aliases pass (try_pass pass) + with Disambiguate.NoWellTypedInterpretation (offset,newerrors) -> + raise (DisambiguationError (offset, errors @ [newerrors]))) | hd :: tl -> (try set_aliases hd (try_pass hd) - with Disambiguate.NoWellTypedInterpretation -> aux tl) + with Disambiguate.NoWellTypedInterpretation (_offset,newerrors) -> + aux (errors @ [newerrors]) tl) | [] -> assert false in let saved_use_coercions = !CoercDb.use_coercions in try - let res = aux passes in + let res = aux [] passes in CoercDb.use_coercions := saved_use_coercions; res with exn -> @@ -135,10 +143,10 @@ type disambiguator_thing = } let disambiguate_thing = - let profiler = CicUtil.profile "disambiguate_thing" in + let profiler = HExtlib.profile "disambiguate_thing" in { do_it = fun ~aliases ~universe ~f ~drop_aliases ~drop_aliases_and_clear_diff thing - -> profiler.CicUtil.profile + -> profiler.HExtlib.profile (disambiguate_thing ~aliases ~universe ~f ~drop_aliases ~drop_aliases_and_clear_diff) thing }