1 /* Copyright 1992 NEC Corporation, Tokyo, Japan. 2 * 3 * Permission to use, copy, modify, distribute and sell this software 4 * and its documentation for any purpose is hereby granted without 5 * fee, provided that the above copyright notice appear in all copies 6 * and that both that copyright notice and this permission notice 7 * appear in supporting documentation, and that the name of NEC 8 * Corporation not be used in advertising or publicity pertaining to 9 * distribution of the software without specific, written prior 10 * permission. NEC Corporation makes no representations about the 11 * suitability of this software for any purpose. It is provided "as 12 * is" without express or implied warranty. 13 * 14 * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN 16 * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 18 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 19 * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 20 * PERFORMANCE OF THIS SOFTWARE. 21 */ 22 23 /* $Id: lisp.h,v 1.2 2003/09/17 10:15:09 aida_s Exp $ */ 24 25 /* #include "keydef.h" 26 #include "mfdef.h" 27 #include "canna.h" 28 #include "symbolname.h" */ 29 #include "ccompat.h" 30 31 #define YES 1 32 #define NO 0 33 34 #define VALGET 1 35 #define VALSET 0 36 37 #define CELLSIZE 10240 /* size of cell area (byte) */ 38 #define STKSIZE 1024 /* the depth of value & parameter stack */ 39 #define BUFSIZE 256 /* universal buffer size (byte) */ 40 41 #define NIL 0 /* internal expression of NIL */ 42 #define UNBOUND -2 /* unbound mark of variable */ 43 #define NON -1 /* the mark of No. (unable to use NO) */ 44 45 #define UNDEF 0 46 #define SPECIAL 1 47 #define SUBR 2 48 #define EXPR 3 49 #define CMACRO 4 50 #define MACRO 5 51 52 #define TAG_MASK 0x07000000L 53 #define CELL_MASK 0x00ffffffL 54 #define GC_MASK 0x08000000L 55 56 #define NIL_TAG 0L 57 #define NUMBER_TAG 0x01000000L 58 #define STRING_TAG 0x02000000L 59 #define SYMBOL_TAG 0x03000000L 60 #define CONS_TAG 0x04000000L 61 62 #define MAX_DEPTH 20 63 64 /* define macros */ 65 66 #define null(x) !(x) 67 #define tag(x) ((x) & TAG_MASK) 68 #define atom(x) (tag(x) < CONS_TAG) 69 #define constp(x) (tag(x) < SYMBOL_TAG) 70 #define numberp(x) (tag(x) == NUMBER_TAG) 71 #define stringp(x) (tag(x) == STRING_TAG) 72 #define symbolp(x) (tag(x) == SYMBOL_TAG) 73 #define consp(x) (tag(x) == CONS_TAG) 74 75 #define gcfield(x) (((struct gccell *)x)->tagfield) 76 #define mkcopied(x) ((x) | GC_MASK) 77 #define alreadycopied(x) (gcfield(x) & GC_MASK) 78 #define newaddr(x) ((x) & ~GC_MASK) 79 80 typedef canna_intptr_t list; 81 typedef canna_intptr_t pointerint; 82 83 /* cell area */ 84 85 #define celloffset(x) ((x) & CELL_MASK) 86 87 #define car(x) ((struct cell *)(celltop + celloffset(x)))->head 88 #define cdr(x) ((struct cell *)(celltop + celloffset(x)))->tail 89 #define caar(x) car(car(x)) 90 #define cadr(x) car(cdr(x)) 91 #define cdar(x) cdr(car(x)) 92 #define cddr(x) cdr(cdr(x)) 93 94 #define symbolpointer(x) ((struct atomcell *)(celltop + celloffset(x))) 95 96 #define mknum(x) (NUMBER_TAG | ((x) & CELL_MASK)) 97 #define xnum(x) ((((x) & 0x00800000)) ? (x | 0xff000000) : (x & 0x00ffffff)) 98 99 #define xstring(x) (((struct stringcell *)(celltop + celloffset(x)))->str) 100 #define xstrlen(x) (((struct stringcell *)(celltop + celloffset(x)))->length) 101 102 #define argnchk(fn,x) if (n != x) argnerr(fn) 103 104 /* data type definitions */ 105 106 struct cell { 107 list tail; 108 list head; 109 }; 110 111 struct atomcell { 112 list plist; 113 list value; 114 char *pname; 115 int ftype; 116 list (*func)(); 117 list (*valfunc)(); 118 int mid; 119 int fid; 120 list hlink; 121 }; 122 123 struct stringcell { 124 int length; 125 char str[4]; /* dummy array */ 126 }; 127 128 struct gccell { 129 list tagfield; 130 }; 131 132 struct atomdefs { 133 char *symname; 134 int symtype; 135 list (*symfunc)(); 136 }; 137 138 struct cannafndefs { 139 char *fnname; 140 int fnid; 141 }; 142 143 struct cannamodedefs { 144 char *mdname; 145 int mdid; 146 }; 147 148 struct cannavardefs { 149 char *varname; 150 list (*varfunc)(); 151 }; 152