From: Stefano Zacchiroli Date: Thu, 21 Apr 2005 12:07:24 +0000 (+0000) Subject: utilities for creating environment dumps X-Git-Tag: after_svn_merge~30 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=567bddeb2cb49029607b7517fbcaa9a973cb0d23;p=helm.git utilities for creating environment dumps --- diff --git a/helm/ocaml/cic_proof_checking/utilities/Makefile b/helm/ocaml/cic_proof_checking/utilities/Makefile new file mode 100644 index 000000000..2cd98f894 --- /dev/null +++ b/helm/ocaml/cic_proof_checking/utilities/Makefile @@ -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 index 000000000..dbfde26cb --- /dev/null +++ b/helm/ocaml/cic_proof_checking/utilities/create_environment.ml @@ -0,0 +1,49 @@ + +let trust = true + +let outfname = + match Sys.argv.(1) with + | "-help" | "--help" | "-h" | "--h" -> + print_endline + ("Usage: create_environment \n" ^ + " is the file where environment will be dumped\n" ^ + " 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 index 000000000..8dad4e68d --- /dev/null +++ b/helm/ocaml/cic_proof_checking/utilities/list_uris.ml @@ -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 index 000000000..0fefc4211 --- /dev/null +++ b/helm/ocaml/cic_proof_checking/utilities/parse_library.ml @@ -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 +