FlagsParsing of command line arguments
Flags are separated based on the technique(s) they impact. Global flags are the ones that don't impact any technique, or impact all of them. Log flags, help flags, timeout flags... are global flags.
NB: when adding a boolean flag, make sure to parse its value with the bool_of_string function.
Adding a new flag impacts three pieces of code. The first is the body of the module you're adding the flag to. Generally speaking, adding a flag looks like
(* Default value of the flag. *)
let my_flag_default = ...
(* Reference storing the value of the flag. *)
let my_flag = ref my_flag_default
(* Add flag specification to module specs. *)
let _ = add_spec (
(* The actual flag. *)
"--my_flag",
(* What to do with the value given to the flag, see other flags. *)
...,
(* Flag description. *)
fun fmt ->
Format.fprintf fmt
"@[<v>Description of my flag.@ Default: %a@]"
pp_print_default_value_of_my_flag my_flag_default
)
(* Flag value accessor. *)
let my_flag () = !my_flagAt this point your flag is integrated in the Kind 2 flags.
To make it available to the rest of Kind 2, you need to modify the signature of the module you added the flag to
flags.mli.The update to the signature is typically
val my_flag : unit -> type_of_my_flagAdding a new flag module
The template to add a new module is
module MyModule : sig
include FlagModule
end = struct
(* Identifier of the module. No space or special characters. *)
let id = "..."
(* Short description of the module. *)
let desc = "..."
(* Explanation of the module. *)
let fmt_explain fmt =
Format.fprintf fmt "@[<v>\
...\
@]"
(* All the flag specification of this module. *)
let all_specs = ref []
let add_specs specs = all_specs := !all_specs @ specs
let add_spec spec = add_specs [spec]
(* Returns all the flag specification of this module. *)
let all_specs () = !all_specs
endDon't forget to update `flags.mli`:
module MyModule : sig
include FlagModule
endYou then need to add your module to the module_map, the association map between module identifiers and modules. Make sure the identifier for your module is not used yet.
You can now add modules following the instructions in the previous section.
An error on the command line, with its message: raised by parse_argv instead of printing the usage, if the profile says so, as kmoxi's does
All lustre files in the cone of influence of the input file.
Clears the lustre files in the cone of influence of the input file.
Adds a lustre file in the cone of influence of the input file.
Returns false if the cone of influence already contains the file
val input_format : unit -> input_formatval real_precision : unit -> real_precisionval exit_code_mode : unit -> exit_code_conventionval log_level : unit -> Lib.log_levelVerbosity level
Memory limit in MB of the analysis, solvers included, or 0 for that of the cgroup of the process (see MemoryWatch).
type enable = Lib.kind_module listThe Kind modules enabled is a list of kind_modules.
val enabled : unit -> enableThe modules enabled.
val invgen_enabled : unit -> enableReturns the invariant generation techniques currently enabled.
val disable : Lib.kind_module -> unitManually disables a module.
val slice_nodes : unit -> slice_nodesTrue iff the current solver support sbv_to_int and ubv_to_int operators
module Smt : sig ... endmodule BmcKind : sig ... endmodule IC3QE : sig ... endmodule IC3IA : sig ... endmodule QE : sig ... endmodule Contracts : sig ... endmodule Certif : sig ... endmodule IVC : sig ... endmodule MCS : sig ... endmodule Arrays : sig ... endmodule Quant : sig ... endmodule Testgen : sig ... endmodule Invgen : sig ... endmodule C2I : sig ... endmodule Interpreter : sig ... endmodule ContractMonitor : sig ... endmodule Lsp : sig ... endWhat an executable shows and accepts on its command line: the modules whose flags it registers, and how its usage message describes the input. The global flags are always registered, less the ones that concern kind2 only.
val kind2_profile : profilekind2: every module
val kmoxi_profile : profilekmoxi: the engine, solver and theory flags, and the global flags that are not about the Lustre front end. The SMT solvers are checked and detected once the input is read, with check_solvers, and an error on the command line is raised as UsageError.
Check the SMT solvers given on the command line, detect the others, and adjust the options to the solvers in use: what parse_argv does, unless its profile leaves it until the input is read, as kmoxi's does. Solver preferences (Smt.prefer_solvers) are to be set before.
val parse_argv : ?profile:profile -> unit -> unitParse the command line of the executable of profile (kind2 by default): a flag outside the profile is unknown.