1 (* Copyright (C) 2000, 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://cs.unibo.it/helm/.
28 module NP = CicNotationPp
29 module GP = GrafiteAstPp
33 let floc = H.dummy_floc
35 let out_verbatim och s =
36 Printf.fprintf och "%s" s
38 let out_comment och s =
39 Printf.fprintf och "%s%s%s\n\n" "(*" s "*)"
41 let out_line_comment och s =
42 let l = 70 - String.length s in
43 Printf.fprintf och "%s %s %s%s\n\n" "(*" s (String.make l '*') "*)"
45 let out_preamble och (path, lines) =
46 let ich = open_in path in
49 let s = input_line ich in
50 begin Printf.fprintf och "%s\n" s; print (pred i) end
53 out_line_comment och "This file was automatically generated: do not edit"
55 let out_command och cmd =
56 let term_pp = NP.pp_term in
57 let lazy_term_pp = NP.pp_term in
58 let obj_pp = NP.pp_obj in
59 let s = GP.pp_statement ~term_pp ~lazy_term_pp ~obj_pp cmd in
60 Printf.fprintf och "%s\n\n" s
62 let command_of_obj obj =
63 G.Executable (floc, G.Command (floc, obj))
66 command_of_obj (G.Set (floc, key, value))
69 command_of_obj (G.Include (floc, value ^ ".ma"))
71 let commit och items =
73 | T.Heading heading -> out_preamble och heading
74 | T.BaseUri baseuri -> out_command och (set "baseuri" baseuri)
75 | T.Include inc -> () (* *)
76 | T.Coercion coercion -> () (* *)
77 | T.Notation notation -> () (* *)
78 | T.Inline iniline -> () (* *)
79 | T.Comment comment -> () (* out_comment och comment *)
80 | T.Unexport unexport -> () (* *)
81 | T.Verbatim verbatim -> out_verbatim och verbatim
84 List.iter commit (List.rev items)