* src/ltlparse/public.hh (format_parse_errors): New function.

* src/ltlparse/fmterror.cc: New file.
* src/ltlparse/Makefile.am (libltlparse_a_SOURCES): Add fmterror.cc.
* src/ltltests/equals.cc, src/ltltests/readltl.cc: Simplify using
format_parse_errors.
This commit is contained in:
Alexandre Duret-Lutz 2003-04-16 12:58:17 +00:00
parent 7425f4a91e
commit 532f9131f5
6 changed files with 52 additions and 41 deletions

View file

@ -9,30 +9,6 @@ syntax(char *prog)
exit(2);
}
bool
print_parse_error(const char* f, spot::ltl::parse_error_list& pel)
{
bool err = false;
spot::ltl::parse_error_list::iterator it;
for (it = pel.begin(); it != pel.end(); ++it)
{
std::cerr << ">>> " << f << std::endl;
unsigned n = 0;
yy::Location& l = it->first;
for (; n < 4 + l.begin.column; ++n)
std::cerr << ' ';
// Write at least one '^', even if begin==end.
std::cerr << '^';
++n;
for (; n < 4 + l.end.column; ++n)
std::cerr << '^';
std::cerr << std::endl << it->second << std::endl << std::endl;
err = true;
}
return err;
}
int
main(int argc, char **argv)
{
@ -43,13 +19,13 @@ main(int argc, char **argv)
spot::ltl::parse_error_list p1;
spot::ltl::formulae *f1 = spot::ltl::parse(argv[1], p1);
if (print_parse_error(argv[1], p1))
if (spot::ltl::format_parse_errors(std::cerr, argv[1], p1))
return 2;
spot::ltl::parse_error_list p2;
spot::ltl::formulae *f2 = spot::ltl::parse(argv[2], p2);
if (print_parse_error(argv[2], p2))
if (spot::ltl::format_parse_errors(std::cerr, argv[2], p2))
return 2;
if (equals(f1, f2))

View file

@ -34,21 +34,8 @@ main(int argc, char **argv)
pel, debug);
spot::ltl::parse_error_list::iterator it;
for (it = pel.begin(); it != pel.end(); ++it)
{
std::cerr << ">>> " << argv[formulae_index] << std::endl;
unsigned n = 0;
yy::Location& l = it->first;
for (; n < 4 + l.begin.column; ++n)
std::cerr << ' ';
// Write at least one '^', even if begin==end.
std::cerr << '^';
++n;
for (; n < 4 + l.end.column; ++n)
std::cerr << '^';
std::cerr << std::endl << it->second << std::endl << std::endl;
exit_code = 1;
}
exit_code =
spot::ltl::format_parse_errors(std::cerr, argv[formulae_index], pel);
if (f)
{