home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / xlisp / xlisp12.ark / XLISP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1985-02-20  |  1.6 KB  |  80 lines

  1. /* xlisp - a small subset of lisp */
  2.  
  3. #ifdef AZTEC
  4. #include "stdio.h"
  5. #include "setjmp.h"
  6. #else
  7. #include <stdio.h>
  8. #include <setjmp.h>
  9. #endif
  10.  
  11. #include "xlisp.h"
  12.  
  13. /* global variables */
  14. jmp_buf *xljmpbuf;
  15. jmp_buf topjmpbuf;
  16.  
  17. /* external variables */
  18. extern struct node *xlenv;
  19. extern struct node *xlstack;
  20. extern struct node *s_stdin,*s_stdout;
  21.  
  22. /* main - the main routine */
  23. main(argc,argv)
  24.   int argc; char *argv[];
  25. {
  26.     struct node expr;
  27.     int i;
  28.  
  29.     /* print the banner line */
  30.     printf("XLISP version 1.2\n");
  31.  
  32.     /* setup the error handler context buffer */
  33.     xljmpbuf = topjmpbuf;
  34.  
  35.     /* setup initialization error handler */
  36.     if (setjmp(xljmpbuf)) {
  37.     printf("fatal initialization error\n");
  38.     exit();
  39.     }
  40.  
  41.     /* initialize xlisp */
  42.     xlinit();
  43.  
  44.     /* load "init.lsp" */
  45.     if (setjmp(xljmpbuf) == 0)
  46.     xlload("init");
  47.  
  48.     /* load any files mentioned on the command line */
  49.     if (setjmp(xljmpbuf) == 0)
  50.     for (i = 1; i < argc; i++) {
  51.         printf("[ loading \"%s\" ]\n",argv[i]);
  52.         if (!xlload(argv[i]))
  53.         xlfail("can't load file");
  54.     }
  55.  
  56.     /* main command processing loop */
  57.     while (TRUE) {
  58.  
  59.     /* setup the error return */
  60.     setjmp(xljmpbuf);
  61.  
  62.     /* free any previous expression and leftover context */
  63.     xlstack = xlenv = NULL;
  64.  
  65.     /* create a new stack frame */
  66.     xlsave(&expr,NULL);
  67.  
  68.     /* read an expression */
  69.     if (!xlread(s_stdin->n_symvalue,&expr.n_ptr))
  70.         break;
  71.  
  72.     /* evaluate the expression */
  73.     expr.n_ptr = xleval(expr.n_ptr);
  74.  
  75.     /* print it */
  76.     xlprint(s_stdout->n_symvalue,expr.n_ptr,TRUE);
  77.     xlterpri(s_stdout->n_symvalue);
  78.     }
  79. }
  80.