diff options
author | Enrico Tassi <Enrico.Tassi@inria.fr> | 2015-10-06 14:11:19 +0200 |
---|---|---|
committer | Enrico Tassi <Enrico.Tassi@inria.fr> | 2015-10-08 09:51:13 +0200 |
commit | ce83c2b9fd1685e46049ee7f47c8716dcf66dbd1 (patch) | |
tree | f37a9f9b4aadcd6b07fce72885f879d457ab78dd /library/goptions.ml | |
parent | 27d4a636cb7f1fbdbced1980808a9b947405eeb5 (diff) |
Goptions: new value type: optional string
These options can be set to a string value, but also unset.
Internal data is of type string option.
Diffstat (limited to 'library/goptions.ml')
-rw-r--r-- | library/goptions.ml | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/library/goptions.ml b/library/goptions.ml index 4f50fbfbd..30d195f83 100644 --- a/library/goptions.ml +++ b/library/goptions.ml @@ -20,6 +20,7 @@ type option_value = | BoolValue of bool | IntValue of int option | StringValue of string + | StringOptValue of string option (** Summary of an option status *) type option_state = { @@ -293,6 +294,10 @@ let declare_string_option = declare_option (fun v -> StringValue v) (function StringValue v -> v | _ -> anomaly (Pp.str "async_option")) +let declare_stringopt_option = + declare_option + (fun v -> StringOptValue v) + (function StringOptValue v -> v | _ -> anomaly (Pp.str "async_option")) (* 3- User accessible commands *) @@ -324,11 +329,13 @@ let check_bool_value v = function let check_string_value v = function | StringValue _ -> StringValue v + | StringOptValue _ -> StringOptValue (Some v) | _ -> bad_type_error () let check_unset_value v = function | BoolValue _ -> BoolValue false | IntValue _ -> IntValue None + | StringOptValue _ -> StringOptValue None | _ -> bad_type_error () (* Nota: For compatibility reasons, some errors are treated as @@ -359,6 +366,8 @@ let msg_option_value (name,v) = | IntValue (Some n) -> int n | IntValue None -> str "undefined" | StringValue s -> str s + | StringOptValue None -> str"undefined" + | StringOptValue (Some s) -> str s (* | IdentValue r -> pr_global_env Id.Set.empty r *) let print_option_value key = |