Commit d552be30 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

ltlcross: Add a --stop-on-error option.

* src/bin/ltlcross.cc: Add the option.
* src/bin/common_finput.hh, src/bin/common_finput.cc: Make it possible
to abort run().
parent 1f12ad87
......@@ -81,6 +81,10 @@ parse_formula(const std::string& s, spot::ltl::parse_error_list& pel)
false, lenient);
}
job_processor::job_processor()
: abort_run(false)
{
}
int
job_processor::process_string(const std::string& input,
......@@ -109,7 +113,7 @@ job_processor::process_stream(std::istream& is,
int error = 0;
int linenum = 0;
std::string line;
while (std::getline(is, line))
while (!abort_run && std::getline(is, line))
error |= process_string(line, filename, ++linenum);
return error;
}
......@@ -133,7 +137,7 @@ job_processor::run()
{
int error = 0;
jobs_t::const_iterator i;
for (i = jobs.begin(); i != jobs.end(); ++i)
for (i = jobs.begin(); i != jobs.end() && !abort_run; ++i)
{
if (!i->file_p)
error |= process_string(i->str);
......
......@@ -51,7 +51,11 @@ parse_formula(const std::string& s, spot::ltl::parse_error_list& error_list);
class job_processor
{
protected:
bool abort_run; // Set to true in process_formula() to abort run().
public:
job_processor();
virtual ~job_processor()
{
}
......
......@@ -80,6 +80,7 @@ Exit status:\n\
#define OPT_CSV 4
#define OPT_DUPS 5
#define OPT_NOCHECKS 6
#define OPT_STOP_ERR 7
static const argp_option options[] =
{
......@@ -110,6 +111,9 @@ static const argp_option options[] =
{ "no-checks", OPT_NOCHECKS, 0, 0,
"do not perform any sanity checks (negated formulas "
"will not be translated)", 0 },
{ "stop-on-error", OPT_STOP_ERR, 0, 0,
"stop on first execution error or failure to pass"
" sanity checks (timeouts are OK)", 0 },
/**************************************************/
{ 0, 0, 0, 0, "State-space generation:", 5 },
{ "states", OPT_STATES, "INT", 0,
......@@ -143,6 +147,7 @@ const char* csv_output = 0;
bool want_stats = false;
bool allow_dups = false;
bool no_checks = false;
bool stop_on_error = false;
std::vector<char*> translators;
bool global_error_flag = false;
......@@ -295,6 +300,9 @@ parse_opt(int key, char* arg, struct argp_state*)
case OPT_STATES:
states = to_pos_int(arg);
break;
case OPT_STOP_ERR:
stop_on_error = true;
break;
default:
return ARGP_ERR_UNKNOWN;
}
......@@ -964,6 +972,9 @@ namespace
}
delete statespace;
std::cerr << std::endl;
// Shall we stop processing formulas now?
abort_run = global_error_flag && stop_on_error;
return 0;
}
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment