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

  1. /* xlisp - a small subset of lisp */
  2.  
  3. /* system specific definitions */
  4.  
  5. /* NNODES    number of nodes to allocate in each request */
  6. /* TDEPTH    trace stack depth */
  7. /* FORWARD    type of a forward declaration (usually "") */
  8. /* LOCAL    type of a local function (usually "static") */
  9.  
  10. /* for the Computer Innovations compiler */
  11. #ifdef CI
  12. #define NNODES        1000
  13. #define TDEPTH        500
  14. #endif
  15.  
  16. /* for the CPM68K compiler */
  17. #ifdef CPM68K
  18. #define NNODES        1000
  19. #define TDEPTH        500
  20. #define LOCAL
  21. #undef NULL
  22. #define NULL        (char *)0
  23. #endif
  24.  
  25. /* for the DeSmet compiler */
  26. #ifdef DESMET
  27. #define NNODES        1000
  28. #define TDEPTH        500
  29. #define LOCAL
  30. #define getc(fp)    getcx(fp)
  31. #define EOF        -1
  32. #endif
  33.  
  34. /* for the VAX-11 C compiler */
  35. #ifdef vms
  36. #define NNODES        2000
  37. #define TDEPTH        1000
  38. #endif
  39.  
  40. /* for the DECUS C compiler */
  41. #ifdef decus
  42. #define NNODES        200
  43. #define TDEPTH        100
  44. #define FORWARD        extern
  45. #endif
  46.  
  47. /* for unix compilers */
  48. #ifdef unix
  49. #define NNODES        200
  50. #define TDEPTH        100
  51. #endif
  52.  
  53. /* for the AZTEC C compiler */
  54. #ifdef AZTEC
  55. #define NNODES        200
  56. #define TDEPTH        100
  57. #define getc(fp)    getcx(fp)
  58. #define putc(ch,fp)    aputc(ch,fp)
  59. #define malloc        alloc
  60. #define strchr        index
  61. #endif
  62.  
  63. /* default important definitions */
  64. #ifndef NNODES
  65. #define NNODES    200
  66. #endif
  67. #ifndef TDEPTH
  68. #define TDEPTH    100
  69. #endif
  70. #ifndef FORWARD
  71. #define FORWARD
  72. #endif
  73. #ifndef LOCAL
  74. #define LOCAL    static
  75. #endif
  76.  
  77. /* useful definitions */
  78. #define TRUE    1
  79. #define FALSE    0
  80.  
  81. /* program limits */
  82. #define STRMAX        100        /* maximum length of a string constant */
  83.     
  84. /* node types */
  85. #define FREE    0
  86. #define SUBR    1
  87. #define FSUBR    2
  88. #define LIST    3
  89. #define SYM    4
  90. #define INT    5
  91. #define STR    6
  92. #define OBJ    7
  93. #define FPTR    8
  94.  
  95. /* node flags */
  96. #define MARK    1
  97. #define LEFT    2
  98.  
  99. /* string types */
  100. #define DYNAMIC    0
  101. #define STATIC    1
  102.  
  103. /* symbol structure */
  104. struct xsym {
  105.     struct node *xsy_plist;    /* symbol plist - points to (name.plist) */
  106.     struct node *xsy_value;    /* the current value */
  107. };
  108.  
  109. /* subr/fsubr node structure */
  110. struct xsubr {
  111.     struct node *(*xsu_subr)();    /* pointer to an internal routine */
  112. };
  113.  
  114. /* list node structure */
  115. struct xlist {
  116.     struct node *xl_value;    /* value at this node */
  117.     struct node *xl_next;    /* next node */
  118. };
  119.  
  120. /* integer node structure */
  121. struct xint {
  122.     int xi_int;            /* integer value */
  123. };
  124.  
  125. /* string node structure */
  126. struct xstr {
  127.     int xst_type;        /* string type */
  128.     char *xst_str;        /* string pointer */
  129. };
  130.  
  131. /* object node structure */
  132. struct xobj {
  133.     struct node *xo_obclass;    /* class of object */
  134.     struct node *xo_obdata;    /* instance data */
  135. };
  136.  
  137. /* file pointer node structure */
  138. struct xfptr {
  139.     FILE *xf_fp;        /* the file pointer */
  140.     int xf_savech;        /* lookahead character for input files */
  141. };
  142.  
  143.  
  144. /* shorthand macros for accessing node substructures */
  145.  
  146. /* symbol node */
  147. #define n_symplist    n_info.n_xsym.xsy_plist
  148. #define n_symvalue    n_info.n_xsym.xsy_value
  149.  
  150. /* subr/fsubr node */
  151. #define n_subr        n_info.n_xsubr.xsu_subr
  152.  
  153. /* list node (and message node and binding node) */
  154. #define n_listvalue    n_info.n_xlist.xl_value
  155. #define n_listnext    n_info.n_xlist.xl_next
  156. #define n_msg        n_info.n_xlist.xl_value
  157. #define n_msgcode    n_info.n_xlist.xl_next
  158. #define n_bndsym    n_info.n_xlist.xl_value
  159. #define n_bndvalue    n_info.n_xlist.xl_next
  160. #define n_left        n_info.n_xlist.xl_value
  161. #define n_right        n_info.n_xlist.xl_next
  162. #define n_ptr        n_info.n_xlist.xl_value
  163.  
  164. /* integer node */
  165. #define n_int        n_info.n_xint.xi_int
  166.  
  167. /* string node */
  168. #define n_str        n_info.n_xstr.xst_str
  169. #define n_strtype    n_info.n_xstr.xst_type
  170.  
  171. /* object node */
  172. #define n_obclass    n_info.n_xobj.xo_obclass
  173. #define n_obdata    n_info.n_xobj.xo_obdata
  174.  
  175. /* file pointer node */
  176. #define n_fp        n_info.n_xfptr.xf_fp
  177. #define n_savech    n_info.n_xfptr.xf_savech
  178.  
  179. /* node structure */
  180. struct node {
  181.     char n_type;        /* type of node */
  182.     char n_flags;        /* flag bits */
  183.     union {            /* value */
  184.     struct xsym n_xsym;    /*     symbol node */
  185.     struct xsubr n_xsubr;    /*     subr/fsubr node */
  186.     struct xlist n_xlist;    /*     list node */
  187.     struct xint n_xint;    /*     integer node */
  188.     struct xstr n_xstr;    /*     string node */
  189.     struct xobj n_xobj;    /*     object node */
  190.     struct xfptr n_xfptr;    /*     file pointer node */
  191.     } n_info;
  192. };
  193.  
  194. /* function table entry structure */
  195. struct fdef {
  196.     char *f_name;
  197.     int f_type;
  198.     struct node *(*f_fcn)();
  199. };
  200.  
  201. /* external procedure declarations */
  202. extern struct node *xleval();        /* evaluate an expression */
  203. extern struct node *xlapply();        /* apply a function to arguments */
  204. extern struct node *xlevlist();        /* evaluate a list of arguments */
  205. extern struct node *xlarg();        /* fetch an argument */
  206. extern struct node *xlevarg();        /* fetch and evaluate an argument */
  207. extern struct node *xlmatch();        /* fetch an typed argument */
  208. extern struct node *xlevmatch();    /* fetch and evaluate a typed arg */
  209. extern struct node *xlsend();        /* send a message to an object */
  210. extern struct node *xlenter();        /* enter a symbol */
  211. extern struct node *xlsenter();        /* enter a symbol with a static pname */
  212. extern struct node *xlintern();        /* intern a symbol */
  213. extern struct node *xlmakesym();    /* make an uninterned symbol */
  214. extern struct node *xlsave();        /* generate a stack frame */
  215. extern struct node *xlobsym();        /* find an object's class or instance
  216.                        variable */
  217. extern struct node *xlgetprop();    /* get the value of a property */
  218. extern char *xlsymname();        /* get the print name of a symbol */
  219.  
  220. extern struct node *newnode();        /* allocate a new node */
  221. extern char *stralloc();        /* allocate string space */
  222. extern char *strsave();            /* make a safe copy of a string */
  223.