Commit 56df459c authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

print_hoa: add support for universal branches

* spot/twaalgos/hoa.cc: Implement it.
* tests/python/alternating.py: Test it.
parent 6aad559c
......@@ -426,13 +426,21 @@ namespace spot
}
os << str;
};
// We do not support alternating automata so far, and it's
// probable that nobody cares about the "no-univ-branch"
// properties. The "univ-branch" properties seems more important
// to announce that the automaton might not be parsable by tools
// that do not support alternating automata.
if (verbose)
// It's probable that nobody cares about the "no-univ-branch"
// property. The "univ-branch" property seems more important to
// announce that the automaton might not be parsable by tools that
// do not support alternating automata.
if (aut->is_alternating())
{
prop(" univ-branch");
}
else if (verbose)
{
if (v1_1)
prop(" !univ-branch");
else
prop(" no-univ-branch");
}
implicit_labels = md.use_implicit_labels;
state_labels = md.use_state_labels;
if (implicit_labels)
......@@ -539,6 +547,20 @@ namespace spot
}
os << "--BODY--" << nl;
auto print_dst = [&](unsigned dst)
{
bool notfirst = false;
for (unsigned d: aut->univ_dests(dst))
{
if (notfirst)
os << '&';
else
notfirst = true;
os << d;
}
};
auto sn = aut->get_named_prop<std::vector<std::string>>("state-names");
for (unsigned i = 0; i < num_states; ++i)
{
......@@ -580,7 +602,8 @@ namespace spot
for (auto& t: aut->out(i))
{
os << '[' << md.sup[t.cond] << "] " << t.dst;
os << '[' << md.sup[t.cond] << "] ";
print_dst(t.dst);
if (this_acc == Hoa_Acceptance_Transitions)
md.emit_acc(os, t.acc);
os << nl;
......@@ -591,7 +614,7 @@ namespace spot
unsigned n = 0;
for (auto& t: aut->out(i))
{
os << t.dst;
print_dst(t.dst);
if (this_acc == Hoa_Acceptance_Transitions)
{
md.emit_acc(os, t.acc);
......@@ -637,7 +660,7 @@ namespace spot
unsigned n = out.size();
for (unsigned i = 0; i < n;)
{
os << out[i];
print_dst(out[i]);
if (this_acc != Hoa_Acceptance_States)
{
md.emit_acc(os, outm[i]) << nl;
......
......@@ -50,3 +50,22 @@ try:
except RuntimeError:
received = True
assert received
h = aut.to_str('hoa')
print(h)
assert h == """HOA: v1
States: 3
Start: 0
AP: 2 "p1" "p2"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: univ-branch trans-labels explicit-labels trans-acc
--BODY--
State: 0
[0] 1&2 {0}
[1] 0&1
State: 1
[0&1] 0&2&1
State: 2
[0 | 1] 2
--END--"""
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment