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/
28 method parseTerm = CicTextualParser2.parse_term
29 method parseTactical = CicTextualParser2.parse_tactical
33 ~parserr ~mqiconn ~(chooseUris: MatitaTypes.choose_uris_callback)
34 ~(chooseInterp: MatitaTypes.choose_interp_callback) ()
36 let disambiguate_term =
37 let module Callbacks =
39 let interactive_user_uri_choice
40 ~selection_mode ?ok ?(enable_button_for_non_vars = true) ~title ~msg
43 chooseUris ~selection_mode ~title ~msg
44 ~nonvars_button:enable_button_for_non_vars uris
46 let interactive_interpretation_choice = chooseInterp
47 let input_or_locate_uri ~(title:string) =
48 (* TODO Zack: I try to avoid using this callback. I therefore assume
49 * that the presence of an identifier that can't be resolved via
50 * "locate" query is a syntax error *)
51 MatitaTypes.not_implemented
52 "MatitaDisambiguator: input_or_locate_uri callback"
55 let module Disambiguator = Disambiguate.Make (Callbacks) in
56 Disambiguator.disambiguate_term
59 val mutable parserr: parserr = parserr
60 method parserr = parserr
61 method setParserr p = parserr <- p
63 val mutable _env = DisambiguateTypes.Environment.empty
65 method setEnv e = _env <- e
67 method disambiguateTermAst ?(context = []) ?(metasenv = []) ?env termAst =
68 let (save_state, env) =
70 | Some env -> (false, env)
71 | None -> (true, _env)
73 match disambiguate_term mqiconn context metasenv termAst ~aliases:env with
74 | [ (env, metasenv, term) as x ] ->
75 if save_state then self#setEnv env;
79 method disambiguateTerm ?context ?metasenv ?env stream =
80 self#disambiguateTermAst ?context ?metasenv ?env
81 (parserr#parseTerm stream)