Debian Codegraph @

vernac/vernacoptions.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 open Util
12 open Goptions
13 open Vernacexpr
14
15 let vernac_set_option ~locality ~stage key opt =
16 match opt with
17 | OptionUnset -> unset_option_value_gen ~locality ~stage key
18 | OptionSetString s -> set_string_option_value_gen ~locality ~stage key s
19 | OptionSetInt n -> set_int_option_value_gen ~locality ~stage key (Some n)
20 | OptionSetTrue -> set_bool_option_value_gen ~locality ~stage key true
21
22 let warn_set_append_deprecated =
23 CWarnings.create ~name:"set-append-deprecated" ~category:Deprecation.Version.v9_1
24 Pp.(fun () -> str "Set ... Append is not supported.")
25
26 let vernac_set_option ~locality ~stage table v =
27 let table =
28 if String.equal "Append" (List.last table) then begin
29 let table = List.drop_last table in
30 let () = match table with
31 | ["Warnings"]|["Debug"] -> ()
32 | _ ->
33 CErrors.user_err
34 Pp.(str "Set ... Append not allowed with " ++ prlist_with_sep spc str table ++ str ".")
35 in
36 warn_set_append_deprecated ();
37 table
38 end
39 else table
40 in
41 vernac_set_option ~locality ~stage table v
42
43 let iter_table f k v = Goptions.iter_table (Global.env()) f k v
44
45 let vernac_add_option local = iter_table { aux = fun table env x -> table.add env local x }
46
47 let vernac_remove_option local = iter_table { aux = fun table env x -> table.remove env local x }
48
49 let vernac_mem_option = iter_table { aux = fun table -> table.mem }
50
51 let vernac_print_option key =
52 try (get_ref_table key).print ()
53 with Not_found ->
54 try (get_string_table key).print ()
55 with Not_found ->
56 try print_option_value key
57 with Not_found -> error_undeclared_key key