Skip to content

Commit

Permalink
update ocaml binding to support more string apis (#6656)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hhro committed Mar 29, 2023
1 parent 130400d commit 6670807
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ callgrind.out.*
.z3-trace
# OCaml generated files
*.a
*.o
*.cma
*.cmo
*.cmi
*.cmx
*.byte
*.cmxa
ocamlz3
# Java generated files
Expand Down
12 changes: 12 additions & 0 deletions src/api/ml/z3.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,9 @@ struct
let mk_re_sort = Z3native.mk_re_sort
let is_re_sort = Z3native.is_re_sort
let mk_string_sort = Z3native.mk_string_sort
let mk_char_sort = Z3native.mk_char_sort
let is_string_sort = Z3native.is_string_sort
let is_char_sort = Z3native.is_char_sort
let mk_string = Z3native.mk_string
let is_string = Z3native.is_string
let get_string = Z3native.get_string
Expand All @@ -1274,6 +1276,10 @@ struct
let mk_str_le = Z3native.mk_str_le
let mk_str_lt = Z3native.mk_str_lt
let mk_int_to_str = Z3native.mk_int_to_str
let mk_string_to_code = Z3native.mk_string_to_code
let mk_string_from_code = Z3native.mk_string_from_code
let mk_ubv_to_str = Z3native.mk_ubv_to_str
let mk_sbv_to_str = Z3native.mk_sbv_to_str
let mk_seq_to_re = Z3native.mk_seq_to_re
let mk_seq_in_re = Z3native.mk_seq_in_re
let mk_re_plus = Z3native.mk_re_plus
Expand All @@ -1287,6 +1293,12 @@ struct
let mk_re_complement = Z3native.mk_re_complement
let mk_re_empty = Z3native.mk_re_empty
let mk_re_full = Z3native.mk_re_full
let mk_char = Z3native.mk_char
let mk_char_le = Z3native.mk_char_le
let mk_char_to_int = Z3native.mk_char_to_int
let mk_char_to_bv = Z3native.mk_char_to_bv
let mk_char_from_bv = Z3native.mk_char_from_bv
let mk_char_is_digit = Z3native.mk_char_is_digit
end

module FloatingPoint =
Expand Down
37 changes: 37 additions & 0 deletions src/api/ml/z3.mli
Original file line number Diff line number Diff line change
Expand Up @@ -1881,9 +1881,15 @@ sig
(** create string sort *)
val mk_string_sort : context -> Sort.sort

(** create char sort *)
val mk_char_sort : context -> Sort.sort

(** test if sort is a string sort (a sequence of 8-bit bit-vectors) *)
val is_string_sort : context -> Sort.sort -> bool

(** test if sort is a char sort *)
val is_char_sort : context -> Sort.sort -> bool

(** create a string literal *)
val mk_string : context -> string -> Expr.expr

Expand Down Expand Up @@ -1936,6 +1942,7 @@ sig
(** retrieve integer expression encoded in string *)
val mk_str_to_int : context -> Expr.expr -> Expr.expr


(** compare strings less-than-or-equal *)
val mk_str_le : context -> Expr.expr -> Expr.expr -> Expr.expr

Expand All @@ -1945,6 +1952,18 @@ sig
(** convert an integer expression to a string *)
val mk_int_to_str : context -> Expr.expr -> Expr.expr

(** [mk_string_to_code ctx s] convert a unit length string [s] to integer code *)
val mk_string_to_code : context -> Expr.expr -> Expr.expr

(** [mk_string_from_code ctx c] convert code [c] to a string *)
val mk_string_from_code : context -> Expr.expr -> Expr.expr

(** [mk_ubv_to_str ctx ubv] convert a unsigned bitvector [ubv] to a string *)
val mk_ubv_to_str : context -> Expr.expr -> Expr.expr

(** [mk_sbv_to_str ctx sbv] convert a signed bitvector [sbv] to a string *)
val mk_sbv_to_str : context -> Expr.expr -> Expr.expr

(** create regular expression that accepts the argument sequence *)
val mk_seq_to_re : context -> Expr.expr -> Expr.expr

Expand Down Expand Up @@ -1984,6 +2003,24 @@ sig
(** the regular expression that accepts all sequences *)
val mk_re_full : context -> Sort.sort -> Expr.expr

(** [mk_char ctx i] converts an integer to a character *)
val mk_char : context -> int -> Expr.expr

(** [mk_char_le ctx lc rc] compares two characters *)
val mk_char_le : context -> Expr.expr -> Expr.expr -> Expr.expr

(** [mk_char_to_int ctx c] converts the character [c] to an integer *)
val mk_char_to_int : context -> Expr.expr -> Expr.expr

(** [mk_char_to_bv ctx c] converts the character [c] to a bitvector *)
val mk_char_to_bv : context -> Expr.expr -> Expr.expr

(** [mk_char_from_bv ctx bv] converts the bitvector [bv] to a character *)
val mk_char_from_bv : context -> Expr.expr -> Expr.expr

(** [mk_char_is_digit ctx c] checks if the character [c] is a digit *)
val mk_char_is_digit: context -> Expr.expr -> Expr.expr

end

(** Floating-Point Arithmetic *)
Expand Down

0 comments on commit 6670807

Please sign in to comment.