]> matita.cs.unibo.it Git - helm.git/blob - matita/components/binaries/matex/matex.ml
- matex: support for alpha-conversion completed
[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
19 module X = Ground
20 module G = Options
21 module E = Engine
22 module O = TeXOutput
23 module K = Kernel
24
25 let help_O = "<dir> Set this output directory"
26 let help_X = " Clear configuration and options"
27 let help_a = " Log alpha-unconverted identifiers (default: no)"
28 let help_l = "<file> Output the list of generated files in this file"
29 let help_p = " omit types (default: no)"
30 let help_t = " Test term transformations (default: no)"
31
32 let help   = ""
33
34 (* internal functions *******************************************************)
35
36 let alpha_decode = R.triple R.string R.string R.string
37
38 let init registry =
39    R.load_from registry; 
40    if !G.no_init then begin
41       K.init ();
42       G.no_init := false;
43    end;
44    G.alpha_type := R.get_list alpha_decode "matex.alpha.type";
45    G.alpha_sort := R.get_list alpha_decode "matex.alpha.sort"
46
47 let is_registry s =
48    F.check_suffix s ".conf.xml"
49
50 let no_init () =
51    failwith "MaTeX: main: registry not initialized" 
52
53 let malformed s =
54    failwith ("MaTeX: main: malformed argument: " ^ s)
55
56 let set_list fname =
57    let file = F.concat !G.out_dir fname in
58    G.close_list (); G.list_och := Some (open_out file)
59
60 let process s =
61    if is_registry s then init s
62    else if !G.no_init then no_init ()
63    else if L.is_uri s then E.process (U.uri_of_string s)
64    else malformed s
65
66 let main =
67 begin try
68    A.parse [
69       "-O", A.String ((:=) G.out_dir), help_O;
70       "-X", A.Unit G.clear, help_X;
71       "-a", A.Set G.log_alpha, help_a;
72       "-l", A.String set_list, help_l;
73       "-p", A.Set G.no_types, help_p;
74       "-t", A.Set G.test, help_t;
75    ] process help
76 with
77    | X.Error s -> X.log s
78 end;
79 G.close_list ()