1 (* Copyright (C) 2000, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
28 module MO = MetaOutput
31 let version_string = "Helena Checker 0.8.0 M - November 2008" in
32 let summary = ref 0 in
34 let meta_file = ref None in
35 let set_summary i = summary := i in
36 let print_version () = print_endline version_string; exit 0 in
37 let set_stage i = stage := i in
40 | Some (och, _) -> close_out och
42 let set_meta_file name =
44 let och = open_out name in
45 let frm = Format.formatter_of_out_channel och in
46 Format.pp_set_margin frm max_int;
47 meta_file := Some (och, frm)
50 if !summary > 0 then Time.gmtime version_string;
52 Printf.printf "Processing file: %s\n" name; flush stdout;
53 if !summary > 0 then Time.utime_stamp "started";
54 let ich = open_in name in
55 let lexbuf = Lexing.from_channel ich in
56 let book = AutParser.book AutLexer.token lexbuf in
58 if !summary > 0 then Time.utime_stamp "parsed";
59 let rec aux ac mc st = function
62 let ac = if !summary > 2 then AO.count_item Cps.id ac item else ac in
64 let mc = if !summary > 2 then MO.count_item Cps.id mc item else mc in
65 begin match !meta_file with
67 | Some (_, frm) -> MO.pp_item Cps.id frm item
71 let st, mc = if !stage > 0 then MA.meta_of_aut f st item else st, mc in
75 aux AO.initial_counters MO.initial_counters MA.initial_status book
77 if !summary > 0 then Time.utime_stamp "processed";
78 if !summary > 2 then AO.print_counters Cps.id ac;
79 if !summary > 2 && !stage > 0 then MO.print_counters Cps.id mc;
81 let help = "Usage: helena [ -V | -Ss <number> | -m <file> ] <file> ..." in
82 let help_S = "<number> Set summary level" in
83 let help_V = " Show version information" in
84 let help_m = "<file> output intermediate representation" in
85 let help_s = "<number> Set translation stage" in
87 ("-S", Arg.Int set_summary, help_S);
88 ("-V", Arg.Unit print_version, help_V);
89 ("-m", Arg.String set_meta_file, help_m);
90 ("-s", Arg.Int set_stage, help_s);
92 if !summary > 0 then Time.utime_stamp "at exit"