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