Introduce a translator class.
This perform pre- and post-processings in addition to the LTL-to-TGBA translation. * src/tgbaalgos/translate.cc, src/tgbaalgos/translate.hh: New files. * src/tgbaalgos/Makefile.am: Add them. * src/tgbaalgos/postproc.hh: Make the private part protected, so that we can inherit from that in the translator class. * src/bin/ltl2tgba.cc: Use the translator class to hide LTL simplification, translation, and postprocessings. * NEWS: Mention it.
This commit is contained in:
parent
0edb2b7a17
commit
c5b7e8e1da
6 changed files with 219 additions and 30 deletions
|
|
@ -31,13 +31,14 @@
|
|||
#include "common_finput.hh"
|
||||
#include "common_post.hh"
|
||||
|
||||
#include "ltlvisit/simplify.hh"
|
||||
#include "ltlast/formula.hh"
|
||||
#include "tgba/tgbaexplicit.hh"
|
||||
#include "tgbaalgos/dotty.hh"
|
||||
#include "tgbaalgos/lbtt.hh"
|
||||
#include "tgbaalgos/ltl2tgba_fm.hh"
|
||||
#include "tgbaalgos/neverclaim.hh"
|
||||
#include "tgbaalgos/save.hh"
|
||||
#include "tgbaalgos/stats.hh"
|
||||
#include "tgbaalgos/translate.hh"
|
||||
#include "tgba/bddprint.hh"
|
||||
#include "misc/optionmap.hh"
|
||||
|
||||
|
|
@ -174,13 +175,11 @@ namespace
|
|||
class trans_processor: public job_processor
|
||||
{
|
||||
public:
|
||||
spot::ltl::ltl_simplifier& simpl;
|
||||
spot::postprocessor& post;
|
||||
spot::translator& trans;
|
||||
spot::stat_printer statistics;
|
||||
|
||||
trans_processor(spot::ltl::ltl_simplifier& simpl,
|
||||
spot::postprocessor& post)
|
||||
: simpl(simpl), post(post), statistics(std::cout, stats)
|
||||
trans_processor(spot::translator& trans)
|
||||
: trans(trans), statistics(std::cout, stats)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -188,12 +187,7 @@ namespace
|
|||
process_formula(const spot::ltl::formula* f,
|
||||
const char* filename = 0, int linenum = 0)
|
||||
{
|
||||
const spot::ltl::formula* res = simpl.simplify(f);
|
||||
f->destroy();
|
||||
f = res;
|
||||
// This helps ltl_to_tgba_fm() to order BDD variables in a more
|
||||
// natural way (improving the degeneralization).
|
||||
simpl.clear_as_bdd_cache();
|
||||
const spot::tgba* aut = trans.run(&f);
|
||||
|
||||
// This should not happen, because the parser we use can only
|
||||
// read PSL/LTL formula, but since our ltl::formula* type can
|
||||
|
|
@ -207,10 +201,6 @@ namespace
|
|||
s.c_str());
|
||||
}
|
||||
|
||||
bool exprop = level == spot::postprocessor::High;
|
||||
const spot::tgba* aut = ltl_to_tgba_fm(f, simpl.get_dict(), exprop);
|
||||
aut = post.run(aut, f);
|
||||
|
||||
if (utf8)
|
||||
{
|
||||
spot::tgba* a = const_cast<spot::tgba*>(aut);
|
||||
|
|
@ -267,14 +257,12 @@ main(int argc, char** argv)
|
|||
error(2, 0, "No formula to translate? Run '%s --help' for usage.",
|
||||
program_name);
|
||||
|
||||
spot::ltl::ltl_simplifier simpl(simplifier_options());
|
||||
spot::translator trans(&extra_options);
|
||||
trans.set_pref(pref);
|
||||
trans.set_type(type);
|
||||
trans.set_level(level);
|
||||
|
||||
spot::postprocessor postproc(&extra_options);
|
||||
postproc.set_pref(pref);
|
||||
postproc.set_type(type);
|
||||
postproc.set_level(level);
|
||||
|
||||
trans_processor processor(simpl, postproc);
|
||||
trans_processor processor(trans);
|
||||
if (processor.run())
|
||||
return 2;
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue