Skip to content

Commit

Permalink
Added fix and test to term translation: now handles escape sequences …
Browse files Browse the repository at this point in the history
…in string literals and extra quotations.
  • Loading branch information
rachelcleaveland committed Nov 22, 2024
1 parent c4fdba7 commit 630c66c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/term_translator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,11 @@ Term TermTranslator::value_from_smt2(const std::string val,
}
}
else if (sk == STRING){
return solver->make_term(val, false, sort);
std::string new_val = val;
if (val.length() > 1 && val.at(0) == '\"') {
new_val = new_val.substr(1,new_val.length()-2);
}
return solver->make_term(new_val, true, sort);
}
{
throw NotImplementedException(
Expand Down
15 changes: 15 additions & 0 deletions tests/test-term-translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,21 @@ TEST_P(TranslationTests, UninterpretedSort)
EXPECT_EQ(fv, fv_1);
}

TEST_P(TranslationTests, Strings)
{
Sort strsort = s1->make_sort(STRING);
Term t = s1->make_term("\\u{a}", true, strsort);

TermTranslator to_s2(s2);
TermTranslator to_s1(s1);

Term t2 = to_s2.transfer_term(t);
EXPECT_EQ(t2->to_string(), t->to_string());

Term t1 = to_s1.transfer_term(t2);
EXPECT_EQ(t, t1);
}

TEST_P(BoolArrayTranslationTests, Arrays)
{
Term f = s1->make_term(false);
Expand Down

0 comments on commit 630c66c

Please sign in to comment.