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 remove_closed_substs s =
27 Pcre.replace ~pat:"{...}" ~templ:"" s
29 let term2pres n ids_to_inner_sorts annterm =
30 let ast, ids_to_uris =
31 TermAcicContent.ast_of_acic ids_to_inner_sorts annterm
34 CicNotationPres.box_of_mpres (
35 CicNotationPres.render ~prec:90 ids_to_uris
36 (TermContentPres.pp_ast ast)
39 let render = function _::x::_ -> x | _ -> assert false in
40 let mpres = CicNotationPres.mpres_of_box bobj in
41 let s = BoxPp.render_to_string render n mpres in
42 remove_closed_substs s
44 let obj_to_string n style prefix obj =
45 let aobj,_,_,ids_to_inner_sorts,ids_to_inner_types,_,_ =
46 try Cic2acic.acic_object_of_cic_object obj
48 let msg = "Cic2ACic: " ^ Printexc.to_string e in
52 | GrafiteAst.Declarative ->
53 let cobj = Acic2content.annobj2content ids_to_inner_sorts ids_to_inner_types aobj in
54 let bobj = Content2pres.content2pres ids_to_inner_sorts cobj in
55 remove_closed_substs ("\n\n" ^
56 BoxPp.render_to_string (function _::x::_ -> x | _ -> assert false) n (CicNotationPres.mpres_of_box bobj)
58 | GrafiteAst.Procedural ->
59 let term_pp = term2pres (n - 8) ids_to_inner_sorts in
60 let lazy_term_pp = term_pp in
61 let obj_pp = CicNotationPp.pp_obj term_pp in
62 let aux = GrafiteAstPp.pp_statement ~term_pp ~lazy_term_pp ~obj_pp in
63 let script = Acic2Procedural.acic2procedural
64 ~ids_to_inner_sorts ~ids_to_inner_types prefix aobj in
65 "\n\n" ^ String.concat "" (List.map aux script)