hoa: make it possible to read a stream of automata

* src/bin/autfilt.cc: Loop over all automata in a file.
* src/hoaparse/public.hh: Turn the parser into an object.
* src/hoaparse/hoaparse.yy: Adjust.
This commit is contained in:
Alexandre Duret-Lutz 2014-11-19 18:50:51 +01:00
parent 5aff262844
commit 131299d03e
3 changed files with 75 additions and 28 deletions

View file

@ -292,17 +292,10 @@ namespace
SPOT_UNREACHABLE();
}
int
process_file(const char* filename)
process_automaton(const spot::const_hoa_aut_ptr& haut,
const char* filename)
{
spot::hoa_parse_error_list pel;
auto haut = spot::hoa_parse(filename, pel, spot::make_bdd_dict());
if (spot::format_hoa_parse_errors(std::cerr, filename, pel))
return 2;
if (!haut)
error(2, 0, "failed to read automaton from %s", filename);
spot::stopwatch sw;
sw.start();
auto aut = post.run(haut->aut, nullptr);
@ -337,6 +330,32 @@ namespace
flush_cout();
return 0;
}
int
process_file(const char* filename)
{
spot::hoa_parse_error_list pel;
auto b = spot::make_bdd_dict();
auto hp = spot::hoa_stream_parser(filename);
int err = 0;
for (;;)
{
auto haut = hp.parse(pel, b);
if (!haut && pel.empty())
break;
if (spot::format_hoa_parse_errors(std::cerr, filename, pel))
err = 2;
if (!haut)
error(0, 0, "failed to read automaton from %s", filename);
else
process_automaton(haut, filename);
}
return err;
}
};
}