File tree Expand file tree Collapse file tree 11 files changed +32
-2
lines changed Expand file tree Collapse file tree 11 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -221,6 +221,9 @@ module Fresh_bitwuzla (B : Bitwuzla_cxx.S) : M = struct
221221
222222 let replace _ ~pattern :_ ~with_ :_ =
223223 Fmt. failwith " Bitwuzla_mappings: String.replace not implemented"
224+
225+ let replace_all _ ~pattern :_ ~with_ :_ =
226+ Fmt. failwith " Bitwuzla_mappings: String.replace_all not implemented"
224227 end
225228
226229 module Re = struct
Original file line number Diff line number Diff line change @@ -203,6 +203,9 @@ module Fresh_cvc5 () = struct
203203
204204 let replace t1 ~pattern ~with_ =
205205 Term. mk_term tm Kind. String_replace [| t1; pattern; with_ |]
206+
207+ let replace_all t1 ~pattern ~with_ =
208+ Term. mk_term tm Kind. String_replace_all [| t1; pattern; with_ |]
206209 end
207210
208211 module Re = struct
Original file line number Diff line number Diff line change @@ -208,6 +208,8 @@ module DolmenIntf = struct
208208 let index_of t ~sub ~pos = DTerm.String. index_of t sub pos
209209
210210 let replace t ~pattern ~with_ = DTerm.String. replace t pattern with_
211+
212+ let replace_all t ~pattern ~with_ = DTerm.String. replace_all t pattern with_
211213 end
212214
213215 module Re = struct
Original file line number Diff line number Diff line change @@ -185,6 +185,8 @@ module DolmenIntf : sig
185185 val index_of : term -> sub :term -> pos :term -> term
186186
187187 val replace : term -> pattern :term -> with_ :term -> term
188+
189+ val replace_all : term -> pattern :term -> with_ :term -> term
188190 end
189191
190192 module Re : sig
Original file line number Diff line number Diff line change @@ -231,6 +231,7 @@ module Make (M_with_make : M_with_make) : S_with_fresh = struct
231231 | Triop. String_extract -> M.String. sub e1 ~pos: e2 ~len: e3
232232 | String_index -> M.String. index_of e1 ~sub: e2 ~pos: e3
233233 | String_replace -> M.String. replace e1 ~pattern: e2 ~with_: e3
234+ | String_replace_all -> M.String. replace_all e1 ~pattern: e2 ~with_: e3
234235 | _ ->
235236 Fmt. failwith {| String : Unsupported triop operator " %a" | } Triop. pp op
236237
Original file line number Diff line number Diff line change @@ -182,6 +182,8 @@ module Nop = struct
182182 let index_of _ ~sub :_ ~pos :_ = assert false
183183
184184 let replace _ ~pattern :_ ~with_ :_ = assert false
185+
186+ let replace_all _ ~pattern :_ ~with_ :_ = assert false
185187 end
186188
187189 module Re = struct
Original file line number Diff line number Diff line change @@ -316,6 +316,10 @@ module type M = sig
316316 (* * [replace t ~pattern ~with_] constructs the string term resulting from
317317 replacing [pattern] with [with_] in [t]. *)
318318 val replace : term -> pattern :term -> with_ :term -> term
319+
320+ (* * [replace_all t ~pattern ~with_] constructs the string term resulting
321+ from replacing all occurrences of [pattern] with [with_] in [t]. *)
322+ val replace_all : term -> pattern :term -> with_ :term -> term
319323 end
320324
321325 (* * {2 Regular Expression Operations} *)
Original file line number Diff line number Diff line change @@ -180,6 +180,8 @@ module Term = struct
180180 | "str.substr" , [ a; b; c ] -> Expr. triop Ty_str String_extract a b c
181181 | "str.indexof" , [ a; b; c ] -> Expr. triop Ty_str String_index a b c
182182 | "str.replace" , [ a; b; c ] -> Expr. triop Ty_str String_replace a b c
183+ | "str.replace_all" , [ a; b; c ] ->
184+ Expr. triop Ty_str String_replace_all a b c
183185 | "str.++" , n -> Expr. raw_naryop Ty_str Concat n
184186 | "str.<" , [ a; b ] -> Expr. raw_relop Ty_str Lt a b
185187 | "str.<=" , [ a; b ] -> Expr. raw_relop Ty_str Le a b
Original file line number Diff line number Diff line change @@ -355,23 +355,28 @@ module Triop = struct
355355 | String_extract
356356 | String_replace
357357 | String_index
358+ | String_replace_all
358359
359360 let equal op1 op2 =
360361 match (op1, op2) with
361362 | Ite , Ite
362363 | List_set , List_set
363364 | String_extract , String_extract
364365 | String_replace , String_replace
365- | String_index , String_index ->
366+ | String_index , String_index
367+ | String_replace_all , String_replace_all ->
366368 true
367- | (Ite | List_set | String_extract | String_replace | String_index ), _ ->
369+ | ( ( Ite | List_set | String_extract | String_replace | String_index
370+ | String_replace_all )
371+ , _ ) ->
368372 false
369373
370374 let pp fmt = function
371375 | Ite -> Fmt. string fmt " ite"
372376 | String_extract -> Fmt. string fmt " substr"
373377 | String_replace -> Fmt. string fmt " replace"
374378 | String_index -> Fmt. string fmt " indexof"
379+ | String_replace_all -> Fmt. string fmt " replace_all"
375380 | List_set -> Fmt. string fmt " set"
376381end
377382
Original file line number Diff line number Diff line change @@ -192,6 +192,9 @@ module Triop : sig
192192 (* * Replace a substring. (str.replace String String String String) *)
193193 | String_index
194194 (* * Find the index of a substring. (str.indexof String String Int Int) *)
195+ | String_replace_all
196+ (* * Replace all occurrences of a substring. (str.replace_all String String
197+ String String) *)
195198
196199 (* * [equal op1 op2] checks if ternary operations [op1] and [op2] are equal. *)
197200 val equal : t -> t -> bool
You can’t perform that action at this time.
0 commit comments