]> matita.cs.unibo.it Git - helm.git/blob - matita/components/binaries/matex/matex.ml
- First commit of MaTeX:
[helm.git] / matita / components / binaries / matex / matex.ml
1 (*
2     ||M||  This file is part of HELM, an Hypertextual, Electronic        
3     ||A||  Library of Mathematics, developed at the Computer Science     
4     ||T||  Department, University of Bologna, Italy.                     
5     ||I||                                                                
6     ||T||  HELM is free software; you can redistribute it and/or         
7     ||A||  modify it under the terms of the GNU General Public License   
8     \   /  version 2 or (at your option) any later version.      
9      \ /   This software is distributed as is, NO WARRANTY.     
10       V_______________________________________________________________ *)
11
12 module A = Arg
13 module F = Filename
14
15 module U = NUri
16 module R = Helm_registry
17 module L = Librarian
18 module B = NCicLibrary
19 module C = NCicTypeChecker
20 module H = HLog
21
22 module G = Options
23 module E = Engine
24 module O = TeXOutput
25
26 let help_O = "<dir> Set this output directory"
27 let help_X = " Clear configuration and options"
28
29 let help   = ""
30
31 (* internal functions *******************************************************)
32
33 let trusted _ = true
34
35 let no_log _ _ = ()
36
37 let init registry =
38    R.load_from registry; 
39    if !G.no_init then begin
40       B.init (); 
41       C.set_trust trusted;
42       H.set_log_callback no_log;
43       G.no_init := false;
44    end
45
46 let is_registry s =
47    F.check_suffix s ".conf.xml"
48
49 let no_init () =
50    failwith "MaTeX: registry not initialized" 
51
52 let malformed s =
53    failwith ("MaTeX: malformed argument: " ^ s)
54
55 let process s =
56    if is_registry s then init s
57    else if !G.no_init then no_init ()
58    else if L.is_uri s then E.process (U.uri_of_string s)
59    else malformed s
60
61 let main =
62    A.parse [
63       "-O", A.String ((:=) G.out_dir), help_O;
64       "-X", A.Unit G.clear, help_X;
65    ] process help