int *
((Stdpp.location list * string * string) list *
(DisambiguateTypes.domain_item * DisambiguateTypes.codomain_item) list *
- Stdpp.location option * string Lazy.t * bool) list
+ (Stdpp.location * string) Lazy.t * bool) list
exception PathNotWellFormed
(** raised when an environment is not enough informative to decide *)
type ('term,'metasenv,'subst,'graph) test_result =
| Ok of 'term * 'metasenv * 'subst * 'graph
- | Ko of Stdpp.location option * string Lazy.t
- | Uncertain of Stdpp.location option * string Lazy.t
+ | Ko of (Stdpp.location * string) Lazy.t
+ | Uncertain of (Stdpp.location * string) Lazy.t
let refine_term metasenv subst context uri term ugraph ~localization_tbl =
(* if benchmark then incr actual_refinements; *)
exn ->
let rec process_exn loc =
function
- HExtlib.Localized (loc,exn) -> process_exn (Some loc) exn
+ HExtlib.Localized (loc,exn) -> process_exn loc exn
| CicRefine.Uncertain msg ->
debug_print (lazy ("UNCERTAIN!!! [" ^ (Lazy.force msg) ^ "] " ^ CicPp.ppterm term)) ;
- Uncertain (loc,msg)
+ Uncertain (lazy (loc,Lazy.force msg))
| CicRefine.RefineFailure msg ->
debug_print (lazy (sprintf "PRUNED!!!\nterm%s\nmessage:%s"
(CicPp.ppterm term) (Lazy.force msg)));
- Ko (loc,msg)
+ Ko (lazy (loc,Lazy.force msg))
| exn -> raise exn
in
- process_exn None exn
+ process_exn Stdpp.dummy_loc exn
let refine_obj metasenv subst context uri obj ugraph ~localization_tbl =
assert (context = []);
exn ->
let rec process_exn loc =
function
- HExtlib.Localized (loc,exn) -> process_exn (Some loc) exn
+ HExtlib.Localized (loc,exn) -> process_exn loc exn
| CicRefine.Uncertain msg ->
debug_print (lazy ("UNCERTAIN!!! [" ^
(Lazy.force msg) ^ "] " ^ CicPp.ppobj obj)) ;
- Uncertain (loc,msg)
+ Uncertain (lazy (loc,Lazy.force msg))
| CicRefine.RefineFailure msg ->
debug_print (lazy (sprintf "PRUNED!!!\nterm%s\nmessage:%s"
(CicPp.ppobj obj) (Lazy.force msg))) ;
- Ko (loc,msg)
+ Ko (lazy (loc,Lazy.force msg))
| exn -> raise exn
in
- process_exn None exn
+ process_exn Stdpp.dummy_loc exn
let resolve (env: codomain_item Environment.t) (item: domain_item) ?(num = "") ?(args = []) () =
try
k
in refine_profiler.HExtlib.profile foo ()
with
- | Try_again msg -> Uncertain (None,msg)
- | Invalid_choice (loc,msg) -> Ko (loc,msg)
+ | Try_again msg -> Uncertain (lazy (Stdpp.dummy_loc,Lazy.force msg))
+ | Invalid_choice (None,msg) -> Ko(lazy (Stdpp.dummy_loc,Lazy.force msg))
+ | Invalid_choice (Some loc,msg) -> Ko (lazy (loc,Lazy.force msg))
in
(* (4) build all possible interpretations *)
let (@@) (l1,l2,l3) (l1',l2',l3') = l1@l1', l2@l2', l3@l3' in
(match test_env aliases rem_dom base_univ with
| Ok (thing, metasenv,subst,new_univ) ->
[ aliases, diff, metasenv, subst, thing, new_univ ], [], []
- | Ko (loc,msg) -> [],[],[aliases,diff,loc,msg,true]
- | Uncertain (loc,msg) ->
- [],[aliases,diff,loc,msg],[])
+ | Ko loc_msg -> [],[],[aliases,diff,loc_msg,true]
+ | Uncertain loc_msg ->
+ [],[aliases,diff,loc_msg],[])
| Node (locs,item,inner_dom) :: remaining_dom ->
debug_print (lazy (sprintf "CHOOSED ITEM: %s"
(string_of_domain_item item)));
match choices with
[] ->
[], [],
- [aliases, diff, Some (List.hd locs),
- lazy ("No choices for " ^ string_of_domain_item item),
+ [aliases, diff,
+ (lazy (List.hd locs,
+ "No choices for " ^ string_of_domain_item item)),
true]
(*
| [codomain_item] ->
| _::_ ->
let mark_not_significant failures =
List.map
- (fun (env, diff, loc, msg, _b) ->
- env, diff, loc, msg, false)
+ (fun (env, diff, loc_msg, _b) ->
+ env, diff, loc_msg, false)
failures in
let classify_errors ((ok_l,uncertain_l,error_l) as outcome) =
if ok_l <> [] || uncertain_l <> [] then
)
in
res @@ filter tl
- | Uncertain (loc,msg) ->
+ | Uncertain loc_msg ->
let res =
(match inner_dom with
- | [] -> [],[new_env,new_diff,loc,msg],[]
+ | [] -> [],[new_env,new_diff,loc_msg],[]
| _ ->
aux new_env new_diff None inner_dom
(remaining_dom@rem_dom)
)
in
res @@ filter tl
- | Ko (loc,msg) ->
- let res = [],[],[new_env,new_diff,loc,msg,true] in
+ | Ko loc_msg ->
+ let res = [],[],[new_env,new_diff,loc_msg,true] in
res @@ filter tl)
in
let ok_l,uncertain_l,error_l =
) ok_l ([],[],error_l)
in
List.fold_right
- (fun (env,diff,_,_) res ->
+ (fun (env,diff,_) res ->
aux env diff None remaining_dom rem_dom @@ res
) uncertain_l res_after_ok_l
in
| Ok _
| Uncertain _ ->
aux aliases diff lookup_in_todo_dom todo_dom []
- | Ko (loc,msg) -> [],[],[aliases,diff,loc,msg,true] in
+ | Ko (loc_msg) -> [],[],[aliases,diff,loc_msg,true] in
try
let res =
match aux' aliases [] None todo_dom with
| [],uncertain,errors ->
let errors =
List.map
- (fun (env,diff,loc,msg) -> (env,diff,loc,msg,true)
+ (fun (env,diff,loc_msg) -> (env,diff,loc_msg,true)
) uncertain @ errors
in
let errors =
List.map
- (fun (env,diff,loc,msg,significant) ->
+ (fun (env,diff,loc_msg,significant) ->
let env' =
filter_map_domain
(fun locs domain_item ->
Not_found -> None)
thing_dom
in
- env',diff,loc,msg,significant
+ env',diff,loc_msg,significant
) errors
in
raise (NoWellTypedInterpretation (0,errors))
let debug_print _ = ();;
-let refine_term metasenv subst context uri term ugraph ~localization_tbl =
+let refine_term metasenv subst context uri term _ ~localization_tbl =
assert (uri=None);
debug_print (lazy (sprintf "TEST_INTERPRETATION: %s"
(NCicPp.ppterm ~metasenv ~subst ~context term)));
try
let localise t =
- try NCic.NCicHash.find localization_tbl t
+ try NCicUntrusted.NCicHash.find localization_tbl t
with Not_found -> assert false
in
- let metasenv, subst, term, ty =
- NCicRefine.typeof metasenv subst context term None ~localise
+ let metasenv, subst, term, _ =
+ NCicRefiner.typeof metasenv subst context term None ~localise
in
Disambiguate.Ok (term, metasenv, subst, ())
with
- | NCicRefine.Uncertain (loc, msg) ->
- debug_print (lazy ("UNCERTAIN: [" ^ Lazy.force msg ^ "] " ^
+ | NCicRefiner.Uncertain (msg) ->
+ debug_print (lazy ("UNCERTAIN: [" ^ snd (Lazy.force msg) ^ "] " ^
NCicPp.ppterm ~metasenv ~subst ~context term)) ;
- Disambiguate.Uncertain (loc,msg,())
- | NCicRefine.RefineFailure (loc,msg) ->
+ Disambiguate.Uncertain (loc,msg)
+ | NCicRefiner.RefineFailure (msg) ->
debug_print (lazy (sprintf "PRUNED:\nterm%s\nmessage:%s"
- (NCicPp.ppterm ~metasenv ~subst ~context term) (Lazy.force msg)));
+ (NCicPp.ppterm ~metasenv ~subst ~context term) (snd(Lazy.force msg))));
Disambiguate.Ko (loc,msg,())
;;
let interpretate_term ?(create_dummy_ids=false) ~context ~env ~uri ~is_path ast
~localization_tbl
=
- assert false
-(*
let context = List.map (function None -> NCic.Anonymous | Some (n,_) -> n) context in
interpretate_term ~create_dummy_ids ~context ~env ~uri ~is_path ast
~localization_tbl
-*)
;;
let domain_of_term ~context =
(List.map
(fun (pass,l) ->
List.map
- (fun (env,diff,offset,msg,significant) ->
- offset, [[pass], [[pass], env, diff], msg, significant]) l
+ (fun (env,diff,offset_msg,significant) ->
+ let offset, msg = Lazy.force offset_msg in
+ offset, [[pass], [[pass], env, diff], lazy msg, significant]) l
) errorll) in
(* Here we are doing a stable sort and list_uniq returns the latter
"equal" element. I.e. we are showing the error corresponding to the
| GrafiteDisambiguator.DisambiguationError (offset,errorll) ->
let loc =
match errorll with
- ((_,_,Some floc,_,_)::_)::_ ->
- let (x, y) = HExtlib.loc_of_floc floc in
- let x = x + offset in
- let y = y + offset in
- let floc = HExtlib.floc_of_loc (x,y) in
- Some floc
- | _ -> None in
+ | ((_,_,loc_msg,_)::_)::_ ->
+ let floc, _ = Lazy.force loc_msg in
+ if floc = Stdpp.dummy_loc then None else
+ let (x, y) = HExtlib.loc_of_floc floc in
+ let x = x + offset in
+ let y = y + offset in
+ let floc = HExtlib.floc_of_loc (x,y) in
+ Some floc
+ | _ -> assert false
+ in
let annotated_errorll =
List.rev
(snd
let msg =
(List.map (fun (passes,_,_,floc,msg,significant) ->
let loc_descr =
- match floc with
- None -> ""
- | Some floc ->
- let (x, y) = HExtlib.loc_of_floc floc in
- sprintf " at %d-%d" (x+offset) (y+offset)
+ if floc = HExtlib.dummy_floc then ""
+ else
+ let (x, y) = HExtlib.loc_of_floc floc in
+ sprintf " at %d-%d" (x+offset) (y+offset)
in
"*" ^ (if not significant then "(Spurious?) " else "")
^ "Error" ^ loc_descr ^ ": " ^ Lazy.force msg,