summaryrefslogtreecommitdiff
path: root/src/printer
diff options
context:
space:
mode:
authorAndres Noetzli <andres.noetzli@gmail.com>2021-05-27 15:42:10 -0700
committerGitHub <noreply@github.com>2021-05-27 22:42:10 +0000
commit29f0b8f378377ed836bddaaf88883d0b2eeb545d (patch)
tree5d9edb57c60ab8c8a07dab52f18b72dd441d4fdf /src/printer
parent631032b15327c28c44b51490dceb434a38f3419a (diff)
Fix `str.replace_re` and `str.replace_re_all` (#6615)
Fixes #6057. The reductions of `str.replace_re` and `str.replace_re_all` were not correctly enforcing that the operations replace the _first_ occurrence of some regular expression in a string. This commit fixes the issue by introducing a new operator `str.indexof_re(s, r, n)`, which, analoguously to `str.indexof`, returns the index of the first match of the regular expression `r` in `s`. The commit adds basic rewrites for evaluating the operator as well as its reduction. Additionally, it converts the reductions of `str.replace_re` and `str.replace_re_all` to use that new operator. This simplifies the reductions of the two operators and ensures that the semantics are consistent between the two.
Diffstat (limited to 'src/printer')
-rw-r--r--src/printer/smt2/smt2_printer.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/printer/smt2/smt2_printer.cpp b/src/printer/smt2/smt2_printer.cpp
index 6258834c4..4607d2747 100644
--- a/src/printer/smt2/smt2_printer.cpp
+++ b/src/printer/smt2/smt2_printer.cpp
@@ -723,6 +723,7 @@ void Smt2Printer::toStream(std::ostream& out,
case kind::STRING_CHARAT:
case kind::STRING_STRCTN:
case kind::STRING_STRIDOF:
+ case kind::STRING_INDEXOF_RE:
case kind::STRING_STRREPL:
case kind::STRING_STRREPLALL:
case kind::STRING_REPLACE_RE:
@@ -1309,6 +1310,7 @@ std::string Smt2Printer::smtKindString(Kind k, Variant v)
case kind::STRING_STRCTN: return "str.contains" ;
case kind::STRING_CHARAT: return "str.at" ;
case kind::STRING_STRIDOF: return "str.indexof" ;
+ case kind::STRING_INDEXOF_RE: return "str.indexof_re";
case kind::STRING_STRREPL: return "str.replace" ;
case kind::STRING_STRREPLALL: return "str.replace_all";
case kind::STRING_REPLACE_RE: return "str.replace_re";
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback