parseaut: swallow the dstarparser
Note that the parser is still not able to reader multiple dstar automata. * src/dstarparse/: Delete. * configure.ac, src/Makefile.am, README: Adjust. * src/parseaut/parseaut.yy, src/parseaut/scanaut.ll: Merge in the dstarparser rules. * src/bin/common_trans.cc, src/bin/common_trans.hh, src/bin/dstar2tgba.cc, src/bin/ltlcross.cc, src/bin/ltldo.cc, src/tests/ikwiad.cc: Adjust usage. * src/tests/parseaut.test: Adjust expected output.
This commit is contained in:
parent
e7ecab93ff
commit
209e89a94c
18 changed files with 331 additions and 956 deletions
|
|
@ -194,7 +194,6 @@ printable_result_filename::~printable_result_filename()
|
|||
void printable_result_filename::reset(unsigned n)
|
||||
{
|
||||
translator_num = n;
|
||||
format = None;
|
||||
}
|
||||
|
||||
void printable_result_filename::cleanup()
|
||||
|
|
@ -204,33 +203,12 @@ void printable_result_filename::cleanup()
|
|||
}
|
||||
|
||||
void
|
||||
printable_result_filename::print(std::ostream& os, const char* pos) const
|
||||
printable_result_filename::print(std::ostream& os, const char*) const
|
||||
{
|
||||
output_format old_format = format;
|
||||
// The HOA parser can read LBTT, neverclaims, and HOA.
|
||||
if (*pos == 'N' || *pos == 'T' || *pos == 'H' || *pos == 'O')
|
||||
format = Hoa;
|
||||
else if (*pos == 'D')
|
||||
format = Dstar;
|
||||
else
|
||||
SPOT_UNREACHABLE();
|
||||
|
||||
if (val_)
|
||||
{
|
||||
// It's OK to use a specifier multiple time, but it's not OK
|
||||
// to mix the formats.
|
||||
if (format != old_format)
|
||||
error(2, 0,
|
||||
"you may not mix different output specifiers: %s",
|
||||
translators[translator_num].spec);
|
||||
}
|
||||
else
|
||||
{
|
||||
char prefix[30];
|
||||
snprintf(prefix, sizeof prefix, "lcr-o%u-", translator_num);
|
||||
const_cast<printable_result_filename*>(this)->val_
|
||||
= spot::create_tmpfile(prefix);
|
||||
}
|
||||
char prefix[30];
|
||||
snprintf(prefix, sizeof prefix, "lcr-o%u-", translator_num);
|
||||
const_cast<printable_result_filename*>(this)->val_ =
|
||||
spot::create_tmpfile(prefix);
|
||||
quote_shell_string(os, val()->name());
|
||||
}
|
||||
|
||||
|
|
@ -268,11 +246,11 @@ translator_runner::translator_runner(spot::bdd_dict_ptr dict,
|
|||
"one of %%f,%%s,%%l,%%w,%%F,%%S,%%L,%%W to indicate how "
|
||||
"to pass the formula.", t.spec);
|
||||
if (!no_output_allowed
|
||||
&& !(has['O'] || has['D'] ||
|
||||
&& !(has['O'] ||
|
||||
// backward-compatibility
|
||||
has['N'] || has['T'] || has['H']))
|
||||
error(2, 0, "no output %%-sequence in '%s'.\n Use one of "
|
||||
"%%O or %%D to indicate where and how the automaton is saved.",
|
||||
has['D'] || has['N'] || has['T'] || has['H']))
|
||||
error(2, 0, "no output %%-sequence in '%s'.\n Use "
|
||||
"%%O to indicate where the automaton is output.",
|
||||
t.spec);
|
||||
// Remember the %-sequences used by all translators.
|
||||
prime(t.cmd);
|
||||
|
|
|
|||
|
|
@ -60,8 +60,6 @@ struct printable_result_filename final:
|
|||
public spot::printable_value<spot::temporary_file*>
|
||||
{
|
||||
unsigned translator_num;
|
||||
enum output_format { None, Dstar, Hoa };
|
||||
mutable output_format format;
|
||||
|
||||
printable_result_filename();
|
||||
~printable_result_filename();
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
#include "twa/bddprint.hh"
|
||||
#include "misc/optionmap.hh"
|
||||
#include "misc/timer.hh"
|
||||
#include "dstarparse/public.hh"
|
||||
#include "parseaut/public.hh"
|
||||
#include "twaalgos/sccinfo.hh"
|
||||
|
||||
static const char argp_program_doc[] ="\
|
||||
|
|
@ -148,7 +148,7 @@ namespace
|
|||
process_file(const char* filename)
|
||||
{
|
||||
spot::parse_aut_error_list pel;
|
||||
auto daut = spot::dstar_parse(filename, pel, spot::make_bdd_dict());
|
||||
auto daut = spot::parse_aut(filename, pel, spot::make_bdd_dict());
|
||||
if (spot::format_parse_aut_errors(std::cerr, filename, pel))
|
||||
return 2;
|
||||
if (!daut)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
#include "common_trans.hh"
|
||||
#include "common_file.hh"
|
||||
#include "common_finput.hh"
|
||||
#include "dstarparse/public.hh"
|
||||
#include "parseaut/public.hh"
|
||||
#include "ltlast/unop.hh"
|
||||
#include "ltlvisit/print.hh"
|
||||
|
|
@ -493,8 +492,6 @@ namespace
|
|||
std::ostringstream command;
|
||||
format(command, translators[translator_num].cmd);
|
||||
|
||||
assert(output.format != printable_result_filename::None);
|
||||
|
||||
std::string cmd = command.str();
|
||||
std::cerr << "Running [" << l << translator_num << "]: "
|
||||
<< cmd << std::endl;
|
||||
|
|
@ -548,73 +545,42 @@ namespace
|
|||
status_str = "ok";
|
||||
problem = false;
|
||||
es = 0;
|
||||
switch (output.format)
|
||||
|
||||
spot::parse_aut_error_list pel;
|
||||
std::string filename = output.val()->name();
|
||||
auto aut = spot::parse_aut(filename, pel, dict);
|
||||
if (!pel.empty())
|
||||
{
|
||||
case printable_result_filename::Dstar:
|
||||
{
|
||||
spot::parse_aut_error_list pel;
|
||||
std::string filename = output.val()->name();
|
||||
auto aut = spot::dstar_parse(filename, pel, dict);
|
||||
if (!pel.empty())
|
||||
{
|
||||
status_str = "parse error";
|
||||
problem = true;
|
||||
es = -1;
|
||||
std::ostream& err = global_error();
|
||||
err << "error: failed to parse the produced DSTAR"
|
||||
" output.\n";
|
||||
spot::format_parse_aut_errors(err, filename, pel);
|
||||
end_error();
|
||||
res = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = aut->aut;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case printable_result_filename::Hoa: // Will also read neverclaims
|
||||
{
|
||||
spot::parse_aut_error_list pel;
|
||||
std::string filename = output.val()->name();
|
||||
auto aut = spot::parse_aut(filename, pel, dict);
|
||||
if (!pel.empty())
|
||||
{
|
||||
status_str = "parse error";
|
||||
problem = true;
|
||||
es = -1;
|
||||
std::ostream& err = global_error();
|
||||
err << "error: failed to parse the produced automaton.\n";
|
||||
spot::format_parse_aut_errors(err, filename, pel);
|
||||
end_error();
|
||||
res = nullptr;
|
||||
}
|
||||
else if (!aut)
|
||||
{
|
||||
status_str = "empty output";
|
||||
problem = true;
|
||||
es = -1;
|
||||
global_error() << "error: empty output.\n";
|
||||
end_error();
|
||||
res = nullptr;
|
||||
}
|
||||
else if (aut->aborted)
|
||||
{
|
||||
status_str = "aborted";
|
||||
problem = true;
|
||||
es = -1;
|
||||
global_error() << "error: aborted HOA file.\n";
|
||||
end_error();
|
||||
res = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = aut->aut;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case printable_result_filename::None:
|
||||
SPOT_UNREACHABLE();
|
||||
status_str = "parse error";
|
||||
problem = true;
|
||||
es = -1;
|
||||
std::ostream& err = global_error();
|
||||
err << "error: failed to parse the produced automaton.\n";
|
||||
spot::format_parse_aut_errors(err, filename, pel);
|
||||
end_error();
|
||||
res = nullptr;
|
||||
}
|
||||
else if (!aut)
|
||||
{
|
||||
status_str = "empty output";
|
||||
problem = true;
|
||||
es = -1;
|
||||
global_error() << "error: empty output.\n";
|
||||
end_error();
|
||||
res = nullptr;
|
||||
}
|
||||
else if (aut->aborted)
|
||||
{
|
||||
status_str = "aborted";
|
||||
problem = true;
|
||||
es = -1;
|
||||
global_error() << "error: aborted HOA file.\n";
|
||||
end_error();
|
||||
res = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = aut->aut;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@
|
|||
#include "twaalgos/relabel.hh"
|
||||
#include "twaalgos/totgba.hh"
|
||||
#include "parseaut/public.hh"
|
||||
#include "dstarparse/public.hh"
|
||||
|
||||
const char argp_program_doc[] ="\
|
||||
Run LTL/PSL formulas through another program, performing conversion\n\
|
||||
|
|
@ -134,8 +133,6 @@ namespace
|
|||
std::ostringstream command;
|
||||
format(command, translators[translator_num].cmd);
|
||||
|
||||
//assert(output.format != printable_result_filename::None);
|
||||
|
||||
std::string cmd = command.str();
|
||||
//std::cerr << "Running [" << l << translator_num << "]: "
|
||||
// << cmd << std::endl;
|
||||
|
|
@ -166,69 +163,44 @@ namespace
|
|||
std::cerr << "error: execution of command \"" << cmd
|
||||
<< "\" returned exit code " << es << ".\n";
|
||||
}
|
||||
else
|
||||
else if (output.val())
|
||||
{
|
||||
problem = false;
|
||||
switch (output.format)
|
||||
|
||||
spot::parse_aut_error_list pel;
|
||||
std::string filename = output.val()->name();
|
||||
auto aut = spot::parse_aut(filename, pel, dict);
|
||||
if (!pel.empty())
|
||||
{
|
||||
case printable_result_filename::Dstar:
|
||||
{
|
||||
spot::parse_aut_error_list pel;
|
||||
std::string filename = output.val()->name();
|
||||
auto aut = spot::dstar_parse(filename, pel, dict);
|
||||
if (!pel.empty())
|
||||
{
|
||||
problem = true;
|
||||
std::cerr << "error: failed to parse the output of \""
|
||||
<< cmd << "\" as a DSTAR automaton.\n";
|
||||
spot::format_parse_aut_errors(std::cerr, filename, pel);
|
||||
res = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = aut->aut;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case printable_result_filename::Hoa:
|
||||
{
|
||||
// Will also read neverclaims/LBTT
|
||||
spot::parse_aut_error_list pel;
|
||||
std::string filename = output.val()->name();
|
||||
auto aut = spot::parse_aut(filename, pel, dict);
|
||||
if (!pel.empty())
|
||||
{
|
||||
problem = true;
|
||||
std::cerr << "error: failed to parse the automaton "
|
||||
"produced by \"" << cmd << "\".\n";
|
||||
spot::format_parse_aut_errors(std::cerr, filename, pel);
|
||||
res = nullptr;
|
||||
}
|
||||
else if (!aut)
|
||||
{
|
||||
problem = true;
|
||||
std::cerr << "error: command \"" << cmd
|
||||
<< "\" produced an empty output.\n";
|
||||
res = nullptr;
|
||||
}
|
||||
else if (aut->aborted)
|
||||
{
|
||||
problem = true;
|
||||
std::cerr << "error: command \"" << cmd
|
||||
<< "\" aborted its output.\n";
|
||||
res = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = aut->aut;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case printable_result_filename::None:
|
||||
problem = false;
|
||||
problem = true;
|
||||
std::cerr << "error: failed to parse the automaton "
|
||||
"produced by \"" << cmd << "\".\n";
|
||||
spot::format_parse_aut_errors(std::cerr, filename, pel);
|
||||
res = nullptr;
|
||||
break;
|
||||
}
|
||||
else if (!aut)
|
||||
{
|
||||
problem = true;
|
||||
std::cerr << "error: command \"" << cmd
|
||||
<< "\" produced an empty output.\n";
|
||||
res = nullptr;
|
||||
}
|
||||
else if (aut->aborted)
|
||||
{
|
||||
problem = true;
|
||||
std::cerr << "error: command \"" << cmd
|
||||
<< "\" aborted its output.\n";
|
||||
res = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = aut->aut;
|
||||
}
|
||||
}
|
||||
else // No automaton output
|
||||
{
|
||||
problem = false;
|
||||
res = nullptr;
|
||||
}
|
||||
|
||||
output.cleanup();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue