fst-compare.C
1.71 KB
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
/*******************************************************************/
/* */
/* FILE fst-compare.C */
/* MODULE fst-compare */
/* PROGRAM SFST */
/* AUTHOR Helmut Schmid, IMS, University of Stuttgart */
/* */
/*******************************************************************/
#include "fst.h"
using std::cout;
using std::cerr;
/*******************************************************************/
/* */
/* main */
/* */
/*******************************************************************/
int main( int argc, char **argv )
{
FILE *file1, *file2;
if (argc < 3) {
fprintf(stderr,"\nUsage: %s file file\n\n", argv[0]);
exit(1);
}
if ((file1 = fopen(argv[1],"rb")) == NULL) {
fprintf(stderr,"\nError: Cannot open transducer file %s\n\n", argv[1]);
exit(1);
}
if ((file2 = fopen(argv[2],"rb")) == NULL) {
fprintf(stderr,"\nError: Cannot open transducer file %s\n\n", argv[2]);
exit(1);
}
try {
Transducer a1(file1);
fclose(file1);
Transducer a2(file2);
fclose(file2);
Transducer *p = &a2.copy(false, &a1.alphabet);
if (a1 == *p)
cout << "Transducers are equivalent\n";
else
cout << "Transducers are different\n";
}
catch (const char *p) {
cerr << p << "\n";
return 1;
}
return 0;
}