summaryrefslogtreecommitdiff
path: root/src/theory/strings/word.cpp
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2020-03-09 13:35:59 -0500
committerGitHub <noreply@github.com>2020-03-09 13:35:59 -0500
commit9f77ec44decf18fe23c738988281373795dcca0d (patch)
tree9772a0ae0bc73e3e00c8b716468b8a86b332f2c6 /src/theory/strings/word.cpp
parentc1da31ed532cd1767c20d5fc01df893c427e0e8e (diff)
Convert more uses of strings to words (#3921)
Towards theory of sequences. Also adds documentation to strncmp/rstrncmp and adds them to the Word interface.
Diffstat (limited to 'src/theory/strings/word.cpp')
-rw-r--r--src/theory/strings/word.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/theory/strings/word.cpp b/src/theory/strings/word.cpp
index a0ee0d224..dd573b68c 100644
--- a/src/theory/strings/word.cpp
+++ b/src/theory/strings/word.cpp
@@ -78,6 +78,34 @@ size_t Word::getLength(TNode x)
bool Word::isEmpty(TNode x) { return getLength(x) == 0; }
+bool Word::strncmp(TNode x, TNode y, std::size_t n)
+{
+ Kind k = x.getKind();
+ if (k == CONST_STRING)
+ {
+ Assert(y.getKind() == CONST_STRING);
+ String sx = x.getConst<String>();
+ String sy = y.getConst<String>();
+ return sx.strncmp(sy, n);
+ }
+ Unimplemented();
+ return false;
+}
+
+bool Word::rstrncmp(TNode x, TNode y, std::size_t n)
+{
+ Kind k = x.getKind();
+ if (k == CONST_STRING)
+ {
+ Assert(y.getKind() == CONST_STRING);
+ String sx = x.getConst<String>();
+ String sy = y.getConst<String>();
+ return sx.rstrncmp(sy, n);
+ }
+ Unimplemented();
+ return false;
+}
+
std::size_t Word::find(TNode x, TNode y, std::size_t start)
{
Kind k = x.getKind();
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback