]> matita.cs.unibo.it Git - helm.git/blob - matitaB/components/disambiguation/disambiguate.mli
bb20ff86635ca1ec53a6b218b610c7f36b97f2a7
[helm.git] / matitaB / components / disambiguation / disambiguate.mli
1 (* Copyright (C) 2004, HELM Team.
2  * 
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.
6  * 
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.
11  * 
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.
16  *
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,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 (** {2 Disambiguation interface} *)
27
28 (** raised when ambiguous input is found but not expected (e.g. in the batch
29   * compiler) *)
30 exception Ambiguous_input
31
32 (* the integer is an offset to be added to each location *)
33 (* list of located error messages, each list is a tuple:
34   * - environment in string form
35   * - environment patch
36   * - location
37   * - error message
38   * - significancy of the error message, if false the error is likely to be
39   *   useless for the final user ... *)
40 exception NoWellTypedInterpretation of
41  int *
42  ((Stdpp.location list * string * string) list *
43   (DisambiguateTypes.domain_item * string) list *
44   (Stdpp.location * string) Lazy.t *
45   bool) list
46 exception PathNotWellFormed
47
48 type 'a disambiguator_input = string * int * 'a
49     
50 type domain = domain_tree list
51 and domain_tree = 
52   Node of Stdpp.location list * DisambiguateTypes.domain_item * domain
53
54 type ('term,'metasenv,'subst,'graph) test_result =
55   | Ok of 'term * 'metasenv * 'subst * 'graph
56   | Ko of (Stdpp.location * string) Lazy.t
57   | Uncertain of (Stdpp.location * string) Lazy.t
58
59 exception Try_again of string Lazy.t
60
61 val set_choose_uris_callback:
62   DisambiguateTypes.interactive_user_uri_choice_type -> unit
63
64 val set_choose_interp_callback:
65   DisambiguateTypes.interactive_interpretation_choice_type -> unit
66
67 val set_choose_disamb_callback:
68   DisambiguateTypes.interactive_ast_choice_type -> unit
69
70 (** @raise Ambiguous_input if called, default value for internal
71   * choose_uris_callback if not set otherwise with set_choose_uris_callback
72   * above *)
73 val mono_uris_callback: DisambiguateTypes.interactive_user_uri_choice_type
74
75 (** @raise Ambiguous_input if called, default value for internal
76   * choose_interp_callback if not set otherwise with set_choose_interp_callback
77   * above *)
78 val mono_interp_callback: DisambiguateTypes.interactive_interpretation_choice_type
79
80 val resolve : 
81   env:'alias1 DisambiguateTypes.InterprEnv.t ->
82   universe: GrafiteAst.alias_spec list DisambiguateTypes.Environment.t ->
83   mk_choice:('alias1 -> 'term DisambiguateTypes.codomain_item) ->
84   DisambiguateTypes.InterprEnv.key -> 'alias1 option -> 
85    [`Num_arg of string | `Args of 'term list] -> 'term
86
87 val find_in_context: string -> string option list -> int
88 val domain_of_term: context:
89   string option list -> NotationPt.term -> domain
90 val domain_of_obj: 
91   context:string option list -> NotationPt.term NotationPt.obj -> domain
92
93 val disambiguate_thing:
94   context:'context ->
95   metasenv:'metasenv ->
96   subst:'subst ->
97   use_coercions:bool ->
98   string_context_of_context:('context -> string option list) ->
99   initial_ugraph:'ugraph ->
100   expty: 'refined_thing option ->
101   mk_implicit:(bool -> 'alias) ->
102   description_of_alias:('alias -> string) ->
103   fix_instance:(DisambiguateTypes.domain_item -> 'alias list -> 'alias list) ->
104   aliases:'alias DisambiguateTypes.InterprEnv.t ->
105   universe:GrafiteAst.alias_spec list DisambiguateTypes.Environment.t ->
106   lookup_in_library:(
107     DisambiguateTypes.interactive_user_uri_choice_type ->
108     DisambiguateTypes.input_or_locate_uri_type ->
109     DisambiguateTypes.Environment.key ->
110     'alias list) ->
111   uri:'uri ->
112   pp_thing:('ast_thing -> string) ->
113   pp_term:(NotationPt.term -> string) ->
114   domain_of_thing:(context: string option list -> 'ast_thing -> domain) ->
115   interpretate_thing:(
116     context:'context ->
117     env:'alias DisambiguateTypes.InterprEnv.t ->
118     universe: GrafiteAst.alias_spec list DisambiguateTypes.Environment.t ->
119     uri:'uri ->
120     is_path:bool -> 
121     'ast_thing -> 
122     localization_tbl:'cichash -> 
123       'raw_thing) ->
124   refine_thing:(
125     'metasenv -> 'subst -> 'context -> 'uri -> use_coercions:bool ->
126     'raw_thing -> 'refined_thing option -> 'ugraph -> localization_tbl:'cichash -> 
127       ('refined_thing, 'metasenv,'subst,'ugraph) test_result) ->
128   visit:(pp_term:(NotationPt.term -> string) ->
129          (NotationPt.term -> bool) -> 'ast_thing -> 
130         ((NotationPt.term -> 'ast_thing) * NotationPt.term) option) -> 
131   mk_localization_tbl:(int -> 'cichash) ->
132   'ast_thing disambiguator_input ->
133   ('ast_thing * 'metasenv * 'subst * 'refined_thing * 'ugraph) list * bool
134
135 val bfvisit :
136   pp_term:(NotationPt.term -> string) -> 
137   (NotationPt.term -> bool) ->
138    NotationPt.term -> ((NotationPt.term -> NotationPt.term) * NotationPt.term) option
139
140 val bfvisit_obj :
141   pp_term:(NotationPt.term -> string) -> 
142   (NotationPt.term -> bool) ->
143    NotationPt.term NotationPt.obj -> ((NotationPt.term -> NotationPt.term NotationPt.obj) * NotationPt.term) option