* HACKING, Makefile.am, configure.ac, m4/gccwarn.m4,
src/Makefile.am, src/ltlast/Makefile.am, src/ltlast/allnodes.hh, src/ltlast/atomic_prop.cc, src/ltlast/atomic_prop.hh, src/ltlast/binop.cc, src/ltlast/binop.hh, src/ltlast/constant.cc, src/ltlast/constant.hh, src/ltlast/formulae.hh, src/ltlast/multop.cc, src/ltlast/multop.hh, src/ltlast/predecl.hh, src/ltlast/unop.cc, src/ltlast/unop.hh, src/ltlast/visitor.hh, src/ltlparse/Makefile.am, src/ltlparse/ltlparse.yy, src/ltlparse/ltlscan.ll, src/ltlparse/parsedecl.hh, src/ltlparse/public.hh, src/ltlvisit/Makefile.am, src/ltlvisit/dotty.cc, src/ltlvisit/dotty.hh, src/ltlvisit/dump.cc, src/ltlvisit/dump.hh, src/ltlvisit/rewrite.cc, src/ltlvisit/rewrite.hh, src/ltltest/Makefile.am, src/ltltest/defs.in, src/ltltest/readltl.cc, src/ltltest/parse.test, src/ltltest/parseerr.test, src/misc/Makefile.am, src/misc/const_sel.hh: New files.
This commit is contained in:
parent
ababb9ff93
commit
f0a8d0aeb3
46 changed files with 1818 additions and 0 deletions
107
src/ltlvisit/dotty.cc
Normal file
107
src/ltlvisit/dotty.cc
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
#include "dotty.hh"
|
||||
#include "ltlast/visitor.hh"
|
||||
#include "ltlast/allnodes.hh"
|
||||
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace ltl
|
||||
{
|
||||
|
||||
class dotty_visitor : public spot::ltl::const_visitor
|
||||
{
|
||||
public:
|
||||
dotty_visitor(std::ostream& os = std::cout)
|
||||
: os_(os), label_("i")
|
||||
{
|
||||
}
|
||||
|
||||
virtual
|
||||
~dotty_visitor()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
visit(const spot::ltl::atomic_prop* ap)
|
||||
{
|
||||
draw_node_(ap->name());
|
||||
}
|
||||
|
||||
void
|
||||
visit(const spot::ltl::constant* c)
|
||||
{
|
||||
draw_node_(c->val_name());
|
||||
}
|
||||
|
||||
void
|
||||
visit(const spot::ltl::binop* bo)
|
||||
{
|
||||
draw_rec_node_(bo->op_name());
|
||||
std::string label = label_;
|
||||
|
||||
label_ += "l";
|
||||
draw_link_(label, label_);
|
||||
bo->first()->accept(*this);
|
||||
label_ = draw_link_(label, label + "r");
|
||||
bo->second()->accept(*this);
|
||||
}
|
||||
|
||||
void
|
||||
visit(const spot::ltl::unop* uo)
|
||||
{
|
||||
draw_rec_node_(uo->op_name());
|
||||
label_ = draw_link_(label_, label_ + "c");
|
||||
uo->child()->accept(*this);
|
||||
}
|
||||
|
||||
void
|
||||
visit(const spot::ltl::multop* mo)
|
||||
{
|
||||
draw_rec_node_(mo->op_name());
|
||||
|
||||
unsigned max = mo->size();
|
||||
std::string label = label_;
|
||||
for (unsigned n = 0; n < max; ++n)
|
||||
{
|
||||
// FIXME: use `n' as a string for label names.
|
||||
label_ = draw_link_(label, label_ + "m");
|
||||
mo->nth(n)->accept(*this);
|
||||
}
|
||||
}
|
||||
private:
|
||||
std::ostream& os_;
|
||||
std::string label_;
|
||||
|
||||
const std::string&
|
||||
draw_link_(const std::string& in, const std::string& out)
|
||||
{
|
||||
os_ << " " << in << " -> " << out << ";" << std::endl;
|
||||
return out;
|
||||
}
|
||||
|
||||
void
|
||||
draw_rec_node_(const char* str) const
|
||||
{
|
||||
os_ << " " << label_ << " [label=\"" << str << "\", shabe=box];"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
draw_node_(const std::string& str) const
|
||||
{
|
||||
os_ << " " << label_ << " [label=\"" << str << "\"];" << std::endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void
|
||||
dotty(const formulae& f, std::ostream& os)
|
||||
{
|
||||
dotty_visitor v(os);
|
||||
os << "digraph G {" << std::endl;
|
||||
f.accept(v);
|
||||
os << "}" << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue