+++ /dev/null
-(* Copyright (C) 2004, HELM Team.
- *
- * This file is part of HELM, an Hypertextual, Electronic
- * Library of Mathematics, developed at the Computer Science
- * Department, University of Bologna, Italy.
- *
- * HELM is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * HELM is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HELM; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- *
- * For details, see the HELM World-Wide-Web page,
- * http://helm.cs.unibo.it/
- *)
-
-class parserr () =
- object
- method parseTerm = CicTextualParser2.parse_term
- method parseTactical = CicTextualParser2.parse_tactical
- end
-
-class disambiguator
- ~parserr ~mqiconn ~(chooseUris: MatitaTypes.choose_uris_callback)
- ~(chooseInterp: MatitaTypes.choose_interp_callback) ()
- =
- let disambiguate_term =
- let module Callbacks =
- struct
- let interactive_user_uri_choice
- ~selection_mode ?ok ?(enable_button_for_non_vars = true) ~title ~msg
- ~id uris
- =
- chooseUris ~selection_mode ~title ~msg
- ~nonvars_button:enable_button_for_non_vars uris
-
- let interactive_interpretation_choice = chooseInterp
- let input_or_locate_uri ~(title:string) =
- (* TODO Zack: I try to avoid using this callback. I therefore assume
- * that the presence of an identifier that can't be resolved via
- * "locate" query is a syntax error *)
- MatitaTypes.not_implemented
- "MatitaDisambiguator: input_or_locate_uri callback"
- end
- in
- let module Disambiguator = Disambiguate.Make (Callbacks) in
- Disambiguator.disambiguate_term
- in
- object (self)
- val mutable parserr: parserr = parserr
- method parserr = parserr
- method setParserr p = parserr <- p
-
- val mutable _env = DisambiguateTypes.Environment.empty
- method env = _env
- method setEnv e = _env <- e
-
- method disambiguateTermAst ?(context = []) ?(metasenv = []) ?env termAst =
- let (save_state, env) =
- match env with
- | Some env -> (false, env)
- | None -> (true, _env)
- in
- match disambiguate_term mqiconn context metasenv termAst ~aliases:env with
- | [ (env, metasenv, term) as x ] ->
- if save_state then self#setEnv env;
- x
- | _ -> assert false
-
- method disambiguateTerm ?context ?metasenv ?env stream =
- self#disambiguateTermAst ?context ?metasenv ?env
- (parserr#parseTerm stream)
- end
-