bin: add %g options to print acceptance name
Fixes #289. * spot/twaalgos/stats.cc, spot/twaalgos/stats.hh, bin/common_aoutput.cc, bin/common_aoutput.hh: plug %g and %G into acc_cond::name() when arguments are given as %[arg]g. or %[arg]G. * tests/core/acc2.test: Add test case. * doc/org/randaut.org, NEWS: Document it.
This commit is contained in:
parent
bd39edde27
commit
75a1d6ac61
7 changed files with 110 additions and 18 deletions
|
|
@ -331,6 +331,31 @@ namespace spot
|
|||
os << count;
|
||||
}
|
||||
|
||||
void printable_acc_cond::print(std::ostream& os, const char* pos) const
|
||||
{
|
||||
if (*pos != '[')
|
||||
{
|
||||
os << val_.get_acceptance();
|
||||
return;
|
||||
}
|
||||
const char* beg = pos;
|
||||
++pos;
|
||||
const char* end = strchr(pos, ']');
|
||||
try
|
||||
{
|
||||
os << val_.name(std::string(pos, end).c_str());
|
||||
}
|
||||
catch (const std::runtime_error& e)
|
||||
{
|
||||
std::ostringstream tmp;
|
||||
tmp << "while processing %"
|
||||
<< std::string(beg, end + 2) << ", ";
|
||||
tmp << e.what();
|
||||
throw std::runtime_error(tmp.str());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stat_printer::stat_printer(std::ostream& os, const char* format)
|
||||
: format_(format)
|
||||
|
|
@ -397,11 +422,7 @@ namespace spot
|
|||
}
|
||||
|
||||
if (has('g'))
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << aut->get_acceptance();
|
||||
gen_acc_ = os.str();
|
||||
}
|
||||
gen_acc_ = aut->acc();
|
||||
|
||||
auto& os = format(format_);
|
||||
// Make sure we do not hold a pointer to the automaton or the
|
||||
|
|
|
|||
|
|
@ -70,6 +70,20 @@ namespace spot
|
|||
print(std::ostream& os, const char*) const override;
|
||||
};
|
||||
|
||||
class SPOT_API printable_acc_cond final: public spot::printable
|
||||
{
|
||||
acc_cond val_;
|
||||
public:
|
||||
printable_acc_cond&
|
||||
operator=(const acc_cond& new_val)
|
||||
{
|
||||
val_ = new_val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void print(std::ostream& os, const char* pos) const override;
|
||||
};
|
||||
|
||||
class SPOT_API printable_scc_info final:
|
||||
public spot::printable
|
||||
{
|
||||
|
|
@ -117,7 +131,7 @@ namespace spot
|
|||
printable_value<unsigned> nondetstates_;
|
||||
printable_value<unsigned> deterministic_;
|
||||
printable_value<unsigned> complete_;
|
||||
printable_value<std::string> gen_acc_;
|
||||
printable_acc_cond gen_acc_;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue