Add support for printing LTL formulas using Wring's syntax.
* src/ltlvisit/tostring.hh, src/ltlvisit/tostring.cc (to_wring_string): New option. * src/bin/common_output.hh, src/bin/common_output.cc: Add support for a --wring option. * src/bin/ltlcheck.cc: Add %w and %W format specifiers.
This commit is contained in:
parent
bf765480b1
commit
0fc3c6bcff
5 changed files with 102 additions and 7 deletions
|
|
@ -128,6 +128,36 @@ namespace spot
|
|||
":", // not supported
|
||||
};
|
||||
|
||||
const char* wring_kw[] = {
|
||||
"FALSE",
|
||||
"TRUE",
|
||||
"[*0]", // not supported
|
||||
" ^ ",
|
||||
" -> ",
|
||||
" <-> ",
|
||||
" U ",
|
||||
" R ",
|
||||
" W ", // rewritten
|
||||
" M ", // rewritten
|
||||
"<>-> ", // not supported
|
||||
"<>=> ", // not supported
|
||||
"<>+> ", // not supported
|
||||
"<>=+> ", // not supported
|
||||
"[]-> ", // not supported
|
||||
"[]=> ", // not supported
|
||||
"!",
|
||||
"X",
|
||||
"F",
|
||||
"G",
|
||||
" + ",
|
||||
" | ", // not supported
|
||||
" * ",
|
||||
" && ", // not supported
|
||||
" & ", // not supported
|
||||
";", // not supported
|
||||
":", // not supported
|
||||
};
|
||||
|
||||
const char* utf8_kw[] = {
|
||||
"0",
|
||||
"1",
|
||||
|
|
@ -262,6 +292,8 @@ namespace spot
|
|||
{
|
||||
os_ << str;
|
||||
}
|
||||
if (kw_ == wring_kw)
|
||||
os_ << "=1";
|
||||
if (full_parent_)
|
||||
os_ << ")";
|
||||
}
|
||||
|
|
@ -518,6 +550,15 @@ namespace spot
|
|||
overline = true;
|
||||
break;
|
||||
}
|
||||
// If we negate an atomic proposition for Wring,
|
||||
// output prop=0.
|
||||
if (kw_ == wring_kw)
|
||||
if (const ltl::atomic_prop* ap = is_atomic_prop(uo->child()))
|
||||
if (is_bare_word(ap->name().c_str()))
|
||||
{
|
||||
os_ << ap->name() << "=0";
|
||||
goto skiprec;
|
||||
}
|
||||
emit(KNot);
|
||||
break;
|
||||
case unop::X:
|
||||
|
|
@ -570,6 +611,8 @@ namespace spot
|
|||
break;
|
||||
}
|
||||
|
||||
skiprec:
|
||||
|
||||
if (full_parent_ && !top_level)
|
||||
closep();
|
||||
else if (overline)
|
||||
|
|
@ -782,5 +825,25 @@ namespace spot
|
|||
to_spin_string(f, os, full_parent);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
to_wring_string(const formula* f, std::ostream& os)
|
||||
{
|
||||
// Remove W and M.
|
||||
f = unabbreviate_wm(f);
|
||||
to_string_visitor v(os, true, false, wring_kw);
|
||||
f->accept(v);
|
||||
f->destroy();
|
||||
return os;
|
||||
}
|
||||
|
||||
std::string
|
||||
to_wring_string(const formula* f)
|
||||
{
|
||||
std::ostringstream os;
|
||||
to_wring_string(f, os);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ namespace spot
|
|||
to_utf8_string(const formula* f, bool full_parent = false,
|
||||
bool ratexp = false);
|
||||
|
||||
/// \brief Output a formula as a (parsable by Spin) string.
|
||||
/// \brief Output a formula as a string parsable by Spin.
|
||||
/// \param f The formula to translate.
|
||||
/// \param os The stream where it should be output.
|
||||
/// \param full_parent Whether or not the string should by fully
|
||||
|
|
@ -82,12 +82,21 @@ namespace spot
|
|||
std::ostream& to_spin_string(const formula* f, std::ostream& os,
|
||||
bool full_parent = false);
|
||||
|
||||
/// \brief Convert a formula into a (parsable by Spin) string.
|
||||
/// \brief Convert a formula into a string parsable by Spin.
|
||||
/// \param f The formula to translate.
|
||||
/// \param full_parent Whether or not the string should by fully
|
||||
/// parenthesized.
|
||||
std::string to_spin_string(const formula* f, bool full_parent = false);
|
||||
|
||||
/// \brief Output a formula as a string parsable by Wring.
|
||||
/// \param f The formula to translate.
|
||||
/// \param os The stream where it should be output.
|
||||
std::ostream& to_wring_string(const formula* f, std::ostream& os);
|
||||
|
||||
/// \brief Convert a formula into a string parsable by Wring
|
||||
/// \param f The formula to translate.
|
||||
std::string to_wring_string(const formula* f);
|
||||
|
||||
/// @}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue