The \ character is no longer INCLUDED when terminating a token.
[egate.git] / fml / fmltest.c
index 24158d3..1947ba2 100644 (file)
@@ -2,25 +2,65 @@
  * FML interpreter. Europagate, 1995
  *
  * $Log: fmltest.c,v $
- * Revision 1.1  1995/02/06 13:48:09  adam
- * Initial revision
+ * Revision 1.2  1995/02/07 16:09:24  adam
+ * The \ character is no longer INCLUDED when terminating a token.
+ * Major changes in tokenization routines. Bug fixes in expressions
+ * with lists (fml_sub0).
+ *
+ * Revision 1.1.1.1  1995/02/06  13:48:10  adam
+ * First version of the FML interpreter. It's slow and memory isn't
+ * freed properly. In particular, the FML nodes aren't released yet.
  *
  */
 
 #include <stdio.h>
 #include "fml.h"
 
+static FILE *inf;
+
+static int inf_read (void)
+{
+    return getc (inf);
+}
+
 int main (int argc, char **argv)
 {
     Fml fml;
+    int nfiles = 0;
 
     fml = fml_open ();
-    if (argc >= 2 && (!strcmp (argv[1], "d") ||
-                      !strcmp (argv[1], "debug")))
+    while (-- argc > 0)
+    {
+        ++argv;
+        if (**argv == '-')
+        {
+            if (argv[0][1] == 'd')
+                fml->debug = 1;
+            else
+            {
+                fprintf (stderr, "uknown option `%s'\n", *argv);
+                exit (1);
+            }
+        }
+        else
+        {
+            nfiles++;
+            inf = fopen (*argv, "r");
+            if (!inf)
+            {
+                fprintf (stderr, "cannot open `%s'\n", *argv);
+                exit (1);
+            }
+            fml->read_func = inf_read;
+            fml_preprocess (fml);
+            fml_exec (fml);
+            fclose (inf);
+        }
+    }
+    if (!nfiles)
     {
-        fml->debug = 1;
+        fml_preprocess (fml);
+        fml_exec (fml);
     }
-    fml_preprocess (fml);
-    fml_exec (fml);
     return 0;
 }