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.H < prev    next >
Text File  |  1986-10-12  |  5KB  |  201 lines

  1. /* xlisp - a small subset of lisp */
  2.  
  3. /* system specific definitions */
  4.  
  5. /* DEFEXT    define to enable default extension of '.lsp' on 'load' */
  6. /* FGETNAME    define if system supports 'fgetname' */
  7. /* NNODES    number of nodes to allocate in each request */
  8. /* TDEPTH    trace stack depth */
  9. /* KEYMAPCLASS    define to include the 'Keymap' class */
  10.  
  11. /* for the VAX-11 C compiler */
  12. #ifdef vms
  13. #define DEFEXT
  14. #define FGETNAME
  15. #define KEYMAPCLASS
  16. #define NNODES    2000
  17. #define TDEPTH    1000
  18. #endif
  19.  
  20. /* for the DECUS C compiler */
  21. #ifdef decus
  22. #define DEFEXT
  23. #define KEYMAPCLASS
  24. #define NNODES    200
  25. #define TDEPTH    100
  26. #endif
  27.  
  28. /* for unix compilers */
  29. #ifdef unix
  30. #define KEYMAPCLASS
  31. #define NNODES    200
  32. #define TDEPTH    100
  33. #endif
  34.  
  35. /* for the AZTEC C compiler */
  36. #ifdef AZTEC
  37. #define DEFEXT
  38. #define KEYMAPCLASS
  39. #define NNODES    200
  40. #define TDEPTH    100
  41. #define getc(fp)    getch(fp)
  42. #define kbin()        CPM(6,0xFF)
  43. #define malloc        alloc
  44. #define strchr        index
  45. #endif
  46.  
  47. /* default important definitions */
  48. #ifndef NNODES
  49. #define NNODES    200
  50. #endif
  51. #ifndef TDEPTH
  52. #define TDEPTH    100
  53. #endif
  54.  
  55. /* useful definitions */
  56. #define TRUE    1
  57. #define FALSE    0
  58.  
  59. /* program limits */
  60. #define STRMAX    100    /* maximum length of a string constant */
  61.  
  62. /* node types */
  63. #define FREE    0
  64. #define SUBR    1
  65. #define LIST    2
  66. #define SYM    3
  67. #define INT    4
  68. #define STR    5
  69. #define OBJ    6
  70. #define FPTR    7
  71. #define KMAP    8
  72.  
  73. /* node flags */
  74. #define MARK    1
  75. #define LEFT    2
  76.  
  77. /* string types */
  78. #define DYNAMIC    0
  79. #define STATIC    1
  80.  
  81. /* symbol structure */
  82. struct xsym {
  83.     char *xsy_name;        /* symbol name */
  84.     struct node *xsy_value;    /* the current value */
  85. };
  86.  
  87. /* subr node structure */
  88. struct xsubr {
  89.     struct node *(*xsu_subr)();    /* pointer to an internal routine */
  90. };
  91.  
  92. /* list node structure */
  93. struct xlist {
  94.     struct node *xl_value;    /* value at this node */
  95.     struct node *xl_next;    /* next node */
  96. };
  97.  
  98. /* integer node structure */
  99. struct xint {
  100.     int xi_int;            /* integer value */
  101. };
  102.  
  103. /* string node structure */
  104. struct xstr {
  105.     int xst_type;        /* string type */
  106.     char *xst_str;        /* string pointer */
  107. };
  108.  
  109. /* object node structure */
  110. struct xobj {
  111.     struct node *xo_obclass;    /* class of object */
  112.     struct node *xo_obdata;    /* instance data */
  113. };
  114.  
  115. /* file pointer node structure */
  116. struct xfptr {
  117.     FILE *xf_fp;        /* the file pointer */
  118. };
  119.  
  120. /* keymap structure */
  121. struct xkmap {
  122.     struct node *(*xkm_map)[];    /* selection pointer */
  123. };
  124.  
  125.  
  126. /* shorthand macros for accessing node substructures */
  127.  
  128. /* symbol node */
  129. #define n_symname    n_info.n_xsym.xsy_name
  130. #define n_symvalue    n_info.n_xsym.xsy_value
  131.  
  132. /* subr node */
  133. #define n_subr        n_info.n_xsubr.xsu_subr
  134.  
  135. /* list node (and message node and binding node) */
  136. #define n_listvalue    n_info.n_xlist.xl_value
  137. #define n_listnext    n_info.n_xlist.xl_next
  138. #define n_msg        n_info.n_xlist.xl_value
  139. #define n_msgcode    n_info.n_xlist.xl_next
  140. #define n_bndsym    n_info.n_xlist.xl_value
  141. #define n_bndvalue    n_info.n_xlist.xl_next
  142. #define n_left        n_info.n_xlist.xl_value
  143. #define n_right        n_info.n_xlist.xl_next
  144. #define n_ptr        n_info.n_xlist.xl_value
  145.  
  146. /* integer node */
  147. #define n_int        n_info.n_xint.xi_int
  148.  
  149. /* string node */
  150. #define n_str        n_info.n_xstr.xst_str
  151. #define n_strtype    n_info.n_xstr.xst_type
  152.  
  153. /* object node */
  154. #define n_obclass    n_info.n_xobj.xo_obclass
  155. #define n_obdata    n_info.n_xobj.xo_obdata
  156.  
  157. /* file pointer node */
  158. #define n_fname        n_info.n_xfptr.xf_name
  159. #define n_fp        n_info.n_xfptr.xf_fp
  160.  
  161. /* key map node */
  162. #define n_kmap        n_info.n_xkmap.xkm_map
  163.  
  164. /* node structure */
  165. struct node {
  166.     char n_type;        /* type of node */
  167.     char n_flags;        /* flag bits */
  168.     union {            /* value */
  169.     struct xsym n_xsym;    /*     symbol node */
  170.     struct xsubr n_xsubr;    /*     subr node */
  171.     struct xlist n_xlist;    /*     list node */
  172.     struct xint n_xint;    /*     integer node */
  173.     struct xstr n_xstr;    /*     string node */
  174.     struct xobj n_xobj;    /*     object node */
  175.     struct xfptr n_xfptr;    /*     file pointer node */
  176.     struct xkmap n_xkmap;    /*     key map node */
  177.     } n_info;
  178. };
  179.  
  180. /* external procedure declarations */
  181. extern struct node *xlread();        /* read an expression */
  182. extern struct node *xleval();        /* evaluate an expression */
  183. extern struct node *xlarg();        /* fetch an argument */
  184. extern struct node *xlevarg();        /* fetch and evaluate an argument */
  185. extern struct node *xlmatch();        /* fetch an typed argument */
  186. extern struct node *xlevmatch();    /* fetch and evaluate a typed arg */
  187. extern struct node *xlsend();        /* send a message to an object */
  188. extern struct node *xlmfind();        /* find the method for a message */
  189. extern struct node *xlxsend();        /* execute a message method */
  190. extern struct node *xlenter();        /* enter a symbol into the oblist */
  191. extern struct node *xlsave();        /* generate a stack frame */
  192. extern struct node *xlobsym();        /* find an object's class or instance
  193.                        variable */
  194. extern struct node *xlclass();        /* enter a class definition */
  195. extern struct node *xlivar();        /* get an instance variable */
  196. extern struct node *xlcvar();        /* get an instance variable */
  197. extern struct node *newnode();        /* allocate a new node */
  198.  
  199. extern char *stralloc();        /* allocate string space */
  200. extern char *strsave();            /* make a safe copy of a string */
  201.