]> matita.cs.unibo.it Git - helm.git/commitdiff
utilities for creating environment dumps
authorStefano Zacchiroli <zack@upsilon.cc>
Thu, 21 Apr 2005 12:07:24 +0000 (12:07 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Thu, 21 Apr 2005 12:07:24 +0000 (12:07 +0000)
helm/ocaml/cic_proof_checking/utilities/Makefile [new file with mode: 0644]
helm/ocaml/cic_proof_checking/utilities/create_environment.ml [new file with mode: 0644]
helm/ocaml/cic_proof_checking/utilities/list_uris.ml [new file with mode: 0644]
helm/ocaml/cic_proof_checking/utilities/parse_library.ml [new file with mode: 0644]

diff --git a/helm/ocaml/cic_proof_checking/utilities/Makefile b/helm/ocaml/cic_proof_checking/utilities/Makefile
new file mode 100644 (file)
index 0000000..2cd98f8
--- /dev/null
@@ -0,0 +1,15 @@
+UTILITIES = create_environment parse_library list_uris
+UTILITIES_OPT = $(patsubst %,%.opt,$(UTILITIES))
+LINKOPTS = -linkpkg -thread
+LIBS = helm-cic_proof_checking
+OCAMLC = ocamlfind ocamlc $(LINKOPTS) -package $(LIBS)
+OCAMLOPT = ocamlfind opt $(LINKOPTS) -package $(LIBS)
+all: $(UTILITIES)
+opt: $(UTILITIES_OPT)
+%: %.ml
+       $(OCAMLC) -o $@ $<
+%.opt: %.ml
+       $(OCAMLOPT) -o $@ $<
+clean:
+       rm -f $(UTILITIES) $(UTILITIES_OPT) *.cm[iox] *.o
+
diff --git a/helm/ocaml/cic_proof_checking/utilities/create_environment.ml b/helm/ocaml/cic_proof_checking/utilities/create_environment.ml
new file mode 100644 (file)
index 0000000..dbfde26
--- /dev/null
@@ -0,0 +1,49 @@
+
+let trust = true
+
+let outfname =
+  match Sys.argv.(1) with
+    | "-help" | "--help" | "-h" | "--h" ->
+          print_endline
+            ("Usage: create_environment <dumpfile> <uri_index>\n" ^
+             "  <dumpfile>   is the file where environment will be dumped\n" ^
+             "  <uri_index>  is the file containing the URIs, one per line,\n" ^
+             "               that will be typechecked. Could be \"-\" for\n" ^
+             "               standard input");
+          flush stdout;
+          exit 0
+    | f -> f
+let _ =
+  CicEnvironment.set_trust (fun _ -> trust);
+  Helm_registry.set "getter.mode" "remote";
+  Helm_registry.set "getter.url" "http://mowgli.cs.unibo.it:58081/";
+  Sys.catch_break true;
+  if Sys.file_exists outfname then begin
+    let ic = open_in outfname in
+    CicEnvironment.restore_from_channel ic;
+    close_in ic
+  end
+let urifname =
+  try
+    Sys.argv.(2)
+  with Invalid_argument _ -> "-"
+let ic =
+  match urifname with
+    | "-" -> stdin
+    | fname -> open_in fname
+let _ =
+  try
+    while true do
+(*       try *)
+        let uri = input_line ic in
+        print_endline uri;
+        flush stdout;
+        let uri = UriManager.uri_of_string uri in
+        ignore (CicTypeChecker.typecheck uri CicUniv.empty_ugraph)
+(*       with Sys.Break -> () *)
+    done
+  with End_of_file | Sys.Break ->
+    let oc = open_out outfname in
+    CicEnvironment.dump_to_channel oc;
+    close_out oc
+
diff --git a/helm/ocaml/cic_proof_checking/utilities/list_uris.ml b/helm/ocaml/cic_proof_checking/utilities/list_uris.ml
new file mode 100644 (file)
index 0000000..8dad4e6
--- /dev/null
@@ -0,0 +1,5 @@
+let ic = open_in Sys.argv.(1) in
+CicEnvironment.restore_from_channel ic;
+List.iter
+  (fun uri -> print_endline (UriManager.string_of_uri uri))
+  (CicEnvironment.list_uri ())
diff --git a/helm/ocaml/cic_proof_checking/utilities/parse_library.ml b/helm/ocaml/cic_proof_checking/utilities/parse_library.ml
new file mode 100644 (file)
index 0000000..0fefc42
--- /dev/null
@@ -0,0 +1,30 @@
+
+let trust = true
+
+let _ =
+  CicEnvironment.set_trust (fun _ -> trust);
+  Helm_registry.set "getter.mode" "remote";
+  Helm_registry.set "getter.url" "http://mowgli.cs.unibo.it:58081/"
+let urifname =
+  try
+    Sys.argv.(1)
+  with Invalid_argument _ -> "-"
+let ic =
+  match urifname with
+    | "-" -> stdin
+    | fname -> open_in fname
+let _ =
+  try
+    while true do
+      try
+        let uri = input_line ic in
+        prerr_endline uri;
+        let uri = UriManager.uri_of_string uri in
+        ignore (CicEnvironment.get_obj CicUniv.empty_ugraph uri)
+(*       with Sys.Break -> () *)
+      with 
+        | End_of_file -> raise End_of_file
+        | exn -> ()
+    done
+  with End_of_file -> Unix.sleep max_int
+