]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/cic_proof_checking/utilities/create_environment.ml
utilities for creating environment dumps
[helm.git] / helm / ocaml / cic_proof_checking / utilities / create_environment.ml
1
2 let trust = true
3
4 let outfname =
5   match Sys.argv.(1) with
6     | "-help" | "--help" | "-h" | "--h" ->
7           print_endline
8             ("Usage: create_environment <dumpfile> <uri_index>\n" ^
9              "  <dumpfile>   is the file where environment will be dumped\n" ^
10              "  <uri_index>  is the file containing the URIs, one per line,\n" ^
11              "               that will be typechecked. Could be \"-\" for\n" ^
12              "               standard input");
13           flush stdout;
14           exit 0
15     | f -> f
16 let _ =
17   CicEnvironment.set_trust (fun _ -> trust);
18   Helm_registry.set "getter.mode" "remote";
19   Helm_registry.set "getter.url" "http://mowgli.cs.unibo.it:58081/";
20   Sys.catch_break true;
21   if Sys.file_exists outfname then begin
22     let ic = open_in outfname in
23     CicEnvironment.restore_from_channel ic;
24     close_in ic
25   end
26 let urifname =
27   try
28     Sys.argv.(2)
29   with Invalid_argument _ -> "-"
30 let ic =
31   match urifname with
32     | "-" -> stdin
33     | fname -> open_in fname
34 let _ =
35   try
36     while true do
37 (*       try *)
38         let uri = input_line ic in
39         print_endline uri;
40         flush stdout;
41         let uri = UriManager.uri_of_string uri in
42         ignore (CicTypeChecker.typecheck uri CicUniv.empty_ugraph)
43 (*       with Sys.Break -> () *)
44     done
45   with End_of_file | Sys.Break ->
46     let oc = open_out outfname in
47     CicEnvironment.dump_to_channel oc;
48     close_out oc
49