xlisp.c
Click here to get the file
Size
1.2 kB
-
File type
text/x-csrc
File contents
/* xlisp - a small subset of lisp */
#include <setjmp.h>
#include "xlisp.h"
/* global variables */
jmp_buf xljmpbuf;
extern struct node *xlread();
extern struct node *xleval();
/* external variables */
extern struct node *xlenv;
extern struct node *xlstack;
extern int xlpvals;
/* inhibit the argv prompt */
int $$narg = 1;
/* main - the main routine */
main(argc,argv)
int argc; char *argv[];
{
struct node expr;
/* initialize the dynamic memory module (must be first) */
xldmeminit();
/* initialize xlisp */
xlinit();
xleinit(); xllinit(); xlminit();
xlkinit(); xloinit(); xlsinit();
/* initialize terminal input */
xltin();
/* read the input file if specified */
if (argc > 1)
xlfin(argv[1]);
/* main command processing loop */
while (TRUE) {
/* setup the error return */
setjmp(xljmpbuf);
/* free any previous expression and leftover context */
xlstack = xlenv = NULL;
/* create a new stack frame */
xlsave(&expr,NULL);
/* read an expression */
expr.n_ptr = xlread();
/* evaluate the expression */
expr.n_ptr = xleval(expr.n_ptr);
/* print it if necessary */
if (xlpvals) {
xlprint(expr.n_ptr);
putchar('\n');
}
}
}