to_string: abbreviate [->i..j] and [=i..j] expressed using [*i..j]
* src/ltlast/bunop.hh (is_bunop, is_Star): New functions. * src/ltlast/multop.hh (is_And, is_Or): Fix constness. (is_Concat, is_Fusion): New functions. * src/ltlast/unop.hh (is_unop, is_X, is_F, is_G, is_GF, is_FG): Fix constness. (is_Not): New function. * src/ltlvisit/tostring.cc (strip_star_not, match_goto, emit_bunop_child, resugar_concat): New methods. (visit(bunop)): Rewrite without calling format(). Detect the [->i..j] pattern. (visit(multop)): Call resugar_concat to detect [=i..j] patterns.
This commit is contained in:
parent
e109f21ce4
commit
39417037d7
4 changed files with 287 additions and 35 deletions
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2010, 2011 Laboratoire de Recherche et Développement
|
||||
// Copyright (C) 2010, 2011, 2012 Laboratoire de Recherche et Développement
|
||||
// de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -120,6 +120,45 @@ namespace spot
|
|||
unsigned max_;
|
||||
};
|
||||
|
||||
/// \brief Cast \a f into a bunop.
|
||||
///
|
||||
/// Cast \a f into a bunop iff it is a bunop instance. Return 0
|
||||
/// otherwise. This is faster than \c dynamic_cast.
|
||||
inline
|
||||
bunop*
|
||||
is_bunop(const formula* f)
|
||||
{
|
||||
if (f->kind() != formula::BUnOp)
|
||||
return 0;
|
||||
return static_cast<bunop*>(const_cast<formula*>(f));
|
||||
}
|
||||
|
||||
/// \brief Cast \a f into a bunop if it has type \a op.
|
||||
///
|
||||
/// Cast \a f into a bunop iff it is a bunop instance with operator \a op.
|
||||
/// Returns 0 otherwise.
|
||||
inline
|
||||
bunop*
|
||||
is_bunop(const formula* f, bunop::type op)
|
||||
{
|
||||
if (f->kind() != formula::BUnOp)
|
||||
return 0;
|
||||
bunop* bo = static_cast<bunop*>(const_cast<formula*>(f));
|
||||
if (bo->op() != op)
|
||||
return 0;
|
||||
return bo;
|
||||
}
|
||||
|
||||
/// \brief Cast \a f into a bunop if it is a Star.
|
||||
///
|
||||
/// Return 0 otherwise.
|
||||
inline
|
||||
bunop*
|
||||
is_Star(const formula* f)
|
||||
{
|
||||
return is_bunop(f, bunop::Star);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif // SPOT_LTLAST_BUNOP_HH
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue