hoa: make the parser more resilient to errors

* src/hoaparse/hoaparse.yy: Improve error recovery,
and fix location tracking in streams.
* src/hoaparse/public.hh: Store the last location so
that the next parse start at the correct position.
* src/bin/autfilt.cc: Stop parsing a stream on irrecoverable errors.
* src/tgbatest/hoaparse.test: Adjust tests.
This commit is contained in:
Alexandre Duret-Lutz 2014-11-20 12:29:18 +01:00
parent 392c527d31
commit 1d962f79ac
4 changed files with 152 additions and 80 deletions

View file

@ -343,13 +343,14 @@ namespace
for (;;)
{
pel.clear();
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);
error(2, 0, "failed to read automaton from %s", filename);
else
process_automaton(haut, filename);
}