# FML interpreter. Europagate, 1995
#
-# $Id: Makefile,v 1.8 1995/02/21 12:11:27 adam Exp $
+# $Id: Makefile,v 1.9 1995/02/22 08:50:48 adam Exp $
SHELL=/bin/sh
INCLUDE=-I../include -I.
TPROG1=fmltest
CFLAGS=-g -Wall -pedantic
+CPP=$(CC) -E
DEFS=$(INCLUDE)
LIB=../lib/fml.a
PO = fmltoken.o fmlmem.o fml.o fmlsym.o fmlrel.o fmlarit.o fmllist.o \
* FML interpreter. Europagate, 1995
*
* $Log: fml.c,v $
- * Revision 1.10 1995/02/21 17:46:08 adam
+ * Revision 1.11 1995/02/22 08:50:49 adam
+ * Definition of CPP changed. Output function can be customized.
+ *
+ * Revision 1.10 1995/02/21 17:46:08 adam
* Bug fix in fml_sub0.
*
* Revision 1.9 1995/02/21 14:00:03 adam
return getchar ();
}
+static void default_write_func (int c)
+{
+ putchar (c);
+}
+
static void default_err_handle (int no)
{
fprintf (stderr, "Error: %d\n", no);
fml->white_chars = " \t\f\r\n";
fml->read_func = default_read_func;
fml->err_handle = default_err_handle;
+ fml->write_func = default_write_func;
fml->list = NULL;
fml->sym_tab = fml_sym_open ();
struct token *tp)
{
fml_cmd_lex (lp, tp);
- putchar ('\n');
+ (*fml->write_func) ('\n');
return NULL;
}
}
-static void fml_emit (struct fml_node *list)
+static void fml_emit (Fml fml, struct fml_node *list)
{
int s = 0;
while (list)
{
struct fml_atom *a;
if (s)
- printf (" ");
+ (*fml->write_func) (' ');
s++;
for (a = list->p[0]; a; a=a->next)
- printf ("%.*s", FML_ATOM_BUF, a->buf);
+ {
+ int i = 0;
+ while (i < FML_ATOM_BUF && a->buf[i])
+ (*fml->write_func) (a->buf[i++]);
+ }
}
else
- fml_emit (list->p[0]);
+ fml_emit (fml, list->p[0]);
list = list->p[1];
}
}
struct fml_node *fn;
fn = fml_sub1 (fml, lp, tp);
- fml_emit (fn);
+ fml_emit (fml, fn);
fml_node_delete (fml, fn);
}
case FML_PREFIX:
case FML_CPREFIX:
if (token.separate && !first)
- putchar (' ');
+ (*fml->write_func) (' ');
first = 1;
fml_emit_expr (fml, &list, &token);
fml_node_stat (fml);
break;
case 't':
if (token.separate && !first)
- putchar (' ');
+ (*fml->write_func) (' ');
first = 0;
fml_emit_expr (fml, &list, &token);
fml_node_stat (fml);