mirror of
https://github.com/Z3Prover/z3
synced 2025-04-27 02:45:51 +00:00
add basic rewriting to strings
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
c04f75cdbb
commit
75359c580e
10 changed files with 323 additions and 8 deletions
|
@ -363,6 +363,23 @@ format * smt2_pp_environment::pp_arith_literal(app * t, bool decimal, unsigned d
|
|||
}
|
||||
}
|
||||
|
||||
format * smt2_pp_environment::pp_string_literal(app * t) {
|
||||
std::string s;
|
||||
VERIFY (get_sutil().str.is_const(t, s));
|
||||
std::ostringstream buffer;
|
||||
buffer << "\"";
|
||||
for (unsigned i = 0; i < s.length(); ++i) {
|
||||
if (s[i] == '\"') {
|
||||
buffer << "\"\"";
|
||||
}
|
||||
else {
|
||||
buffer << s[i];
|
||||
}
|
||||
}
|
||||
buffer << "\"";
|
||||
return mk_string(get_manager(), buffer.str().c_str());
|
||||
}
|
||||
|
||||
format * smt2_pp_environment::pp_datalog_literal(app * t) {
|
||||
uint64 v;
|
||||
VERIFY (get_dlutil().is_numeral(t, v));
|
||||
|
@ -578,6 +595,9 @@ class smt2_printer {
|
|||
if (m_env.get_autil().is_numeral(c) || m_env.get_autil().is_irrational_algebraic_numeral(c)) {
|
||||
f = m_env.pp_arith_literal(c, m_pp_decimal, m_pp_decimal_precision);
|
||||
}
|
||||
else if (m_env.get_sutil().str.is_const(c)) {
|
||||
f = m_env.pp_string_literal(c);
|
||||
}
|
||||
else if (m_env.get_bvutil().is_numeral(c)) {
|
||||
f = m_env.pp_bv_literal(c, m_pp_bv_lits, m_pp_bv_neg);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue