fst-lowmem.C
1.98 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*******************************************************************/
/* */
/* FILE fst-lowmem.C */
/* MODULE fst-lowmem */
/* PROGRAM SFST */
/* AUTHOR Helmut Schmid, IMS, University of Stuttgart */
/* */
/*******************************************************************/
#include "fst.h"
using std::cerr;
bool Switch=false;
/*******************************************************************/
/* */
/* main */
/* */
/*******************************************************************/
int main( int argc, char **argv )
{
FILE *file, *outfile;
if (argc == 2 && (strcmp(argv[1],"-h") == 0 ||
strcmp(argv[1],"-help") == 0 ||
strcmp(argv[1],"-?") == 0))
{
fprintf(stderr,"\nUsage: fst-lowmem [file [file]]\n\n");
fprintf(stderr,"Options:\n\t-s create transducer for generation\n\n");
exit(1);
}
int n = 1;
if (argc > 1 && strcmp(argv[1],"-s") == 0) {
Switch = true;
n++;
}
if (argc <= n)
file = stdin;
else {
if ((file = fopen(argv[n],"rb")) == NULL) {
fprintf(stderr,"Error: Cannot open input file %s\n\n", argv[n]);
exit(1);
}
n++;
}
if (argc <= n)
outfile = stdout;
else {
if ((outfile = fopen(argv[n],"wb")) == NULL) {
fprintf(stderr,"Error: Cannot open output file %s\n\n", argv[n]);
exit(1);
}
}
try {
Transducer a(file);
if (Switch)
a.switch_levels().store_lowmem(outfile);
else
a.store_lowmem(outfile);
}
catch (const char *p) {
cerr << p << "\n";
return 1;
}
return 0;
}