equals.cc 1.19 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include "ltlparse/public.hh"
#include "ltlvisit/equals.hh"

void
syntax(char *prog)
{
  std::cerr << prog << " formulae1 formulae2" << std::endl;
  exit(2);
}

bool 
print_parse_error(const char* f, spot::ltl::parse_error_list& pel)
{
  bool err = false;

  spot::ltl::parse_error_list::iterator it;
  for (it = pel.begin(); it != pel.end(); ++it)
    {
      std::cerr << ">>> " << f << std::endl;
      unsigned n = 0;
      yy::Location& l = it->first;
      for (; n < 4 + l.begin.column; ++n)
	std::cerr << ' ';
      // Write at least one '^', even if begin==end.
      std::cerr << '^';
      ++n;
      for (; n < 4 + l.end.column; ++n)
	std::cerr << '^';
      std::cerr << std::endl << it->second << std::endl << std::endl;
      err = true;
    }
  return err;
}

int
main(int argc, char **argv)
{
  if (argc != 3)
    syntax(argv[0]);

  
  spot::ltl::parse_error_list p1;
  spot::ltl::formulae *f1 = spot::ltl::parse(argv[1], p1);

  if (print_parse_error(argv[1], p1))
    return 2;

  spot::ltl::parse_error_list p2;
  spot::ltl::formulae *f2 = spot::ltl::parse(argv[2], p2);
			
  if (print_parse_error(argv[2], p2))
    return 2;

  if (equals(f1, f2))
    return 0;
  return 1;

}