1 (* Copyright (C) 2004, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
26 (** {2 Disambiguation interface} *)
28 (* the integer is an offset to be added to each location *)
29 (* list of located error messages, each list is a tuple:
30 * - environment in string form
34 * - significancy of the error message, if false the error is likely to be
35 * useless for the final user ... *)
36 exception NoWellTypedInterpretation of
38 ((Stdpp.location list * string * string) list *
39 (DisambiguateTypes.domain_item * string) list *
40 (Stdpp.location * string) Lazy.t *
42 exception PathNotWellFormed
44 val interpretate_path :
45 context:Cic.name list -> CicNotationPt.term -> Cic.term
47 type 'a disambiguator_input = string * int * 'a
49 type domain = domain_tree list
51 Node of Stdpp.location list * DisambiguateTypes.domain_item * domain
53 type ('term,'metasenv,'subst,'graph) test_result =
54 | Ok of 'term * 'metasenv * 'subst * 'graph
55 | Ko of (Stdpp.location * string) Lazy.t
56 | Uncertain of (Stdpp.location * string) Lazy.t
58 exception Try_again of string Lazy.t
60 val domain_of_ast_term: context:Cic.name list -> CicNotationPt.term -> domain
62 module type Disambiguator =
64 val disambiguate_thing:
68 mk_implicit:([ `Closed ] option -> 'refined_thing) ->
69 initial_ugraph:'ugraph ->
70 hint: ('metasenv -> 'raw_thing -> 'raw_thing) *
71 (('refined_thing,'metasenv,'subst,'ugraph) test_result ->
72 ('refined_thing,'metasenv,'subst,'ugraph) test_result) ->
73 aliases:'refined_thing DisambiguateTypes.codomain_item DisambiguateTypes.Environment.t ->
74 universe:'refined_thing DisambiguateTypes.codomain_item list
75 DisambiguateTypes.Environment.t option ->
76 lookup_in_library:((selection_mode:[ `MULTIPLE | `SINGLE ] ->
78 ?enable_button_for_non_vars:bool ->
82 UriManager.uri list -> UriManager.uri list) ->
83 (title:string -> ?id:string -> unit -> UriManager.uri option) ->
84 DisambiguateTypes.Environment.key ->
85 'refined_thing DisambiguateTypes.codomain_item list) ->
87 pp_thing:('ast_thing -> string) ->
88 domain_of_thing:(context:'context -> 'ast_thing -> domain) ->
89 interpretate_thing:(context:'context ->
90 env:'refined_thing DisambiguateTypes.codomain_item
91 DisambiguateTypes.Environment.t ->
93 is_path:bool -> 'ast_thing -> localization_tbl:'cichash -> 'raw_thing) ->
94 refine_thing:('metasenv ->
99 'ugraph -> localization_tbl:'cichash ->
100 ('refined_thing, 'metasenv,'subst,'ugraph) test_result) ->
101 localization_tbl:'cichash ->
102 string * int * 'ast_thing ->
103 ((DisambiguateTypes.Environment.key *
104 'refined_thing DisambiguateTypes.codomain_item) list *
105 'metasenv * 'subst * 'refined_thing * 'ugraph)
108 val disambiguate_term :
109 ?fresh_instances:bool ->
110 context:Cic.context ->
111 metasenv:Cic.metasenv ->
112 subst:Cic.substitution ->
114 ?initial_ugraph:CicUniv.universe_graph ->
115 aliases:Cic.term DisambiguateTypes.environment ->(* previous interpretation status *)
116 universe:Cic.term DisambiguateTypes.multiple_environment option ->
117 lookup_in_library:((selection_mode:[ `MULTIPLE | `SINGLE ] ->
119 ?enable_button_for_non_vars:bool ->
123 UriManager.uri list -> UriManager.uri list) ->
124 (title:string -> ?id:string -> unit -> UriManager.uri option) ->
125 DisambiguateTypes.Environment.key ->
126 Cic.term DisambiguateTypes.codomain_item list) ->
127 CicNotationPt.term disambiguator_input ->
128 ((DisambiguateTypes.domain_item * Cic.term DisambiguateTypes.codomain_item) list *
129 Cic.metasenv * (* new metasenv *)
132 CicUniv.universe_graph) list * (* disambiguated term *)
135 val disambiguate_obj :
136 ?fresh_instances:bool ->
137 aliases:Cic.term DisambiguateTypes.environment ->(* previous interpretation status *)
138 universe:Cic.term DisambiguateTypes.multiple_environment option ->
139 uri:UriManager.uri option -> (* required only for inductive types *)
140 lookup_in_library:((selection_mode:[ `MULTIPLE | `SINGLE ] ->
142 ?enable_button_for_non_vars:bool ->
146 UriManager.uri list -> UriManager.uri list) ->
147 (title:string -> ?id:string -> unit -> UriManager.uri option) ->
148 DisambiguateTypes.Environment.key ->
149 Cic.term DisambiguateTypes.codomain_item list) ->
150 CicNotationPt.term CicNotationPt.obj disambiguator_input ->
151 ((DisambiguateTypes.domain_item * Cic.term DisambiguateTypes.codomain_item) list *
152 Cic.metasenv * (* new metasenv *)
155 CicUniv.universe_graph) list * (* disambiguated obj *)
159 module Make (C : DisambiguateTypes.Callbacks) : Disambiguator