Use []=> and <>=> as sugar in the output when possible.
* src/ltlast/multop.hh (is_multop): Take a constant formula as input. * src/ltlvisit/tostring.cc (to_string_visitor::visit(multop*)): Output []=> or <>=> when the left argument of a []-> or <>-> is a concatenation that ends in 1. * doc/tl/tl.tex: Document this desugaring.
This commit is contained in:
parent
5e7c0add49
commit
412f946ac0
3 changed files with 32 additions and 12 deletions
|
|
@ -185,11 +185,11 @@ namespace spot
|
|||
/// Returns 0 otherwise.
|
||||
inline
|
||||
multop*
|
||||
is_multop(formula* f, multop::type op)
|
||||
is_multop(const formula* f, multop::type op)
|
||||
{
|
||||
if (f->kind() != formula::MultOp)
|
||||
return 0;
|
||||
multop* mo = static_cast<multop*>(f);
|
||||
multop* mo = static_cast<multop*>(const_cast<formula*>(f));
|
||||
if (mo->op() != op)
|
||||
return 0;
|
||||
return mo;
|
||||
|
|
@ -197,8 +197,8 @@ namespace spot
|
|||
|
||||
/// \brief Cast \a f into a multop if it has type \a op1 or \a op2.
|
||||
///
|
||||
/// Cast \a f into a multop iff it is a multop instance with operator \a op1
|
||||
/// or \a op2. Returns 0 otherwise.
|
||||
/// Cast \a f into a multop iff it is a multop instance with
|
||||
/// operator \a op1 or \a op2. Returns 0 otherwise.
|
||||
inline
|
||||
multop*
|
||||
is_multop(const formula* f, multop::type op1, multop::type op2)
|
||||
|
|
|
|||
|
|
@ -122,6 +122,8 @@ namespace spot
|
|||
if (!top_level)
|
||||
openp();
|
||||
|
||||
bool onelast = false;
|
||||
|
||||
switch (bo->op())
|
||||
{
|
||||
case binop::UConcat:
|
||||
|
|
@ -130,6 +132,21 @@ namespace spot
|
|||
os_ << "{";
|
||||
in_ratexp_ = true;
|
||||
top_level_ = true;
|
||||
{
|
||||
multop* m = is_multop(bo->first(), multop::Concat);
|
||||
if (m)
|
||||
{
|
||||
unsigned s = m->size();
|
||||
if (m->nth(s - 1) == constant::true_instance())
|
||||
{
|
||||
formula* tmp = m->all_but(s - 1);
|
||||
tmp->accept(*this);
|
||||
tmp->destroy();
|
||||
onelast = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// fall through
|
||||
default:
|
||||
bo->first()->accept(*this);
|
||||
|
|
@ -160,7 +177,7 @@ namespace spot
|
|||
os_ << " M ";
|
||||
break;
|
||||
case binop::UConcat:
|
||||
os_ << "} []-> ";
|
||||
os_ << (onelast ? "} []=> " : "} []-> ");
|
||||
in_ratexp_ = false;
|
||||
top_level_ = top_level;
|
||||
break;
|
||||
|
|
@ -171,12 +188,12 @@ namespace spot
|
|||
in_ratexp_ = false;
|
||||
goto second_done;
|
||||
}
|
||||
os_ << "} <>-> ";
|
||||
os_ << (onelast ? "} <>=> " : "} <>-> ");
|
||||
in_ratexp_ = false;
|
||||
top_level_ = false;
|
||||
break;
|
||||
case binop::EConcatMarked:
|
||||
os_ << "} <>+> ";
|
||||
os_ << (onelast ? "} <>=+> " : "} <>+> ");
|
||||
in_ratexp_ = false;
|
||||
top_level_ = false;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue