Skip to content

Commit b0a0002

Browse files
author
Daniel Kroening
authored
Merge pull request #2751 from diffblue/unicode-format
Unicode for format_expr
2 parents 9d8abbf + 86aea9b commit b0a0002

File tree

2 files changed

+46
-9
lines changed

2 files changed

+46
-9
lines changed

src/cbmc/show_vcc.cpp

+18-6
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ Author: Daniel Kroening, [email protected]
2222

2323
void bmct::show_vcc_plain(std::ostream &out)
2424
{
25-
out << "\n" << "VERIFICATION CONDITIONS:" << "\n" << "\n";
26-
2725
bool has_threads=equation.has_threads();
26+
bool first=true;
2827

2928
for(symex_target_equationt::SSA_stepst::iterator
3029
s_it=equation.SSA_steps.begin();
@@ -34,6 +33,11 @@ void bmct::show_vcc_plain(std::ostream &out)
3433
if(!s_it->is_assert())
3534
continue;
3635

36+
if(first)
37+
first=false;
38+
else
39+
out << '\n';
40+
3741
if(s_it->source.pc->source_location.is_not_nil())
3842
out << s_it->source.pc->source_location << "\n";
3943

@@ -66,13 +70,14 @@ void bmct::show_vcc_plain(std::ostream &out)
6670
}
6771
}
6872

69-
out << "|--------------------------" << "\n";
73+
// Unicode equivalent of "|--------------------------"
74+
out << u8"\u251c";
75+
for(unsigned i=0; i<26; i++) out << u8"\u2500";
76+
out << '\n';
7077

7178
std::string string_value=
7279
from_expr(ns, s_it->source.pc->function, s_it->cond_expr);
7380
out << "{" << 1 << "} " << string_value << "\n";
74-
75-
out << "\n";
7681
}
7782
}
7883

@@ -159,7 +164,14 @@ void bmct::show_vcc()
159164
break;
160165

161166
case ui_message_handlert::uit::PLAIN:
162-
show_vcc_plain(out);
167+
status() << "VERIFICATION CONDITIONS:\n" << eom;
168+
if(have_file)
169+
show_vcc_plain(out);
170+
else
171+
{
172+
show_vcc_plain(status());
173+
status() << eom;
174+
}
163175
break;
164176
}
165177

src/util/format_expr.cpp

+28-3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,27 @@ static std::ostream &format_rec(std::ostream &os, const multi_ary_exprt &src)
6262
{
6363
bool first = true;
6464

65+
std::string operator_str;
66+
67+
if(src.id() == ID_and)
68+
operator_str = u8"\u2227"; // wedge, U+2227
69+
else if(src.id() == ID_or)
70+
operator_str = u8"\u2228"; // vee, U+2228
71+
else if(src.id() == ID_xor)
72+
operator_str = u8"\u2295"; // + in circle, U+2295
73+
else if(src.id() == ID_le)
74+
operator_str = u8"\u2264"; // <=, U+2264
75+
else if(src.id() == ID_ge)
76+
operator_str = u8"\u2265"; // >=, U+2265
77+
else if(src.id() == ID_notequal)
78+
operator_str = u8"\u2260"; // /=, U+2260
79+
else if(src.id() == ID_implies)
80+
operator_str = u8"\u21d2"; // =>, U+21D2
81+
else if(src.id() == ID_iff)
82+
operator_str = u8"\u21d4"; // <=>, U+21D4
83+
else
84+
operator_str = id2string(src.id());
85+
6586
for(const auto &op : src.operands())
6687
{
6788
if(first)
@@ -95,7 +116,7 @@ static std::ostream &format_rec(std::ostream &os, const binary_exprt &src)
95116
static std::ostream &format_rec(std::ostream &os, const unary_exprt &src)
96117
{
97118
if(src.id() == ID_not)
98-
os << '!';
119+
os << u8"\u00ac"; // neg, U+00AC
99120
else if(src.id() == ID_unary_minus)
100121
os << '-';
101122
else
@@ -197,8 +218,12 @@ std::ostream &format_rec(std::ostream &os, const exprt &expr)
197218
}
198219
else if(id == ID_type)
199220
return format_rec(os, expr.type());
200-
else if(id == ID_forall || id == ID_exists)
201-
return os << id << ' ' << format(to_quantifier_expr(expr).symbol()) << " : "
221+
else if(id == ID_forall)
222+
return os << id << u8" \u2200 : "
223+
<< format(to_quantifier_expr(expr).symbol().type()) << " . "
224+
<< format(to_quantifier_expr(expr).where());
225+
else if(id == ID_exists)
226+
return os << id << u8" \u2203 : "
202227
<< format(to_quantifier_expr(expr).symbol().type()) << " . "
203228
<< format(to_quantifier_expr(expr).where());
204229
else if(id == ID_let)

0 commit comments

Comments
 (0)