readltl.cc 1.02 KB
Newer Older
1
2
3
4
5
6
7
8
#include <iostream>
#include "ltlparse/public.hh"
#include "ltlvisit/dump.hh"
#include "ltlvisit/dotty.hh"

void
syntax(char *prog)
{
9
  std::cerr << prog << " [-d] formula" << std::endl;
10
11
12
13
14
15
16
17
18
19
20
21
  exit(2);
}

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

  if (argc < 2)
    syntax(argv[0]);

  bool debug = false;
22
  int formula_index = 1;
23
24
25
26
27
28

  if (!strcmp(argv[1], "-d"))
    {
      debug = true;
      if (argc < 3)
	syntax(argv[0]);
29
      formula_index = 2;
30
31
    }    
  
32
  spot::ltl::environment& env(spot::ltl::default_environment::instance());
33
  spot::ltl::parse_error_list pel;
34
  spot::ltl::formula *f = spot::ltl::parse(argv[formula_index], 
35
					   pel, env, debug);
36
37

  spot::ltl::parse_error_list::iterator it;
38
  exit_code = 
39
    spot::ltl::format_parse_errors(std::cerr, argv[formula_index], pel);
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

  if (f)
    {
#ifdef DOTTY
      spot::ltl::dotty(*f, std::cout);
#else
      spot::ltl::dump(*f, std::cout);
      std::cout << std::endl;
#endif
      delete f;
    }
  else
    {
      exit_code = 1;
    }
    
  return exit_code;
}