]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/bin/recomm/recomm.ml
update in ground
[helm.git] / matita / matita / contribs / lambdadelta / bin / recomm / recomm.ml
1 module EC = RecommCheck
2 module EL = RecommLexer
3 module EI = RecommInput
4 module EO = RecommOutput
5
6 module P1 = RecommPccFor
7 module P2 = RecommPcsAnd
8 module P3 = RecommPcsPar
9
10 module G = RecommGc
11
12 let write = ref false
13
14 let force = ref false
15
16 let chdir path =
17   Sys.chdir path
18
19 let rec process path name =
20   let file = Filename.concat path name in 
21   if Sys.is_directory file then begin
22     let dir = Sys.readdir file in
23     Array.iter (process file) dir
24   end else
25   if Filename.extension file = ".ma" then begin
26     Printf.eprintf "processing: %S\n" file;
27     let orig = EI.read_srcs file in
28     let lint = EC.recomm_srcs orig in
29     if !force || (!write && lint <> orig) then EO.write_srcs file lint
30   end else begin
31     Printf.eprintf "skipping: %S\n" file
32   end
33
34 let msg_C = "<dir>  Set this working directory (default: .)"
35 let msg_L = " Log lexer tokens (default: no)"
36 let msg_c = "<int>  Set these output columns (default: 78)"
37 let msg_d = " Log with dark colors (default: no)"
38 let msg_f = " Write all output files (default: no)"
39 let msg_k = " Log key comments (default: no)"
40 let msg_m = " Log mark comments (default: no)"
41 let msg_n = " Log with no colors (default: yes)"
42 let msg_o = " Log other comments (default: no)"
43 let msg_r = " Replace the input files (default: no)"
44 let msg_s = " Log section comments (default: no)"
45 let msg_t = " Log title comments (default: no)"
46 let msg_w = " Write the changed output files (default: no)"
47
48 let main =
49   Arg.parse [
50     "-C", Arg.String chdir, msg_C;
51     "-L", Arg.Set EL.debug, msg_m;
52     "-c", Arg.Int ((:=) EO.width), msg_c;
53     "-d", Arg.Clear EC.bw, msg_d;
54     "-f", Arg.Set force, msg_f;
55     "-k", Arg.Set EC.log_k, msg_k;
56     "-m", Arg.Set EC.log_m, msg_m;
57     "-n", Arg.Set EC.bw, msg_n;
58     "-o", Arg.Set EC.log_o, msg_o;
59     "-r", Arg.Set EO.replace, msg_r;
60     "-s", Arg.Set EC.log_s, msg_s;
61     "-t", Arg.Set EC.log_t, msg_t;
62     "-w", Arg.Set write, msg_w;
63   ] (process "") ""