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.
# FML interpreter. Europagate, 1995
#
-# $Id: Makefile,v 1.2 1995/02/09 14:33:36 adam Exp $
+# $Id: Makefile,v 1.3 1995/02/09 16:06:04 adam Exp $
SHELL=/bin/sh
INCLUDE=-I../include
CFLAGS=-g -Wall -pedantic
DEFS=$(INCLUDE)
LIB=fml.a
-PO = fmltoken.o fmlmem.o fml.o fmlsym.o fmlrel.o fmlarit.o fmllist.o
+PO = fmltoken.o fmlmem.o fml.o fmlsym.o fmlrel.o fmlarit.o fmllist.o \
+fmlcall.o fmlcalls.o
+
CPP=cc -E
CC=gcc
* FML interpreter. Europagate, 1995
*
* $Log: fml.c,v $
- * Revision 1.5 1995/02/09 14:33:36 adam
+ * Revision 1.6 1995/02/09 16:06:06 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.5 1995/02/09 14:33:36 adam
* Split source fml.c and define relevant build-in functions in separate
* files. New operators mult, div, not, llen implemented.
*
return fn;
}
-static struct fml_node *fml_exec_group (struct fml_node *list, Fml fml);
-
void fml_lr_values (Fml fml, struct fml_node *l, int *left_val,
struct fml_node *r, int *right_val)
{
fml_node_delete (fml, fn);
}
-static struct fml_node *fml_exec_group (struct fml_node *list, Fml fml)
+struct fml_node *fml_exec_group (struct fml_node *list, Fml fml)
{
struct token token;
struct fml_sym_info *info;
}
break;
case 't':
-#if 0
- printf ("<token.tokenbuf=%s>", token.tokenbuf);
-#endif
if (token.separate && !first)
putchar (' ');
first = 0;
fml_node_stat (fml);
fml_exec_group (fml->list, fml);
if (fml->debug & 1)
- printf ("\n");
+ putchar ('\n');
}
* FML interpreter. Europagate, 1995
*
* $Log: fml.h,v $
- * Revision 1.1 1995/02/06 13:48:09 adam
- * Initial revision
+ * Revision 1.2 1995/02/09 16:06:06 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.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.
*
*/
Fml fml_open (void);
int fml_preprocess (Fml fml);
+
void fml_exec (Fml fml);
+void fml_exec_call (Fml fml);
+void fml_exec_call_str (Fml fml, const char *str);
#define FML_ERR_NOMEM 1
--- /dev/null
+/*
+ * FML interpreter. Europagate, 1995
+ *
+ * $Log: fmlcall.c,v $
+ * Revision 1.1 1995/02/09 16:06:07 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.
+ *
+ */
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "fmlp.h"
+
+void fml_exec_call (Fml fml)
+{
+ struct fml_node *fn;
+
+ fml_node_stat (fml);
+ fn = fml_tokenize (fml);
+
+ fml_exec_group (fn, fml);
+ fml_node_delete (fml, fn);
+}
+
--- /dev/null
+/*
+ * FML interpreter. Europagate, 1995
+ *
+ * $Log: fmlcalls.c,v $
+ * Revision 1.1 1995/02/09 16:06:07 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.
+ *
+ */
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "fmlp.h"
+
+static const char *str_ptr;
+static int eof_mark;
+static int str_reader (void)
+{
+ if (!*str_ptr)
+ return eof_mark;
+ return *str_ptr++;
+}
+
+void fml_exec_call_str (Fml fml, const char *str)
+{
+ int (*old_func)(void) = fml->read_func;
+
+ fml->read_func = str_reader;
+ str_ptr = str;
+ eof_mark = fml->eof_mark;
+ fml_exec_call (fml);
+ fml->read_func = old_func;
+}
* FML interpreter. Europagate, 1995
*
* $Log: fmlp.h,v $
- * Revision 1.5 1995/02/09 14:37:19 adam
+ * Revision 1.6 1995/02/09 16:06:07 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.5 1995/02/09 14:37:19 adam
* Removed .depend from cvs. Removed function fml_mk_list.
*
* Revision 1.4 1995/02/09 14:33:37 adam
void fml_del_token (struct token *tp, Fml fml);
struct fml_node *fml_expr_term (Fml fml, struct fml_node **lp,
struct token *tp);
+struct fml_node *fml_exec_group (struct fml_node *list, Fml fml);
* 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
*/
#include <stdio.h>
+#include <string.h>
#include "fml.h"
static FILE *inf;
{
Fml fml;
int nfiles = 0;
+ int interactive = 0;
fml = fml_open ();
while (-- argc > 0)
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);
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;
}