dump.cc 1.31 KB
Newer Older
1
2
3
4
5
#include "dump.hh"
#include "ltlast/visitor.hh"
#include "ltlast/allnodes.hh"


6
namespace spot
7
8
9
10
11
12
13
14
15
16
17
{
  namespace ltl
  {

    class dump_visitor : public spot::ltl::const_visitor
    {
    public:
      dump_visitor(std::ostream& os = std::cout)
	: os_(os)
      {
      }
18
19

      virtual
20
21
22
23
      ~dump_visitor()
      {
      }

24
      void
25
26
27
28
29
30
31
32
33
      visit(const spot::ltl::atomic_prop* ap)
      {
	os_ << "AP(" << ap->name() << ")";
      }

      void
      visit(const spot::ltl::constant* c)
      {
	os_ << "constant(" << c->val_name() << ")";
34
35
      }

36
37
38
39
40
41
42
43
44
      void
      visit(const spot::ltl::binop* bo)
      {
	os_ << "binop(" << bo->op_name() << ", ";
	bo->first()->accept(*this);
	os_ << ", ";
	bo->second()->accept(*this);
	os_ << ")";
      }
45

46
47
48
49
50
51
52
      void
      visit(const spot::ltl::unop* uo)
      {
	os_ << "unop(" << uo->op_name() << ", ";
	uo->child()->accept(*this);
	os_ << ")";
      }
53

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
      void
      visit(const spot::ltl::multop* mo)
      {
	os_ << "multop(" << mo->op_name() << ", ";
	unsigned max = mo->size();
	mo->nth(0)->accept(*this);
	for (unsigned n = 1; n < max; ++n)
	  {
	    std::cout << ", ";
	    mo->nth(n)->accept(*this);
	  }
	os_ << ")";
      }
    private:
      std::ostream& os_;
    };

71
72
    void
    dump(const formula* f, std::ostream& os)
73
74
    {
      dump_visitor v(os);
75
      f->accept(v);
76
77
78
79
    }

  }
}