/* xlisp - a small subset of lisp */ #include /* #include */ #include "xlisp.h" /* global variables */ /* jmp_buf xljmpbuf; */ /* external variables */ extern struct node *xlenv; extern struct node *xlstack; extern int xlpvals; /* Read file, if it exists */ static int xlfget(mylib) char *mylib; { FILE *xf; /* Try opening the file */ if((xf = fopen(mylib, "r")) != 0) { fclose(xf); xlfin(mylib); return(TRUE); } return(FALSE); } /* 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(); xlsinit(); xlfinit(); xlpinit(); xlhinit(); /* initialize terminal input */ xltin(FALSE); /* read the input file if specified */ if (argc > 1) xlfin(argv[1]); else if(( /* Read system file, if accessible */ xlfget("SY:[1,1]MINI.LSP") | /* Read user file, if accessible */ xlfget("MINI.LSP") ) == FALSE) printf("\nMiniLISP 1.0\n"); /* main command processing loop */ while (TRUE) { /* setup the error return */ /* setjmp(xljmpbuf); */ /* Jan Brittenson UFH 11-Oct-86 */ #ifdef decusc setexit(); #endif /* 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,TRUE); putchar('\n'); } } }