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/.
26 (******************************************************************************)
30 (* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
33 (* This is a textual interface to the Coq-like pretty printer cicPp for cic *)
34 (* terms exported in xml. It uses directly the modules cicPp and cache and *)
35 (* indirectly all the other modules (cicParser, cicParser2, cicParser3, *)
36 (* getter). The syntax is "experiment[.opt] filename1 ... filenamen" where *)
37 (* filenamei is the path-name of an xml file describing a cic term. On stdout *)
38 (* are pretty-printed all the n terms *)
40 (******************************************************************************)
42 let pretty_print = ref true;;
43 let read_from_stdin = ref false;;
44 let uris_in_input = ref false;;
49 print_endline ("^^^" ^ uri ^ "^^^") ;
50 print_string (CicPp.ppobj (CicCache.get_obj (UriManager.uri_of_string uri)));
51 print_endline ("\n$$$" ^ uri ^ "$$$\n")
56 let _ = CicCache.get_obj (UriManager.uri_of_string uri) in
57 print_endline " OK!" ;
62 let uri_of_filename fn =
63 if !uris_in_input then fn
66 Str.replace_first (Str.regexp (Str.quote Configuration.helm_dir)) "cic:" fn
68 let uri' = Str.replace_first (Str.regexp "\.xml$") "" uri in
72 let read_filenames_from_stdin () =
76 let l = Str.split (Str.regexp " ") (read_line ()) in
77 List.iter (fun x -> files := (uri_of_filename x) :: !files) l
81 files := List.rev !files ;
82 List.iter parse !files
85 (* filenames are read from command line and converted to uris via *)
86 (* uri_of_filenames; then the cic terms are load in cache via *)
87 (* CicCache.get_obj and then pretty printed via CicPp.ppobj *)
92 ["-nopp", Arg.Clear pretty_print, "Do not pretty print, parse only" ;
93 "-stdin", Arg.Set read_from_stdin, "Read from stdin" ;
94 "-uris", Arg.Set uris_in_input, "Read uris, not filenames" ;
95 "-update", Arg.Unit Getter.update, "Update the getter view of the world"]
96 (fun x -> files := (uri_of_filename x) :: !files)
98 usage: experiment file ...
101 if !read_from_stdin then read_filenames_from_stdin ()
104 files := List.rev !files;
105 List.iter parse !files