ltlcross: diagnose missing i/o specifications earlier.

* src/misc/formater.cc, src/misc/formater.hh (scan): New method.
(prime): Use it.
* src/bin/ltlcross.cc (translator_runner::translator_runner): Scan each
specification string, and report those missing an input or output
%-sequence.
* NEWS: Mention it.
This commit is contained in:
Alexandre Duret-Lutz 2013-01-21 10:20:25 +01:00
parent edd687a301
commit 6a547371d7
4 changed files with 52 additions and 12 deletions

2
NEWS
View file

@ -27,6 +27,8 @@ New in spot 1.0a (not released):
transition counts, just as the ltlcross tool. transition counts, just as the ltlcross tool.
- ltlcross will display the number of timeouts at the end - ltlcross will display the number of timeouts at the end
of its execution. of its execution.
- ltlcross will diagnose tools with missing input or
output %-sequence before attempting to run any of them.
- The parser for LBT's prefix-style LTL formulas will now - The parser for LBT's prefix-style LTL formulas will now
read atomic propositions that are not of the form p1, p2... read atomic propositions that are not of the form p1, p2...
This makes it possible to process formulas written in This makes it possible to process formulas written in

View file

@ -494,10 +494,28 @@ namespace
declare('N', &output); declare('N', &output);
declare('T', &output); declare('T', &output);
std::vector<bool> has(256);
size_t s = translators.size(); size_t s = translators.size();
assert(s); assert(s);
for (size_t n = 0; n < s; ++n) for (size_t n = 0; n < s; ++n)
prime(translators[n]); {
// Check that each translator uses at least one input and
// one output.
has.clear();
scan(translators[n], has);
if (!(has['f'] || has['s'] || has['l'] || has['w']
|| has['F'] || has['S'] || has['L'] || has['W']))
error(2, 0, "no input %%-sequence in '%s'.\n Use "
"one of %%f,%%s,%%l,%%w,%%F,%%S,%%L,%%W to indicate how "
"to pass the formula.", translators[n]);
if (!(has['N'] || has['T']))
error(2, 0, "no output %%-sequence in '%s'.\n Use "
"one of %%N,%%T to indicate where the automaton is saved.",
translators[n]);
// Remember the %-sequences used by all translators.
prime(translators[n]);
}
} }
@ -526,7 +544,7 @@ namespace
return string_ltl_wring; return string_ltl_wring;
if (!string_ltl_lbt.val().empty()) if (!string_ltl_lbt.val().empty())
return string_ltl_lbt; return string_ltl_lbt;
error(2, 0, "None of the translators need the input formula?"); assert(!"None of the translators need the input formula?");
return string_ltl_spot; return string_ltl_spot;
} }
@ -560,9 +578,7 @@ namespace
format(command, translators[translator_num]); format(command, translators[translator_num]);
toclean.push_back(output.val()); toclean.push_back(output.val());
if (output.format == printable_result_filename::None) assert(output.format != printable_result_filename::None);
error(2, 0, "no output sequence used in %s",
translators[translator_num]);
std::string cmd = command.str(); std::string cmd = command.str();
std::cerr << "Running [" << l << translator_num << "]: " std::cerr << "Running [" << l << translator_num << "]: "

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*- // -*- coding: utf-8 -*-
// Copyright (C) 2012 Laboratoire de Recherche et Développement de // Copyright (C) 2012, 2013 Laboratoire de Recherche et Développement
// l'Epita (LRDE). // de l'Epita (LRDE).
// //
// This file is part of Spot, a model checking library. // This file is part of Spot, a model checking library.
// //
@ -23,18 +23,24 @@
namespace spot namespace spot
{ {
void void
formater::prime(const char* fmt) formater::scan(const char* fmt, std::vector<bool>& has) const
{ {
for (const char* pos = fmt; *pos; ++pos) for (const char* pos = fmt; *pos; ++pos)
if (*pos == '%') if (*pos == '%')
{ {
char c = *++pos; char c = *++pos;
has_[c] = true; has[c] = true;
if (!c) if (!c)
break; break;
} }
} }
void
formater::prime(const char* fmt)
{
scan(fmt, has_);
}
std::ostream& std::ostream&
formater::format(const char* fmt) formater::format(const char* fmt)
{ {

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*- // -*- coding: utf-8 -*-
// Copyright (C) 2012 Laboratoire de Recherche et Développement de // Copyright (C) 2012, 2013 Laboratoire de Recherche et Développement
// l'Epita (LRDE). // de l'Epita (LRDE).
// //
// This file is part of Spot, a model checking library. // This file is part of Spot, a model checking library.
// //
@ -117,16 +117,32 @@ namespace spot
{ {
} }
/// \brief Scan the %-sequences occuring in \a fmt.
///
/// Set has['c'] for each %c in \a fmt. \a has must
/// be 256 wide.
/// @{
void
scan(const char* fmt, std::vector<bool>& has) const;
void
scan(const std::string& fmt, std::vector<bool>& has) const
{
scan(fmt.c_str(), has);
}
/// @}
/// Collect the %-sequences occurring in \a fmt. /// Collect the %-sequences occurring in \a fmt.
/// @{
void void
prime(const char* fmt); prime(const char* fmt);
/// Collect the %-sequences occurring in \a fmt.
void void
prime(const std::string& fmt) prime(const std::string& fmt)
{ {
prime(fmt.c_str()); prime(fmt.c_str());
} }
/// @}
/// Whether %c occurred in the primed formats. /// Whether %c occurred in the primed formats.
bool bool