2 * FML interpreter. Europagate, 1995
5 * Revision 1.8 1995/03/02 08:06:10 adam
6 * Fml function strsub implemented. New test files marc[45].fml.
7 * New test options in fmltest.
9 * Revision 1.7 1995/02/23 08:32:06 adam
12 * Revision 1.5 1995/02/10 15:50:56 adam
13 * MARC interface implemented. Minor bugs fixed. fmltest can
14 * be used to format single MARC records. New function '\list'
17 * Revision 1.4 1995/02/09 16:06:08 adam
18 * FML can be called from the outside multiple times by the functions:
19 * fml_exec_call and fml_exec_call_str.
20 * An interactive parameter (-i) to fmltest starts a shell-like
21 * interface to FML by using the fml_exec_call_str function.
23 * Revision 1.3 1995/02/09 13:07:15 adam
24 * Nodes are freed now. Many bugs fixed.
26 * Revision 1.2 1995/02/07 16:09:24 adam
27 * The \ character is no longer INCLUDED when terminating a token.
28 * Major changes in tokenization routines. Bug fixes in expressions
29 * with lists (fml_sub0).
31 * Revision 1.1.1.1 1995/02/06 13:48:10 adam
32 * First version of the FML interpreter. It's slow and memory isn't
33 * freed properly. In particular, the FML nodes aren't released yet.
46 static int inf_read (void)
51 int main (int argc, char **argv)
57 const char *iso2709_fname = NULL;
58 const char *format_func = NULL;
59 int number_of_records = 10000;
68 if (argv[0][1] == 'd')
70 else if (argv[0][1] == 'm')
72 else if (argv[0][1] == 'i')
74 else if (argv[0][1] == 's')
76 else if (argv[0][1] == 'n')
80 number_of_records = atoi (*++argv);
84 else if (argv[0][1] == '2')
88 iso2709_fname = *++argv;
90 format_func = *++argv;
95 fprintf (stderr, "missing marcfile and format\n");
101 fprintf (stderr, "unknown option `%s'\n", *argv);
108 inf = fopen (*argv, "r");
111 fprintf (stderr, "cannot open FML file `%s'\n", *argv);
114 fml->read_func = inf_read;
115 fml_preprocess (fml);
122 fml_preprocess (fml);
125 else if (iso2709_fname)
129 const char *nargv[5];
133 inf = fopen (iso2709_fname, "r");
136 fprintf (stderr, "cannot open %s\n", iso2709_fname);
139 while (no < number_of_records && (buf = iso2709_read (inf)))
141 rec = iso2709_cvt (buf);
144 nargv[1] = format_func;
145 nargv[2] = " \\list";
147 nargv[3]= marc_to_str (fml, rec);
149 printf ("\n[%s]\n", nargv[3]);
151 fml_exec_call_argv (fml, nargv);
165 const char *nargv[4];
170 if (!fgets (arg, 127, stdin))
172 if ((cp = strchr (arg, '\n')))
176 fml_exec_call_argv (fml, nargv);