FML can be called from the outside multiple times by the functions:
[egate.git] / fml / fmltest.c
index 6c07b3a..9c944e1 100644 (file)
@@ -2,7 +2,13 @@
  * FML interpreter. Europagate, 1995
  *
  * $Log: fmltest.c,v $
- * Revision 1.3  1995/02/09 13:07:15  adam
+ * Revision 1.4  1995/02/09 16:06:08  adam
+ * FML can be called from the outside multiple times by the functions:
+ * fml_exec_call and fml_exec_call_str.
+ * An interactive parameter (-i) to fmltest starts a shell-like
+ * interface to FML by using the fml_exec_call_str function.
+ *
+ * Revision 1.3  1995/02/09  13:07:15  adam
  * Nodes are freed now. Many bugs fixed.
  *
  * Revision 1.2  1995/02/07  16:09:24  adam
@@ -17,6 +23,7 @@
  */
 
 #include <stdio.h>
+#include <string.h>
 #include "fml.h"
 
 static FILE *inf;
@@ -30,6 +37,7 @@ int main (int argc, char **argv)
 {
     Fml fml;
     int nfiles = 0;
+    int interactive = 0;
 
     fml = fml_open ();
     while (-- argc > 0)
@@ -41,6 +49,10 @@ int main (int argc, char **argv)
                 fml->debug |= 1;
             else if (argv[0][1] == 'm')
                 fml->debug |= 2;
+            else if (argv[0][1] == 'i')
+            {
+                interactive = 1;
+            }
             else
             {
                 fprintf (stderr, "uknown option `%s'\n", *argv);
@@ -67,5 +79,26 @@ int main (int argc, char **argv)
         fml_preprocess (fml);
         fml_exec (fml);
     }
+    else
+    {
+        if (interactive)
+        {
+            char arg[128];
+
+            while (1)
+            {
+                char *cp;
+
+                printf ("\nFML>");
+                fflush (stdout);
+
+                if (!fgets (arg, 127, stdin))
+                    break;
+                if ((cp = strchr (arg, '\n')))
+                    *cp = '\0';
+                fml_exec_call_str (fml, arg);
+            }
+        }
+    }
     return 0;
 }