1 (* Copyright (C) 2005, 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 let load_notation fname =
27 let ic = open_in fname in
28 let lexbuf = Ulexing.from_utf8_channel ic in
31 match GrafiteParser.parse_statement lexbuf with
32 | GrafiteAst.Executable (_, GrafiteAst.Command (_, cmd)) ->
33 ignore (CicNotation.process_notation cmd)
36 with End_of_file -> close_in ic
38 let parse_environment str =
39 let stream = Ulexing.from_utf8_string str in
40 let environment = ref DisambiguateTypes.Environment.empty in
41 let multiple_environment = ref DisambiguateTypes.Environment.empty in
45 match GrafiteParser.parse_statement stream with
46 GrafiteAst.Executable (_, GrafiteAst.Command (_, GrafiteAst.Alias (_,alias)))
48 | _ -> assert false in
50 (*CSC: Warning: this code should be factorized with the corresponding
51 code in MatitaEngine *)
53 GrafiteAst.Ident_alias (id,uri) ->
54 DisambiguateTypes.Id id,
55 (uri,(fun _ _ _-> CicUtil.term_of_uri (UriManager.uri_of_string uri)))
56 | GrafiteAst.Symbol_alias (symb,instance,desc) ->
57 DisambiguateTypes.Symbol (symb,instance),
58 DisambiguateChoices.lookup_symbol_by_dsc symb desc
59 | GrafiteAst.Number_alias (instance,desc) ->
60 DisambiguateTypes.Num instance,
61 DisambiguateChoices.lookup_num_by_dsc desc
63 environment := DisambiguateTypes.Environment.add key value !environment;
64 multiple_environment := DisambiguateTypes.Environment.cons key value !multiple_environment;
68 !environment, !multiple_environment