let disambiguate_term ~context ~metasenv ~subst ~expty
?(initial_ugraph = CicUniv.oblivion_ugraph)
- ~mk_implicit ~description_of_alias ~mk_choice
+ ~mk_implicit ~description_of_alias ~fix_instance ~mk_choice
~aliases ~universe ~lookup_in_library (text,prefix_len,term)
=
let mk_localization_tbl x = Cic.CicHash.create x in
MultiPassDisambiguator.disambiguate_thing ~context ~metasenv ~subst
~initial_ugraph ~aliases ~string_context_of_context
~universe ~lookup_in_library ~mk_implicit ~description_of_alias
+ ~fix_instance
~uri:None ~pp_thing:CicNotationPp.pp_term
~domain_of_thing:Disambiguate.domain_of_term
~interpretate_thing:(interpretate_term (?create_dummy_ids:None) ~mk_choice)
~freshen_thing:CicNotationUtil.freshen_term
~passes:(MultiPassDisambiguator.passes ())
-let disambiguate_obj ~mk_implicit ~description_of_alias ~mk_choice
+let disambiguate_obj ~mk_implicit ~description_of_alias ~fix_instance ~mk_choice
~aliases ~universe ~lookup_in_library ~uri (text,prefix_len,obj)
=
let mk_localization_tbl x = Cic.CicHash.create x in
~aliases ~universe ~uri ~string_context_of_context
~pp_thing:(CicNotationPp.pp_obj CicNotationPp.pp_term)
~domain_of_thing:Disambiguate.domain_of_obj
- ~lookup_in_library ~mk_implicit ~description_of_alias
+ ~lookup_in_library ~mk_implicit ~description_of_alias ~fix_instance
~initial_ugraph:CicUniv.empty_ugraph
~interpretate_thing:(interpretate_obj ~mk_choice)
~refine_thing:refine_obj
?initial_ugraph:CicUniv.universe_graph ->
mk_implicit:(bool -> 'alias) ->
description_of_alias:('alias -> string) ->
+ fix_instance:(DisambiguateTypes.domain_item -> 'alias list -> 'alias list) ->
mk_choice:('alias -> Cic.term DisambiguateTypes.codomain_item) ->
aliases:'alias DisambiguateTypes.Environment.t ->
universe:'alias list DisambiguateTypes.Environment.t option ->
val disambiguate_obj :
mk_implicit:(bool -> 'alias) ->
description_of_alias:('alias -> string) ->
+ fix_instance:(DisambiguateTypes.domain_item -> 'alias list -> 'alias list) ->
mk_choice:('alias -> Cic.term DisambiguateTypes.codomain_item) ->
aliases:'alias DisambiguateTypes.Environment.t ->
universe:'alias list DisambiguateTypes.Environment.t option ->
let refine_profiler = HExtlib.profile "disambiguate_thing.refine_thing"
+type alias_spec =
+ | Ident_alias of string * string (* identifier, uri *)
+ | Symbol_alias of string * int * string (* name, instance no, description *)
+ | Number_alias of int * string (* instance no, description *)
+
let disambiguate_thing
~context ~metasenv ~subst ~use_coercions
~string_context_of_context
~initial_ugraph:base_univ ~expty
- ~mk_implicit ~description_of_alias
+ ~mk_implicit ~description_of_alias ~fix_instance
~aliases ~universe ~lookup_in_library
~uri ~pp_thing ~domain_of_thing ~interpretate_thing ~refine_thing
~mk_localization_tbl
input_or_locate_uri item
| Some e ->
(try
- let item =
- match item with
- | Symbol (symb, _) -> Symbol (symb, 0)
- | item -> item
- in
- Environment.find item e
+ fix_instance item (Environment.find item e)
with Not_found -> [])
in
(*
expty: 'refined_thing option ->
mk_implicit:(bool -> 'alias) ->
description_of_alias:('alias -> string) ->
+ fix_instance:(DisambiguateTypes.domain_item -> 'alias list -> 'alias list) ->
aliases:'alias DisambiguateTypes.Environment.t ->
universe:'alias list DisambiguateTypes.Environment.t option ->
lookup_in_library:(
| [] -> assert false
in
aux 1 [] passes
+;;
let disambiguate_thing ~passes ~freshen_thing ~context ~metasenv ~subst
~string_context_of_context ~initial_ugraph ~expty ~mk_implicit
- ~description_of_alias ~aliases ~universe ~lookup_in_library ~uri ~pp_thing
- ~domain_of_thing ~interpretate_thing ~refine_thing ~mk_localization_tbl thing
+ ~description_of_alias ~fix_instance ~aliases ~universe ~lookup_in_library
+ ~uri ~pp_thing ~domain_of_thing ~interpretate_thing ~refine_thing
+ ~mk_localization_tbl thing
=
let f ~fresh_instances ~aliases ~universe ~use_coercions (txt,len,thing) =
let thing = if fresh_instances then freshen_thing thing else thing in
Disambiguate.disambiguate_thing
~context ~metasenv ~subst ~use_coercions ~string_context_of_context
- ~initial_ugraph ~expty ~mk_implicit ~description_of_alias
+ ~initial_ugraph ~expty ~mk_implicit ~description_of_alias ~fix_instance
~aliases ~universe ~lookup_in_library
~uri ~pp_thing ~domain_of_thing ~interpretate_thing ~refine_thing
~mk_localization_tbl (txt,len,thing)
in
- disambiguate_thing ~description_of_alias ~passes ~aliases ~universe ~f thing
+ disambiguate_thing ~description_of_alias ~passes ~aliases
+ ~universe ~f thing
expty: 'refined_thing option ->
mk_implicit:(bool -> 'alias) ->
description_of_alias:('alias -> string) ->
+ fix_instance:(DisambiguateTypes.domain_item -> 'alias list -> 'alias list) ->
aliases:'alias DisambiguateTypes.Environment.t ->
universe:'alias list
DisambiguateTypes.Environment.t option ->
| _ -> lookup_in_library interactive_user_uri_choice input_or_locate_uri item
;;
+let fix_instance item l =
+ match item with
+ DisambiguateTypes.Symbol (_,n) ->
+ List.map
+ (function
+ LexiconAst.Symbol_alias (s,_,d) -> LexiconAst.Symbol_alias (s,n,d)
+ | _ -> assert false
+ ) l
+ | DisambiguateTypes.Num n ->
+ List.map
+ (function
+ LexiconAst.Number_alias (_,d) -> LexiconAst.Number_alias (n,d)
+ | _ -> assert false
+ ) l
+ | DisambiguateTypes.Id _ -> l
+;;
+
+
(** @param term not meaningful when context is given *)
let disambiguate_term expty text prefix_len lexicon_status_ref context metasenv
term =
~expty ~universe:(Some lexicon_status#lstatus.LexiconEngine.multi_aliases)
~lookup_in_library
~mk_choice:cic_mk_choice
- ~mk_implicit
+ ~mk_implicit ~fix_instance
~description_of_alias:LexiconAst.description_of_alias
~context ~metasenv ~subst:[] (text,prefix_len,term))
in
~universe:(Some estatus#lstatus.LexiconEngine.multi_aliases)
~lookup_in_library:nlookup_in_library
~mk_choice:ncic_mk_choice
- ~mk_implicit
+ ~mk_implicit ~fix_instance
~description_of_alias:LexiconAst.description_of_alias
~context ~metasenv ~subst thing)
in
(CicDisambiguate.disambiguate_term
~lookup_in_library
~mk_choice:cic_mk_choice
- ~mk_implicit
+ ~mk_implicit ~fix_instance
~description_of_alias:LexiconAst.description_of_alias
~initial_ugraph:ugraph ~aliases:lexicon_status#lstatus.LexiconEngine.aliases
~universe:(Some lexicon_status#lstatus.LexiconEngine.multi_aliases)
(CicDisambiguate.disambiguate_obj
~lookup_in_library
~mk_choice:cic_mk_choice
- ~mk_implicit
+ ~mk_implicit ~fix_instance
~description_of_alias:LexiconAst.description_of_alias
~aliases:estatus#lstatus.LexiconEngine.aliases
~universe:(Some estatus#lstatus.LexiconEngine.multi_aliases)
~lookup_in_library:nlookup_in_library
~description_of_alias:LexiconAst.description_of_alias
~mk_choice:ncic_mk_choice
- ~mk_implicit
+ ~mk_implicit ~fix_instance
~uri:(OCic2NCic.nuri_of_ouri uri)
~rdb:estatus
~aliases:estatus#lstatus.LexiconEngine.aliases
;;
let disambiguate_term ~context ~metasenv ~subst ~expty
- ~mk_implicit ~description_of_alias ~mk_choice
+ ~mk_implicit ~description_of_alias ~fix_instance ~mk_choice
~aliases ~universe ~rdb ~lookup_in_library
(text,prefix_len,term)
=
MultiPassDisambiguator.disambiguate_thing
~freshen_thing:CicNotationUtil.freshen_term
~context ~metasenv ~initial_ugraph:() ~aliases
- ~mk_implicit ~description_of_alias
+ ~mk_implicit ~description_of_alias ~fix_instance
~string_context_of_context:(List.map (fun (x,_) -> Some x))
~universe ~uri:None ~pp_thing:CicNotationPp.pp_term
~passes:(MultiPassDisambiguator.passes ())
;;
let disambiguate_obj
- ~mk_implicit ~description_of_alias ~mk_choice
+ ~mk_implicit ~description_of_alias ~fix_instance ~mk_choice
~aliases ~universe ~rdb ~lookup_in_library ~uri
(text,prefix_len,obj)
=
MultiPassDisambiguator.disambiguate_thing
~freshen_thing:CicNotationUtil.freshen_obj
~context:[] ~metasenv:[] ~subst:[] ~initial_ugraph:() ~aliases
- ~mk_implicit ~description_of_alias
+ ~mk_implicit ~description_of_alias ~fix_instance
~string_context_of_context:(List.map (fun (x,_) -> Some x))
~universe
~uri:(Some uri)
expty:NCic.term option ->
mk_implicit: (bool -> 'alias) ->
description_of_alias:('alias -> string) ->
+ fix_instance:(DisambiguateTypes.domain_item -> 'alias list -> 'alias list) ->
mk_choice:('alias -> NCic.term DisambiguateTypes.codomain_item) ->
aliases:'alias DisambiguateTypes.Environment.t ->
universe:'alias list DisambiguateTypes.Environment.t option ->
bool
val disambiguate_obj :
- mk_implicit:(bool -> 'a) ->
- description_of_alias:('a -> string) ->
- mk_choice:('a -> NCic.term DisambiguateTypes.codomain_item) ->
- aliases:'a DisambiguateTypes.Environment.t ->
- universe:'a list DisambiguateTypes.Environment.t option ->
- rdb:#NRstatus.status ->
- lookup_in_library:(DisambiguateTypes.interactive_user_uri_choice_type ->
- DisambiguateTypes.input_or_locate_uri_type ->
- DisambiguateTypes.Environment.key -> 'a list) ->
- uri:NUri.uri ->
- string * int * CicNotationPt.term CicNotationPt.obj ->
- ((DisambiguateTypes.Environment.key * 'a) list * NCic.metasenv *
- NCic.substitution * NCic.obj)
- list * bool
+ mk_implicit:(bool -> 'alias) ->
+ description_of_alias:('alias -> string) ->
+ fix_instance:(DisambiguateTypes.domain_item -> 'alias list -> 'alias list) ->
+ mk_choice:('alias -> NCic.term DisambiguateTypes.codomain_item) ->
+ aliases:'alias DisambiguateTypes.Environment.t ->
+ universe:'alias list DisambiguateTypes.Environment.t option ->
+ rdb:#NRstatus.status ->
+ lookup_in_library:(
+ DisambiguateTypes.interactive_user_uri_choice_type ->
+ DisambiguateTypes.input_or_locate_uri_type ->
+ DisambiguateTypes.Environment.key ->
+ 'alias list) ->
+ uri:NUri.uri ->
+ string * int * CicNotationPt.term CicNotationPt.obj ->
+ ((DisambiguateTypes.Environment.key * 'alias) list * NCic.metasenv *
+ NCic.substitution * NCic.obj)
+ list * bool
val disambiguate_path: CicNotationPt.term -> NCic.term