]> matita.cs.unibo.it Git - helm.git/blob - matita/matitac.ml
34e0639e3aa62ebfd422fb7a02c7a5ac7e5d1d6b
[helm.git] / matita / matitac.ml
1 (* Copyright (C) 2005, HELM Team.
2  * 
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.
6  * 
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.
11  * 
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.
16  *
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,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 (* $Id$ *)
27
28 module G = GrafiteAst
29 module L = LexiconAst
30
31 (* from transcript *)
32
33 let out_comment och s =
34    let s = if s <> "" && s.[0] = '*' then "#" ^ s else s in 
35    Printf.fprintf och "%s%s%s\n\n" "(*" s "*)"
36
37 let out_line_comment och s =
38    let l = 70 - String.length s in
39    let s = Printf.sprintf " %s %s" s (String.make l '*') in
40    out_comment och s
41
42 let out_preamble och (path, lines) =
43    let ich = open_in path in
44    let rec print i =
45       if i > 0 then 
46          let s = input_line ich in
47          begin Printf.fprintf och "%s\n" s; print (pred i) end
48    in 
49    print lines;
50    out_line_comment och "This file was automatically generated: do not edit"
51
52 (* from matitacLib *)
53
54 let pp_ast_statement =
55   GrafiteAstPp.pp_statement ~term_pp:CicNotationPp.pp_term
56     ~lazy_term_pp:CicNotationPp.pp_term ~obj_pp:(CicNotationPp.pp_obj CicNotationPp.pp_term)
57
58 (**)
59
60 let dump f =
61    let och = open_out f in
62    let atexit () = close_out och in
63    let rt_base_dir = Filename.dirname Sys.argv.(0) in
64    let path = Filename.concat rt_base_dir "matita.ma.templ" in
65    let lines = 14 in
66    out_preamble och (path, lines);
67    let lexicon_engine_cb = function
68      | L.Include _ as ast -> output_string och (LexiconAstPp.pp_command ast)
69      | _                  -> ()
70    in
71    let matita_engine_cb = function
72       | G.Executable (_, G.Macro (_, G.Inline _)) 
73       | G.Executable (_, G.Command (_, G.Include _)) -> ()
74       | ast                                                 ->
75          output_string och (pp_ast_statement ast)
76    in
77    let matitac_lib_cb = output_string och in
78    LexiconEngine.set_callback lexicon_engine_cb;
79    MatitaEngine.set_callback matita_engine_cb;
80    MatitacLib.set_callback matitac_lib_cb;
81    at_exit atexit
82    
83 let main () =
84  match Filename.basename Sys.argv.(0) with
85  |"gragrep"    |"gragrep.opt"    |"gragrep.opt.static"    ->Gragrep.main()
86  |"matitadep"  |"matitadep.opt"  |"matitadep.opt.static"  ->Matitadep.main()
87  |"matitaclean"|"matitaclean.opt"|"matitaclean.opt.static"->Matitaclean.main()
88  |"matitamake" |"matitamake.opt" |"matitamake.opt.static" ->Matitamake.main()
89  |"matitaprover"|"matitaprover.opt"
90  |"matitaprover.opt.static" ->Matitaprover.main()
91  |"matitawiki"|"matitawiki.opt" ->MatitaWiki.main()
92  | _ ->
93 (*
94       let _ = Paramodulation.Saturation.init () in  *)
95 (* ALB to link paramodulation *)
96       let dump_msg = "<filename> Dump source with expanded macros to <filename>" in
97       MatitaInit.add_cmdline_spec ["-dump", Arg.String dump, dump_msg];
98       let _ = MatitacLib.main `COMPILER in
99       ()
100
101 let _ = main ()
102