]> matita.cs.unibo.it Git - helm.git/blob - matita/components/binaries/mac/mac.ml
d5826e619461beaed3462885fd74d4ffb618e246
[helm.git] / matita / components / binaries / mac / mac.ml
1 module A = Arg
2 module P = Printf
3
4 module O = Options 
5 module L = Lexer
6
7 let help   = "Usage: mac [ -LX ]* [ <file> ]*"
8 let help_L = " Activate lexer debugging"
9 let help_Q = " Read data from standard input"
10 let help_V = " Show version information"
11 let help_X = " Reset options and counters"
12
13 let active = ref false
14
15 let process_channel ich =
16    let lexbuf = Lexing.from_channel ich in
17    L.token lexbuf; active := true
18
19 let output_version () =
20    P.printf "mac 0.1.0 M - November 2012\n"
21
22 let process_stdin () =
23    process_channel stdin
24
25 let process_file fname =
26    let ich = open_in fname in
27    process_channel ich; close_in ich
28
29 let output_count () =
30    if !active then P.printf "%u\n" !O.count
31
32 let main () =
33    A.parse [
34       "-L", A.Set O.debug_lexer, help_L;
35       "-Q", Arg.Unit process_stdin, help_Q; 
36       "-V", Arg.Unit output_version, help_V; 
37       "-X", A.Unit O.clear, help_X;
38    ] process_file help;
39    output_count ()
40
41 let _ = main ()