Nodes are freed now. Many bugs fixed.
[egate.git] / fml / fmltest.c
1 /*
2  * FML interpreter. Europagate, 1995
3  *
4  * $Log: fmltest.c,v $
5  * Revision 1.3  1995/02/09 13:07:15  adam
6  * Nodes are freed now. Many bugs fixed.
7  *
8  * Revision 1.2  1995/02/07  16:09:24  adam
9  * The \ character is no longer INCLUDED when terminating a token.
10  * Major changes in tokenization routines. Bug fixes in expressions
11  * with lists (fml_sub0).
12  *
13  * Revision 1.1.1.1  1995/02/06  13:48:10  adam
14  * First version of the FML interpreter. It's slow and memory isn't
15  * freed properly. In particular, the FML nodes aren't released yet.
16  *
17  */
18
19 #include <stdio.h>
20 #include "fml.h"
21
22 static FILE *inf;
23
24 static int inf_read (void)
25 {
26     return getc (inf);
27 }
28
29 int main (int argc, char **argv)
30 {
31     Fml fml;
32     int nfiles = 0;
33
34     fml = fml_open ();
35     while (-- argc > 0)
36     {
37         ++argv;
38         if (**argv == '-')
39         {
40             if (argv[0][1] == 'd')
41                 fml->debug |= 1;
42             else if (argv[0][1] == 'm')
43                 fml->debug |= 2;
44             else
45             {
46                 fprintf (stderr, "uknown option `%s'\n", *argv);
47                 exit (1);
48             }
49         }
50         else
51         {
52             nfiles++;
53             inf = fopen (*argv, "r");
54             if (!inf)
55             {
56                 fprintf (stderr, "cannot open `%s'\n", *argv);
57                 exit (1);
58             }
59             fml->read_func = inf_read;
60             fml_preprocess (fml);
61             fml_exec (fml);
62             fclose (inf);
63         }
64     }
65     if (!nfiles)
66     {
67         fml_preprocess (fml);
68         fml_exec (fml);
69     }
70     return 0;
71 }