Up

module OASISExpr

: sig

Boolean expressions

This module provides a boolean expression evaluator. See OASIS manual for the precise syntax of the boolean expression

Author Sylvain Le Gall

Test

#
type test

Test definition.

#
val tests : test list

Mandatory tests.

#
val string_of_test : test -> string

Convert a test to string.

#
val test_of_string : string -> test

Convert a string to test.

Expression

#
type flag = string
#
type t =
# | EBool of bool
(*true or false*)
# | ENot of t
(*! e*)
# | EAnd of t * t
(*e1 && e2*)
# | EOr of t * t
(*e1 || e2*)
# | EFlag of flag
(*flag(foo), a boolean value.*)
# | ETest of test * string
(*os_type(Win32), a value compared to a string.*)

Boolean expression definition.

#
type 'a choices = (t * 'a) list

Choose among different values

#
val eval : (string -> string) -> t -> bool

eval eval_tst t Evaluates the expression. Use eval_tst to get values of flags and tests.

#
val choose : ?printer:('a -> string) -> ?name:string -> (string -> string) -> 'a choices -> 'a

choose ~printer ~name eval_tst choices Evaluate each conditions of choices and choose the last condition that evaluates to true. If something goes wrong, use printer to display values and ~name as the choice list name.

See also eval.

#
val check : flag list -> t -> unit

Check that a boolean expression only use available flags. Not exported.

#
val reduce : t -> t

Try to reduce the size of a boolean expression. Not exported.

#
val reduce_choices : (t * 'a) list -> (t * 'a) list

Try to reduce the size of a choice list. Not exported.

#
val if_then_else : t -> (t * 'a) list -> (t * 'a) list -> (t * 'a) list

if_then_else cond choices_if choices_else Combine choices, if_then_else style.

#
val odn_of_t : t -> ODN.t

Dump ODN.t. Not exported.

#
val odn_of_choices : ('a -> ODN.t) -> 'a choices -> ODN.t
#
val to_string : t -> string

Transform an expression into a string. Not exported

#
val string_of_choices : ('a -> string) -> 'a choices -> string

Transform a list of choice into a string. Not exported

end