/* xlisp - a small subset of lisp */ #define decusc /* system specific definitions */ /* DEFEXT define to enable default extension of '.lsp' on 'load' */ /* FGETNAME define if system supports 'fgetname' */ /* CNTRLGBREAK define if control-g is a break character */ /* for the VAX-11 C compiler */ #ifdef vms #define DEFEXT #define FGETNAME #define CNTRLGBREAK #endif /* for the DECUS C compiler */ #ifdef decusc #define DEFEXT /* enable extension defaulting on 'load' */ #define CNTRLGBREAK /* control-g is a break character */ #endif /* for unix compilers */ #ifdef unix #endif /* for the AZTEC C compiler */ #ifdef aztec #define DEFEXT #define getc(fp) getch(fp) #define kbin() CPM(6,0xFF) #define malloc alloc #endif /* useful definitions */ #define TRUE 1 #define FALSE 0 /* program limits */ #define STRMAX 100 /* maximum length of a string constant */ #define NNODES 200 /* number of nodes to allocate in each request */ #define TDEPTH 40 /* trace stack depth */ /* node types */ #define FREE 0 #define SUBR 1 #define LIST 2 #define SYM 3 #define INT 4 #define STR 5 /* #define OBJ 6 */ #define FPTR 7 /* #define KMAP 8 */ /* node flags */ #define MARK 1 #define LEFT 2 /* string types */ #define DYNAMIC 0 #define STATIC 1 /* symbol structure */ struct xsym { char *xsy_name; /* symbol name */ struct node *xsy_value; /* the current value */ }; /* subr node structure */ struct xsubr { struct node *(*xsu_subr)(); /* pointer to an internal routine */ }; /* list node structure */ struct xlist { struct node *xl_value; /* value at this node */ struct node *xl_next; /* next node */ }; /* integer node structure */ struct xint { int xi_int; /* integer value */ }; /* string node structure */ struct xstr { int xst_type; /* string type */ char *xst_str; /* string pointer */ }; #ifdef nottrue /* object node structure */ struct xobj { struct node *xo_obclass; /* class of object */ struct node *xo_obdata; /* instance data */ }; #endif /* file pointer node structure */ struct xfptr { FILE *xf_fp; /* the file pointer */ }; #ifdef nottrue /* keymap structure */ struct xkmap { struct node *(*xkm_map)[]; /* selection pointer */ }; #endif /* shorthand macros for accessing node substructures */ /* symbol node */ #define n_symname n_info.n_xsym.xsy_name #define n_symvalue n_info.n_xsym.xsy_value /* subr node */ #define n_subr n_info.n_xsubr.xsu_subr /* list node (and message node and binding node) */ #define n_listvalue n_info.n_xlist.xl_value #define n_listnext n_info.n_xlist.xl_next #define n_msg n_info.n_xlist.xl_value #define n_msgcode n_info.n_xlist.xl_next #define n_bndsym n_info.n_xlist.xl_value #define n_bndvalue n_info.n_xlist.xl_next #define n_left n_info.n_xlist.xl_value #define n_right n_info.n_xlist.xl_next #define n_ptr n_info.n_xlist.xl_value /* integer node */ #define n_int n_info.n_xint.xi_int /* string node */ #define n_str n_info.n_xstr.xst_str #define n_strtype n_info.n_xstr.xst_type #ifdef nottrue /* object node */ #define n_obclass n_info.n_xobj.xo_obclass #define n_obdata n_info.n_xobj.xo_obdata #endif /* file pointer node */ #define n_fname n_info.n_xfptr.xf_name #define n_fp n_info.n_xfptr.xf_fp #ifdef nottrue /* key map node */ #define n_kmap n_info.n_xkmap.xkm_map #endif /* node structure */ struct node { char n_type; /* type of node */ char n_flags; /* flag bits */ union { /* value */ struct xsym n_xsym; /* symbol node */ struct xsubr n_xsubr; /* subr node */ struct xlist n_xlist; /* list node */ struct xint n_xint; /* integer node */ struct xstr n_xstr; /* string node */ struct xfptr n_xfptr; /* file pointer node */ #ifdef nottrue struct xobj n_xobj; /* object node */ struct xkmap n_xkmap; /* key map node */ #endif } n_info; }; /* external procedure declarations */ extern struct node *xlread(); /* read an expression */ extern struct node *xleval(); /* evaluate an expression */ extern struct node *xlarg(); /* fetch an argument */ extern struct node *xlevarg(); /* fetch and evaluate an argument */ extern struct node *xlmatch(); /* fetch an typed argument */ extern struct node *xlevmatch(); /* fetch and evaluate a typed arg */ extern struct node *xlenter(); /* enter a symbol into the oblist */ extern struct node *xlsave(); /* generate a stack frame */ extern struct node *newnode(); /* allocate a new node */ extern char *stralloc(); /* allocate string space */ extern char *strsave(); /* make a safe copy of a string */