ltl2tgba.cc 1.95 KB
Newer Older
1
2
3
4
5
6
#include <iostream>
#include <cassert>
#include "ltlvisit/destroy.hh"
#include "ltlast/allnodes.hh"
#include "ltlparse/public.hh"
#include "tgba/ltl2tgba.hh"
7
8
#include "tgba/bddprint.hh"
#include "tgba/tgbabddtranslatefactory.hh"
9
10
11
12
13
#include "tgbaalgos/dotty.hh"

void
syntax(char* prog)
{
14
15
16
17
18
19
  std::cerr << "Usage: "<< prog << " [-d][-o][-r] formula" << std::endl
	    << std::endl
	    << "  -d   turn on traces during parsing" << std::endl
	    << "  -o   re-order BDD variables in the automata" << std::endl
	    << "  -r   display the relation BDD, not the reachability graph"
	    << std::endl;
20
21
22
23
24
25
26
27
  exit(2);
}

int
main(int argc, char** argv)
{
  int exit_code = 0;

28
29
30
31
  bool debug_opt = false;
  bool defrag_opt = false;
  bool rel_opt = false;
  int formula_index = 0;
32

33
  for (;;)
34
    {
35
      if (argc < formula_index + 2)
36
	syntax(argv[0]);
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

      ++formula_index;

      if (!strcmp(argv[formula_index], "-d"))
	{
	  debug_opt = true;
	}
      else if (!strcmp(argv[formula_index], "-o"))
	{
	  defrag_opt = true;
	}
      else if (!strcmp(argv[formula_index], "-r"))
	{
	  rel_opt = true;
	}
      else
	{
	  break;
	}
56
57
    }

58

59
60
61
  spot::ltl::environment& env(spot::ltl::default_environment::instance());
  spot::ltl::parse_error_list pel;
  spot::ltl::formula* f = spot::ltl::parse(argv[formula_index],
62
					   pel, env, debug_opt);
63
64
65
66
67
68
69
70

  exit_code =
    spot::ltl::format_parse_errors(std::cerr, argv[formula_index], pel);

  if (f)
    {
      spot::tgba_bdd_concrete a = spot::ltl_to_tgba(f);
      spot::ltl::destroy(f);
71
72
73
74
75
76
77
      if (defrag_opt)
	a = spot::defrag(a);
      if (rel_opt)
	spot::bdd_print_dot(std::cout, a.get_dict(), 
			    a.get_core_data().relation);
      else
	spot::dotty_reachable(std::cout, a);
78
79
80
81
82
83
84
85
86
87
88
89
    }
  else
    {
      exit_code = 1;
    }

  assert(spot::ltl::atomic_prop::instance_count() == 0);
  assert(spot::ltl::unop::instance_count() == 0);
  assert(spot::ltl::binop::instance_count() == 0);
  assert(spot::ltl::multop::instance_count() == 0);
  return exit_code;
}