1 (******************************************************************************)
5 (* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
8 (* This is a textual interface to the Coq-like pretty printer cicPp for cic *)
9 (* terms exported in xml. It uses directly the modules cicPp and cache and *)
10 (* indirectly all the other modules (cicParser, cicParser2, cicParser3, *)
11 (* getter). The syntax is "experiment[.opt] filename1 ... filenamen" where *)
12 (* filenamei is the path-name of an xml file describing a cic term. On stdout *)
13 (* are pretty-printed all the n terms *)
15 (******************************************************************************)
17 let pretty_print = ref true;;
18 let read_from_stdin = ref false;;
19 let uris_in_input = ref false;;
24 print_endline ("^^^" ^ uri ^ "^^^") ;
25 print_string (CicPp.ppobj (CicCache.get_obj (UriManager.uri_of_string uri)));
26 print_endline ("\n$$$" ^ uri ^ "$$$\n")
31 let _ = CicCache.get_obj (UriManager.uri_of_string uri) in
32 print_endline " OK!" ;
37 let uri_of_filename fn =
38 if !uris_in_input then fn
41 Str.replace_first (Str.regexp (Str.quote Configuration.helm_dir)) "cic:" fn
43 let uri' = Str.replace_first (Str.regexp "\.xml$") "" uri in
47 let read_filenames_from_stdin () =
51 let l = Str.split (Str.regexp " ") (read_line ()) in
52 List.iter (fun x -> files := (uri_of_filename x) :: !files) l
56 files := List.rev !files ;
57 List.iter parse !files
60 (* filenames are read from command line and converted to uris via *)
61 (* uri_of_filenames; then the cic terms are load in cache via *)
62 (* CicCache.get_obj and then pretty printed via CicPp.ppobj *)
67 ["-nopp", Arg.Clear pretty_print, "Do not pretty print, parse only" ;
68 "-stdin", Arg.Set read_from_stdin, "Read from stdin" ;
69 "-uris", Arg.Set uris_in_input, "Read uris, not filenames" ;
70 "-update", Arg.Unit Getter.update, "Update the getter view of the world"]
71 (fun x -> files := (uri_of_filename x) :: !files)
73 usage: experiment file ...
76 if !read_from_stdin then read_filenames_from_stdin ()
79 files := List.rev !files;
80 List.iter parse !files