readltl.cc 974 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include "ltlparse/public.hh"
#include "ltlvisit/dump.hh"
#include "ltlvisit/dotty.hh"

void
syntax(char *prog)
{
  std::cerr << prog << " [-d] formulae" << std::endl;
  exit(2);
}

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

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

  bool debug = false;
  int formulae_index = 1;

  if (!strcmp(argv[1], "-d"))
    {
      debug = true;
      if (argc < 3)
	syntax(argv[0]);
      formulae_index = 2;
    }    
  
  spot::ltl::parse_error_list pel;
  spot::ltl::formulae *f = spot::ltl::parse(argv[formulae_index], 
					    pel, debug);

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

  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;
}