* src/ltlvisit/tunabbrev.cc, src/ltlvisit/tunabbrev.hh: New files.
* src/ltlvisit/Makefile.am (libltlvisit_a_SOURCES): Add them. * src/ltltest/tunabbrev.test: New file. * src/ltltest/lunabbrev.test: Fix comment. * src/ltltest/Makefile.am (TESTS): Add tunabbrev.test. (check_PROGRAMS): Add tunabbrev. (tunabbrev_SOURCES, tunabbrev_CPPFLAGS): New variables. * src/ltltest/equals.cc (main) [TUNABBREV]: Call unabbreviate_ltl. * src/ltlvisit/lunabbrev.hh (unabbreviate_logic_visitor::recurse): New virtual function. * src/ltlvisit/lunabbrev.cc (unabbreviate_logic_visitor::recurse): Likewise. (unabbreviate_logic_visitor::visit): Use it instead of calling unabbreviate_logic directly.
This commit is contained in:
parent
fc3ceebd4f
commit
080214ebb8
11 changed files with 160 additions and 9 deletions
|
|
@ -10,4 +10,6 @@ libltlvisit_a_SOURCES = \
|
|||
equals.cc \
|
||||
equals.hh \
|
||||
lunabbrev.hh \
|
||||
lunabbrev.cc
|
||||
lunabbrev.cc \
|
||||
tunabbrev.hh \
|
||||
tunabbrev.cc
|
||||
|
|
|
|||
|
|
@ -34,14 +34,14 @@ namespace spot
|
|||
void
|
||||
unabbreviate_logic_visitor::visit(const unop* uo)
|
||||
{
|
||||
result_ = new unop(uo->op(), unabbreviate_logic(uo->child()));
|
||||
result_ = new unop(uo->op(), recurse(uo->child()));
|
||||
}
|
||||
|
||||
void
|
||||
unabbreviate_logic_visitor::visit(const binop* bo)
|
||||
{
|
||||
formula* f1 = unabbreviate_logic(bo->first());
|
||||
formula* f2 = unabbreviate_logic(bo->second());
|
||||
formula* f1 = recurse(bo->first());
|
||||
formula* f2 = recurse(bo->second());
|
||||
switch (bo->op())
|
||||
{
|
||||
/* f1 ^ f2 == (f1 & !f2) | (f2 & !f1) */
|
||||
|
|
@ -82,11 +82,16 @@ namespace spot
|
|||
unsigned mos = mo->size();
|
||||
for (unsigned i = 0; i < mos; ++i)
|
||||
{
|
||||
res->add(unabbreviate_logic(mo->nth(i)));
|
||||
res->add(recurse(mo->nth(i)));
|
||||
}
|
||||
result_ = res;
|
||||
}
|
||||
|
||||
formula* unabbreviate_logic_visitor::recurse(const formula* f)
|
||||
{
|
||||
return unabbreviate_logic(f);
|
||||
}
|
||||
|
||||
formula*
|
||||
unabbreviate_logic(const formula* f)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@ namespace spot
|
|||
void visit(const multop* mo);
|
||||
void visit(const constant* c);
|
||||
|
||||
private:
|
||||
virtual formula* recurse(const formula* f);
|
||||
|
||||
protected:
|
||||
formula* result_;
|
||||
};
|
||||
|
||||
|
|
|
|||
53
src/ltlvisit/tunabbrev.cc
Normal file
53
src/ltlvisit/tunabbrev.cc
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#include "ltlast/allnodes.hh"
|
||||
#include "tunabbrev.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace ltl
|
||||
{
|
||||
unabbreviate_ltl_visitor::unabbreviate_ltl_visitor()
|
||||
{
|
||||
}
|
||||
|
||||
unabbreviate_ltl_visitor::~unabbreviate_ltl_visitor()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
unabbreviate_ltl_visitor::visit(const unop* uo)
|
||||
{
|
||||
switch (uo->op())
|
||||
{
|
||||
case unop::X:
|
||||
case unop::Not:
|
||||
this->super::visit(uo);
|
||||
return;
|
||||
case unop::F:
|
||||
result_ = new binop(binop::U,
|
||||
new constant(constant::True),
|
||||
recurse(uo->child()));
|
||||
return;
|
||||
case unop::G:
|
||||
result_ = new binop(binop::R,
|
||||
new constant(constant::False),
|
||||
recurse(uo->child()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
formula*
|
||||
unabbreviate_ltl_visitor::recurse(const formula* f)
|
||||
{
|
||||
return unabbreviate_ltl(f);
|
||||
}
|
||||
|
||||
formula*
|
||||
unabbreviate_ltl(const formula* f)
|
||||
{
|
||||
unabbreviate_ltl_visitor v;
|
||||
f->accept(v);
|
||||
return v.result();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
27
src/ltlvisit/tunabbrev.hh
Normal file
27
src/ltlvisit/tunabbrev.hh
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#ifndef SPOT_LTLVISIT_TUNABBREV_HH
|
||||
# define SPOT_LTLVISIT_TUNABBREV_HH
|
||||
|
||||
#include "ltlast/formula.hh"
|
||||
#include "ltlvisit/lunabbrev.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace ltl
|
||||
{
|
||||
class unabbreviate_ltl_visitor : public unabbreviate_logic_visitor
|
||||
{
|
||||
typedef unabbreviate_logic_visitor super;
|
||||
public:
|
||||
unabbreviate_ltl_visitor();
|
||||
virtual ~unabbreviate_ltl_visitor();
|
||||
|
||||
void visit(const unop* uo);
|
||||
|
||||
formula* recurse(const formula* f);
|
||||
};
|
||||
|
||||
formula* unabbreviate_ltl(const formula* f);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SPOT_LTLVISIT_TUNABBREV_HH
|
||||
Loading…
Add table
Add a link
Reference in a new issue