Debian Codegraph @

topbin/rocqworker_with_drop.ml

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 (* We register this handler for lower-level toplevel loading code *)
12 let () = CErrors.register_handler (function
13 | Symtable.Error e ->
14 Some (Pp.str (Format.asprintf "%a" Symtable.report_error e))
15 | _ ->
16 None
17 )
18
19 (* Another bit of text is printed in the [include_utilities] file, so the default one is not need *)
20 let () = Clflags.noversion := true
21
22 let load_module fmt name =
23 if not ((Topdirs.load_file [@ocaml.warning "-3"]) fmt name) then
24 CErrors.user_err Pp.(str ("Could not load plugin " ^ name))
25
26 let load_plugin fmt ps =
27 let lib = Mltop.PluginSpec.to_package ps in
28 Topfind.load_deeply [lib]
29
30 let ml_loop fmt ?init_file () =
31 let init_file = ref init_file in
32 Toploop.add_hook (fun event ->
33 if event = Toploop.After_setup then begin
34 match !init_file with
35 | None -> ()
36 | Some f ->
37 init_file := None; (* Run the initialization file only once *)
38 ignore (Coq_byte_config.toploop_use_silently fmt f)
39 end
40 );
41 Coq_byte_config.compenv_handle_exit_with_status_0 (fun () ->
42 Coq_byte_config.toploop_prep_and_loop fmt)
43
44 let drop_setup () =
45 let ppf = Format.std_formatter in
46 Mltop.set_top
47 { load_plugin = load_plugin ppf
48 ; load_module = load_module ppf
49 ; add_dir = Topdirs.dir_directory
50 ; ml_loop = ml_loop ppf
51 }
52
53 (* Main coqtop initialization *)
54 let () =
55 drop_setup ();
56 Coqtop.(start_coq coqtop_toplevel (List.tl (Array.to_list Sys.argv)))