home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / LANGUAGS / XLISP / XLISP11.ARK / XLISP.C < prev    next >
Text File  |  1986-10-12  |  2KB  |  75 lines

  1. /* xlisp - a small subset of lisp */
  2.  
  3. #ifdef AZTEC
  4. #include "a:stdio.h"
  5. #include "a: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.  
  16. /* external variables */
  17. extern struct node *xlenv;
  18. extern struct node *xlstack;
  19. extern int xlpvals;
  20.  
  21. /* main - the main routine */
  22. main(argc,argv)
  23.   int argc; char *argv[];
  24. {
  25.     struct node expr;
  26.  
  27.     /* initialize the dynamic memory module (must be first) */
  28.     xldmeminit();
  29.  
  30.     /* initialize xlisp */
  31.     xlinit();
  32.     xleinit(); xllinit(); xlminit();
  33.     xloinit(); xlsinit(); xlfinit();
  34.     xlpinit();
  35.  
  36.     /* initialize the 'Keymap' class */
  37. #ifdef KEYMAPCLASS
  38.     xlkinit();
  39. #endif
  40.  
  41.     /* initialize terminal input */
  42.     xltin(FALSE);
  43.  
  44.     /* read the input file if specified */
  45.     if (argc > 1)
  46.     xlfin(argv[1]);
  47.     else
  48.     printf("XLISP version 1.1\n");
  49.  
  50.     /* main command processing loop */
  51.     while (TRUE) {
  52.  
  53.     /* setup the error return */
  54.     setjmp(xljmpbuf);
  55.  
  56.     /* free any previous expression and leftover context */
  57.     xlstack = xlenv = NULL;
  58.  
  59.     /* create a new stack frame */
  60.     xlsave(&expr,NULL);
  61.  
  62.     /* read an expression */
  63.     expr.n_ptr = xlread();
  64.  
  65.     /* evaluate the expression */
  66.     expr.n_ptr = xleval(expr.n_ptr);
  67.  
  68.     /* print it if necessary */
  69.     if (xlpvals) {
  70.         xlprint(expr.n_ptr,TRUE);
  71.         putchar('\n');
  72.     }
  73.     }
  74. }
  75.