2 # This is a shell archive (produced by GNU sharutils 4.6.3).
3 # To extract the files from this archive, save it to some FILE, remove
4 # everything before the `#!/bin/sh' line above, then type `sh FILE'.
7 # Made on 2010-12-08 20:21 UTC by <ying@althonx4>.
8 # Source directory was `/mnt/rd1/apli'.
10 # Existing files will *not* be overwritten, unless `-c' is specified.
14 # ------ ---------- ------------------------------------------
15 # 6656 -rw-r--r-- apli/arith.c
16 # 6494 -rw-r--r-- apli/cellt.c
17 # 9497 -rw-r--r-- apli/eval.c
18 # 7383 -rw-r--r-- apli/flow.c
19 # 3790 -rw-r--r-- apli/globals.c
20 # 8984 -rw-r--r-- apli/init.c
21 # 21896 -rw-r--r-- apli/io.c
22 # 2972 -rw-r--r-- apli/iter.c
23 # 8205 -rw-r--r-- apli/kcomp.c
24 # 91 -rw-r--r-- apli/kern.c
25 # 11787 -rw-r--r-- apli/list.c
26 # 4836 -rw-r--r-- apli/logic.c
27 # 3088 -rw-r--r-- apli/map.c
28 # 6887 -rw-r--r-- apli/misc.c
29 # 3014 -rw-r--r-- apli/prop.c
30 # 5265 -rw-r--r-- apli/set.c
31 # 2993 -rw-r--r-- apli/str.c
32 # 2489 -rw-r--r-- apli/sym.c
33 # 2442 -rw-r--r-- apli/symt.c
34 # 1574 -rw-r--r-- apli/vec.c
35 # 14099 -rw-r--r-- apli/kernel.h
36 # 559 -rw-r--r-- apli/README
37 # 393 -rw-r--r-- apli/Makefile
39 MD5SUM
=${MD5SUM-md5sum}
40 f
=`${MD5SUM} --version | egrep '^md5sum .*(core|text)utils'`
41 test -n "${f}" && md5check
=true || md5check
=false
43 echo 'Note: not verifying md5sums. Consider installing GNU coreutils.'
51 if test "$gettext_dir" = FAILED
&& test -f $dir/gettext \
52 && ($dir/gettext --version >/dev
/null
2>&1)
54 case `$dir/gettext --version 2>&1 | sed 1q` in
55 *GNU
*) gettext_dir
=$dir ;;
58 if test "$locale_dir" = FAILED
&& test -f $dir/shar \
59 && ($dir/shar --print-text-domain-dir >/dev
/null
2>&1)
61 locale_dir
=`$dir/shar --print-text-domain-dir`
65 if test "$locale_dir" = FAILED ||
test "$gettext_dir" = FAILED
69 TEXTDOMAINDIR
=$locale_dir
73 echo="$gettext_dir/gettext -s"
75 if (echo "testing\c"; echo 1,2,3) |
grep c
>/dev
/null
76 then if (echo -n test; echo 1,2,3) |
grep n
>/dev
/null
79 else shar_n
=-n shar_c
= ; fi
80 else shar_n
= shar_c
='\c' ; fi
84 st2tr
=123123592001.5 # old SysV 14-char limit
87 if touch -am -t ${st1} ${f} >/dev
/null
2>&1 && \
88 test ! -f ${st1} && test -f ${f}; then
89 shar_touch
='touch -am -t $1$2$3$4$5$6.$7 "$8"'
91 elif touch -am ${st2} ${f} >/dev
/null
2>&1 && \
92 test ! -f ${st2} && test ! -f ${st2tr} && test -f ${f}; then
93 shar_touch
='touch -am $3$4$5$6$1$2.$7 "$8"'
95 elif touch -am ${st3} ${f} >/dev
/null
2>&1 && \
96 test ! -f ${st3} && test -f ${f}; then
97 shar_touch
='touch -am $3$4$5$6$2 "$8"'
102 ${echo} 'WARNING: not restoring timestamps. Consider getting and'
103 ${echo} 'installing GNU `touch'\'', distributed in GNU coreutils...'
106 rm -f ${st1} ${st2} ${st2tr} ${st3} ${f}
108 if test ! -d ${lock_dir}
109 then : ; else ${echo} 'lock directory '${lock_dir}' exists'
113 then ${echo} 'x - created lock directory `'${lock_dir}\''.'
114 else ${echo} 'x - failed to create lock directory `'${lock_dir}\''.'
117 # ============= apli/arith.c ==============
118 if test ! -d 'apli'; then
121 then ${echo} 'x - created directory `apli'\''.'
122 else ${echo} 'x - failed to create directory `apli'\''.'
126 if test -f 'apli/arith.c' && test "$first_param" != -c; then
127 ${echo} 'x -SKIPPING apli/arith.c (file already exists)'
129 ${echo} 'x - extracting apli/arith.c (text)'
130 sed 's/^X//' << 'SHAR_EOF' > 'apli/arith.c' &&
132 5.1 Arithmetic functions
139 Lplus
() /* (+ 'num1 'num2
) */
141 X kerncell tos
= argstk
[argtop
];
142 X kerncell arg1
= ARGnum1
;
143 X kerncell arg2
= ARGnum2
;
145 X CHECKlargs
(plussym
, 2);
146 X
if (ISint
(arg1
) || ISreal
(arg1
) ) {
148 X
return(ISint
(arg1
) ? mkinum
(arg1-
>CELLinum
+ arg2-
>CELLinum
)
149 X
: mkrnum
(arg1-
>CELLrnum
+ arg2-
>CELLinum
) );
151 X
if (ISreal
(arg2
) )
152 X
return(ISint
(arg1
) ? mkrnum
(arg1-
>CELLinum
+ arg2-
>CELLrnum
)
153 X
: mkrnum
(arg1-
>CELLrnum
+ arg2-
>CELLrnum
) ) ;
157 X error
(plussym
, err_num
, arg1
);
161 Lminus
() /* (- 'num1 'num2
) */
163 X kerncell arg1
= ARGnum1
;
164 X kerncell arg2
= ARGnum2
;
166 X CHECKlargs
(minussym
, 2);
168 X
if (ISint
(arg1
) || ISreal
(arg1
) ) {
171 X
return (ISint
(arg1
) ? mkinum
(arg1-
>CELLinum
- arg2-
>CELLinum
)
172 X
: mkrnum
(arg1-
>CELLrnum
- arg2-
>CELLinum
) );
174 X
if (ISreal
(arg2
) )
175 X
return (ISint
(arg1
) ? mkrnum
(arg1-
>CELLinum
- arg2-
>CELLrnum
)
176 X
: mkrnum
(arg1-
>CELLrnum
- arg2-
>CELLrnum
) );
180 X error
(minussym
, err_num
, arg1
);
185 Ltimes
() /* (* 'num1 'num2
) */
187 X kerncell arg1
= ARGnum1
;
188 X kerncell arg2
= ARGnum2
;
190 X CHECKlargs
(timessym
, 2);
191 X
if (ISint
(arg1
= ARGnum1
) || ISreal
(arg1
) ) {
193 X
if (ISint
(arg2
= ARGnum2
))
194 X
return(ISint
(arg1
) ? mkinum
(arg1-
>CELLinum
* arg2-
>CELLinum
)
195 X
: mkrnum
(arg1-
>CELLrnum
* arg2-
>CELLinum
) );
198 X Arthmettc Stnngs and Symbols
202 X
if (ISreal
(arg2
) )
203 X
return(ISint
(arg1
) ? mkrnum
(arg1-
>CELLinum
* arg2-
>CELLrnum
)
204 X
: mkrnum
(arg1-
>CELLrnum
* arg2-
>CELLrnum
) ) ;
208 X error
(timessym
, err_num
, arg1
);
213 Ldiv
() /* (/ 'num1 'num2
) */
215 X kerncell arg1
= ARGnum1
;
216 X kerncell arg2
= ARGnum2
;
218 X CHECKlargs
(divsym
, 2);
220 X
if (ISint
(arg1
) || ISreal
(arg1
) ) {
222 X
return (ISint
(arg1
) ? mkinum
(arg1-
>CELLinum
/ arg2-
>CELLinum
)
223 X
: mkrnum
(arg1-
>CELLrnum
/ arg2-
>CELLrnum
) );
226 X
return (ISint
(arg1
) ? mkrnum
(arg1-
>CELLinum
/ arg2-
>CELLinum
)
227 X
: mkrnum
(arg1-
>CELLrnum
/ arg2-
>CELLrnum
) );
231 X error
(divsym
, err_num
, arg1
);
236 Vsum
() /* (sum 'num1 ... 'numb
) */
242 X register int idx
= ARGidx1
;
243 X register kerncell arg
;
245 X
while (idx
< argtop
) {
246 X
if (ISint
(arg
= argstk
[idx
++]))
247 X
sum += arg-
>CELLinum
;
248 X
else if (ISreal
(arg
) ) {
250 X
sum += arg-
>CELLrnum
;
253 X error
(sumsym
, err_num
, arg
);
255 X
return(has_real ? mkrnum
((real
) sum)
256 X
: mkinum
((int
) sum));
261 X
5.1 Arithmetic functions
265 Vprod
() /* (prod
'num1 ... 'numn
} */
271 X register int idx
= ARGidx1
;
272 X register kerncell arg
;
274 X
while (idx
< argtop
) {
276 X
if (ISint
(arg
= argstk
[idx
++] ) )
277 X prod
*= arg-
>CELLinum
;
278 X
else if (ISreal
(arg
) ) {
280 X prod
*= arg-
>CELLrnum
;
283 X error
(prodsym
, err_num
, arg
);
285 X
return (has_real ? mkrnum
((real
) prod
)
286 X
: mkinum
( (int
) prod
) );
291 Lrem
() /* (% 'znum1 'znum2
) */
293 X kerncell arg1
= ARGnum1
;
294 X kerncell arg2
= ARGnum2
;
296 X CHECKlargs
(remsym
, 2);
297 X
return (mkinum
(GETint
(remsym
, arg1
) % GETint
(remsym
, arg2
) ) );
303 X Arithmetic
, Strings und Symbols
307 Lpow
() /* (^
'num1 'num2
) */
309 X kerncell arg1
= ARGnum1
;
310 X kerncell arg2
= ARGnum2
;
313 X CHECKlargs
(powsym
, 2);
315 X
return (mkrnum
( (real
) pow
( (double
) GETnum
(powsym
, arg1
),
317 X
(double
) GETnum
(powsym
, arg2
) ) ) );
322 Linc
() /* (++ 'inurn) */
324 X kerncell arg = ARGnum1;
326 X CHECKlargs (incsym, 1);
327 X return (mkinum(GETint (incsym, arg) + 1) );
332 Ldec () /* (-- 'inum
) */
334 X kerncell arg
= ARGnum1
;
336 X CHECKlargs
(decsym
, 1);
338 X
return(mkinum
(GETint
(decsym
, arg
) - 1) ) ;
343 Labs
() /* (abs
'num) */
346 X kerncell arg = ARGnum1;
348 X CHECKlargs (abssym, 1);
351 X return (arg->CELLinum >= 0 ? arg : mkinum(-arg->CELLinum) );
354 X return (arg->CELLrnum >= 0 ? arg: mkrnum(-arg->CELLrnum) );
356 X error (abssym, err_num, arg);
362 Lneg () /* (neg 'inurn
) */
364 X kerncell arg
= ARGnum1
;
365 X CHECKlargs
(negsym
, 1);
368 X
return (mkinum
(-arg->CELLinum
));
371 X
return (mkrnum
(-arg->CELLrnum
) );
373 X error
(negsym
, err_num
, arg
);
377 Lint
() /* (int
'num) */
379 X kerncell arg = ARGnum1;
382 X CHECKlargs (intsym, 1);
383 X return (mkinum( (int) floor(GETreal(intsym, arg) + 0.0) ) );
389 Lreal () /* (real 'inurn
) */
392 X kerncell arg
= ARGnum1
;
393 X CHECKlargs
(realsym
, 1);
395 X
return(mkrnum
((real
) (GETint
(realsym
,arg
) + 0.0)));
399 La_lt
() /* (< 'num1 'num2
) */
402 X kerncell arg1
= ARGnum1
;
403 X kerncell arg2
= ARGnum2
;
405 X CHECKlargs
(a_ltsym
, 2);
406 X
return(GETnum
(a_ltsym
,arg1
) < GETnum
(a_ltsym
,arg2
) ? TTT
: NIL
);
411 La_gt
() /* (> 'num1 'num2
) */
413 X kerncell arg1
= ARGnum1
;
414 X kerncell arg2
= ARGnum2
;
416 X CHECKlargs
(a_gtsym
,2);
418 X
return(GETnum
(a_gtsym
, arg1
) > GETnum
(a_gtsym
, arg2
) ? TTT
: NIL
);
422 X
5.1 Arithmetic functions
426 La_le
() /* (< 'num1 'num2
) */
428 X kerncell arg1
= ARGnum1
;
429 X kerncell arg2
= ARGnum2
;
431 X CHECKlargs
(a_lesym
, 2);
432 X
return(GETnum
(a_lesym
, arg1
) <= GETnum
(a_lesym
, arg2
) ? TTT
: NIL
);
438 La_ge
() /* (>= 'num1 'num2
) */
440 X kerncell arg1
= ARGnum1
;
441 X kerncell arg2
= ARGnum2
;
443 X CHECKlargs
(a_gesym
, 2);
445 X
return(GETnum
(a_gesym
, arg1
) >= GETnum
(a_gesym
, arg2
) ? TTT
: NIL
);
450 La_eq
() /* (= 'num1 'num2
) */
452 X kerncell arg1
= ARGnum1
;
453 X kerncell arg2
= ARGnum2
;
455 X CHECKlargs
(a_eqsym
, 2);
456 X
return (GETnum
(a_eqsym
, arg1
) == GETnum
(a_eqsym
,arg2
) ? TTT
: NIL
);
462 La_ne
() /* (/= 'num1 'num2
) */
464 X kerncell arg1
= ARGnum1
;
465 X kerncell arg2
= ARGnum2
;
467 X CHECKlargs
(a_nesym
, 2);
469 X
return(GETnum
(a_nesym
,arg1
) != GETnum
(a_nesym
,arg2
) ? TTT
: NIL
);
474 Lnumberp
() /* (number?
'expr) */
476 X kerncell arg = ARGnum1;
478 X CHECKlargs( numberpsym, 1);
480 X return(ISint(arg) || ISreal(arg) ? TTT: NIL) ;
484 X Arithmetic, Strings and Symbols
489 Lintp () /* (int? 'expr) */
491 X CHECKlargs
(intpsym
, 1);
492 X
return(ISint
(ARGnum1
) ? TTT
: NIL
);
499 Lrealp () /* (real? 'expr) */
501 X CHECKlargs
(realpsym
, 1);
502 X
return(ISreal
(ARGnum1
) ? TTT
: NIL
);
507 (set 20 10 09 19 22 18 43 'apli/arith.c'; eval "$shar_touch") &&
508 chmod 0644 'apli/arith.c'
510 then ${echo} 'restore of apli/arith.c failed'
514 ${MD5SUM} -c >/dev
/null
2>&1 ||
${echo} 'apli/arith.c: MD5 check failed'
516 9197b8cca2085574a60fea8f7d8db733 apli/arith.c
519 test `LC_ALL=C wc -c < 'apli/arith.c'` -ne 6656 && \
520 ${echo} 'restoration warning: size of apli/arith.c is not 6656'
523 # ============= apli/cellt.c ==============
524 if test ! -d 'apli'; then
527 then ${echo} 'x - created directory `apli'\''.'
528 else ${echo} 'x - failed to create directory `apli'\''.'
532 if test -f 'apli/cellt.c' && test "$first_param" != -c; then
533 ${echo} 'x -SKIPPING apli/cellt.c (file already exists)'
535 ${echo} 'x - extracting apli/cellt.c (text)'
536 sed 's/^X//' << 'SHAR_EOF' > 'apli/cellt.c' &&
540 extern kerncell _tempstr
;
541 extern kernsym symtab
[];
542 kerncell celltab
[CELLTABSIZE
]; /* cell table
*/
543 int celltabsize
= CELLTABSIZE
; /* cell table size
*/
544 int celltabidx
= 0; /* current index to cell table
*/
545 int blockidx
; /* index to a cell
in current block
*/
546 int phase1
= 1; /* block allocation phase
*/
547 kerncell blockptr
; /* block pointer
*/
548 kerncell inumblock
; /* small inum block
*/
549 kerncell freelist
= NULL
; /* used only after garbage collection
*/
550 kerncell collectgarb
();
553 new
(size
) /* allocates
'size' bytes
*/
556 X char
*res
; /* *malloc
(); */
558 X
if ((res
= malloc
(size
) ) == NULL
) {
559 X phase1
= 0; /* terminate block allocation phase
*/
560 X celltabsize
= celltabidx
; /* freeze celltab
's growth */
562 X if ((res = (char *)malloc(size)) == NULL ) /* try again */
563 X faterr (err_memory);
572 initcelltab () /* initialize the cell table */
574 X int range = SMALLINTHIGH - SMALLINTLOW;
575 X register int blkidx;
576 X register kerncell blkptr;
578 X if (range >= BLOCKSIZE)
579 X faterr("BLOCKSIZE is too small" );
581 X if ( (celltab [celltabidx] = blkptr = inumblock =
582 X (kerncell) malloc (sizeof (struct cell) * BLOCKSIZE) ) == NULL)
583 X faterr (err_memory);
585 X for (blkidx=0; blkidx < range; ++blkidx) { /* small inums */
586 X blkptr->flag = INTOBJ;
587 X (blkptr++)->CELLinum = SMALLINTLOW + blkidx;
591 X blockptr = blkptr + 1;
597 freshcell () /* returns a fresh cons-cell */
599 X static kerncell freecell;
600 X if (phase1) { /* in this phase storage is still available */
601 X if (blockidx++ < BLOCKSIZE) { /* get it fran current block */
602 X blockptr->CELLcdr = NIL;
603 X return (CELLpush(blockptr++) );
605 X if (++celltabidx < celltabsize) { /* create a new block */
606 X if ((celltab[celltabidx] = blockptr = (kerncell)
607 X malloc(sizeof(struct cell) * BLOCKSIZE)) == NULL) {
608 X celltabsize = celltabidx;
609 X goto phase2; /* run out of storage > phase2 */
612 X blockptr->CELLcdr = NIL;
613 X return (CELLpush (blockptr++));
615 phase2: /* in this phase storage is exhausted */
618 X if (freelist == NULL)
619 X if (collectgarb() == NULL) /* try garbage collecting */
620 X faterr ("cons-cell storage exhausted");
621 X freecell = freelist;
622 X freelist = freelist->CELLcdr;
623 X freecell->CELLcdr = NIL;
624 X return (CELLpush ( freecell) );
628 /* p24 Storage Management */
630 /* collect garbage */
634 X register int i, cidx;
635 X register kernsym entry;
636 X register kerncell blockptr;
639 X for (i<0; i < HASHTABSIZE; ++i) {
640 X entry = symtab [i];
641 X while (entry) { /* mark every symbol's refs.
*/
642 X
if (ISnotbinary
(entry
) )
643 X mark
(entry-
>bind); /* mark bindings
*/
644 X mark
(entry-
>prop
); /* mark property lists
*/
645 X entry
= entry-
>link
;
649 X
for (i
=0; i
<= vartop
; ++i
) /* mark bindings of vars on var stack
*/
650 X mark
(varstk
[i
] .
bind);
651 X
for (i
=0; i
<= argtop
; ++i
) { /* mark args on arg stack
*/
652 X
if (CONVint
(argstk
[i
]) > ARGSTKSIZE
) /* ignore indices
*/
653 X mark
(argstk
[i
] );
655 X
for (i
=celltop
; i
< EVALSTKSIZE
; ++i
) /* mark cells on cell stack
*/
656 X mark
(evalstk
[i
] );
659 X blockptr
= celltab
[0];
660 X
for (i
=0; i
< BLOCKSIZE
; ++i
) /* unmark small integers
*/
661 X
(blockptr
++) ->flag
&= MASK7
;
662 X
for (cidx
=1; cidx
< celltabsize
; ++cidx
) { /* sweep
*/
663 X blockptr
= celltab
[cidx
];
664 X
for (i
=0; i
< BLOCKSIZE
; ++i
) {
665 X
if (ISmarked
(blockptr
)) /* cell
in use?
*/
666 X
(blockptr
++)->flag
&= MASK7
; /* unmark it
*/
667 X
else { /* cell not
in use
*/
668 X blockptr-
>CELLcdr
= freelist
; /* free it
*/
669 X freelist
= blockptr
;
670 X switch
(blockptr-
>flag
) {
671 X
case STROBJ
: free
(blockptr-
>CELLstr
);
673 X
case CHANOBJ
: closechan
(blockptr-
>CELLchan
);
675 X
case VECTOROBJ
: free
(blockptr-
>CELLvec
);
689 mark
(obj
) /* mark cells that are
in use
*/
690 X register kerncell obj
;
697 X
) /* symbols need no marking
*/
699 X switch
(obj-
>flag
) {
701 X
{ register int dim
= obj-
>CELLdim-
>CELLinum
;
702 X register kerncell
*vec
= obj-
>CELLvec
;
703 X obj-
>flag
!= MARK
; /* mark vector
*/
704 X obj-
>CELLdim-
>flag
!= MARK
; /* mark vector dimension
*/
705 X
while (dim--
) mark
(*vec
++); /* mark vector elements
*/
708 X
case LISTOBJ
: /* sets are treated as lists
*/
710 X
while (ISlist
(obj
)) {
711 X obj-
>flag
!= MARK
; /* mark this cell
*/
712 X mark
(obj-
>CELLcar
); /* mark list element
*/
713 X obj
= obj-
>CELLcdr
;
715 X
if (obj
!= NIL
) /* dotted pair
'? */
718 X default: /* mark elementary object */
728 X /* make an integer object */
730 X if (inum >= SMALLINTLOW && inum < SMALLINTHIGH)
731 X return (inumblock + inum - SMALLINTLOW);
733 X obj->flag = INTOBJ;
734 X obj->CELLinum = inum;
745 X /* make a real object */
746 X kerncell obj = freshcell ();
747 X obj->flag = REALOBJ;
748 X obj->CELLrnum = rnum;
753 mkstr (str) /* make a string object */
756 X kerncell obj = freshcell();
758 X int len = strlen(str);
759 X newstr = new(len + 1);
760 X strcpy (newstr, str );
761 X *(newstr + len) = 0;
762 X obj->flag = STROBJ;
763 X obj->CELLstr = newstr;
771 X /* make a temporary string object */
772 X _tempstr->CELLstr = str;
773 X return ( _tempstr);
779 mkchan (chan) /* make a channel object */
783 X kerncell obj = freshcell ();
784 X obj->flag = CHANOBJ;
785 X obj->CELLchan = chan;
790 mkcell (head, tail) /* make a new cons-cell */
791 X kerncell head, tail;
794 X kerncell obj = freshcell();
795 X obj->flag = LISTOBJ;
796 X obj->CELLcar = head;
797 X obj->CELLcdr = tail;
802 mkset (head, tail) /* make a new cons-cell */
803 X kerncell head, tail;
806 X kerncell obj = freshcell();
807 X obj->flag = SETOBJ;
808 X obj->CELLcar = head;
809 X obj->CELLcdr = tail;
813 (set 20 10 09 19 22 18 43 'apli
/cellt.c
'; eval "$shar_touch") &&
814 chmod 0644 'apli
/cellt.c
'
816 then ${echo} 'restore of apli
/cellt.c failed
'
820 ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'apli
/cellt.c
: MD5 check failed
'
822 35ae0743768222234ecff982b5263c99 apli/cellt.c
825 test `LC_ALL=C wc -c < 'apli
/cellt.c
'` -ne 6494 && \
826 ${echo} 'restoration warning
: size of apli
/cellt.c is not
6494'
829 # ============= apli/eval.c ==============
830 if test -f 'apli
/eval.c
' && test "$first_param" != -c; then
831 ${echo} 'x
-SKIPPING apli
/eval.c
(file already exists
)'
833 ${echo} 'x
- extracting apli
/eval.c
(text
)'
834 sed 's
/^X
//' << 'SHAR_EOF
' > 'apli
/eval.c
' &&
839 extern kernsym evalsym;
840 extern error( kerncell, char*, kerncell);
841 kerncell evalcall (kerncell, kerncell, int );
842 kerncell evallam (kerncell, kerncell, int );
845 eval (expr) /* evaluate expr */
851 X if ( ISconst(expr) || ISvar(expr) || ISinternal (expr) )
852 X return (CONVsym(expr)->bind);
854 X error( evalsym, "unbound symbol", EVALpush(expr));
856 X else if (ISlist(expr) )
858 X { int save_celltop = celltop; /* save top of cell stack */
860 X kerncell save = evalcall (expr->CELLcar, EVALpush(expr), 0);
862 X celltop = save_celltop; /* restore top of cell stack */
866 X return (expr); /* any other object evaluates to itself */
872 evalcall (head, list, stacked) /* evaluate a function call */
873 X register kerncell head, list;
874 X int stacked; /* non-zero when args are already stacked */
877 X kerncell (* fun) ();
882 X if (ISlist(head)) { /* ((...) arg1 ... argn) */
884 X if ( (fox = head->CELLcar) == CONVcell(lamsym) )
885 X return (evallam(head, list->CELLcdr, stacked) );
887 X if (fox == CONVcell(vlamsym) )
888 X return (evalvlam(head, list->CELLcdr, stacked) );
890 X if (fox == CONVcell(ulamsym) )
891 X return (expand (head, list, stacked) );
893 X if (fox == CONVcell(mlamsym) )
894 X return (eval(expand (head, list, stacked) ) );
896 X head = evalcall (head->CELLcar, head, 0);
899 X if (ISsym(head) ) { /* (head arg1 ... argn) */
901 X if (head == CONVcell (quotesym) ) /* < expr */
902 X return (list->CELLcdr->CELLcar);
904 X switch (head->flag) { /* what, kind of symbol is head? */
906 X head = CONVsym(head) ->bind; /* function binding */
913 X list = list->CELLcdr;
914 X while (ISlist(list)) {
915 X fox = eval(list->CELLcar); /* evaluate args */
916 X ARGpush(fox); /* push args onto arg stack */
917 X list = list->CELLcdr;
919 X ARGpush(CONVcell(arg1) ); /* push position of 1st arg */
921 X fox = ((fun = CONVsym(head) ->bind) != CONVcell(Lcxxr)
923 X : (* fun) (CONVsym(head) ->name));
930 X fox = (stacked ? mkargslist () : list->CELLcdr);
932 X fun = CONVsym(head) ->bind;
938 X fox = (stacked ? mkargslist () : list->CELLcdr);
940 X fun = CONVsym(head) ->bind;
943 X return(eval(stacked
944 X ? fox /* substitute the result */
946 X ? (list->CELLcar = fox->CELLcar,
947 X list->CELLcdr = fox->CELLcdr, list)
948 X :(list->CELLcar = CONVcell(voidsym),
949 X list->CELLcdr = mkcell (fox, nil)))));
953 X if (ISvector(fox = head) || /* indexed vector? */
954 X ISvar (fox) && ISvector (fox = CONVsym(fox)->bind) )
956 X return (evalvector (fox, list->CELLcdr, stacked));
958 X error(evalsym, "undefined function", head);
965 evallam (lam, args, stacked) /* evaluate a lam application */
966 X register kerncell lam, args;
967 X int stacked; /* non-zero when args are already stacked */
970 X kerncell obj, vars;
971 X register kerncell vs;
973 X lam = lam->CELLcdr; /* drop lam head */
975 X if ((vars = lam->CELLcar) != NIL && ! ISlist(vars) )
977 X error (evalsym, err_pars,vars);
979 X nvars = checkvars (vars); /* check that vars are all symbols */
985 X while (ISlist (args) ) {
986 X obj = eval (args->CELLcar); /* evaluate each argument and */
987 X ARGpush(obj); /* push it onto arg stack */
988 X args = args->CELLcdr;
991 X ARGpush (CONVcell (arg1) ); /* push position of 1st arg */
996 X CHECKlargs(lamsym, nvars); /* check number of args */
997 X savevars(vars); /* save current binding of vars */
998 X for (vs=vars; ISlist(vs); vs=vs->CELLcdr) /* bind the vars to args */
1000 X CONVsym(vs->CELLcar)->bind = argstk[arg1++];
1002 X lam = lam->CELLcdr;
1004 X while (ISlist(lam) ) {
1006 X obj= eval (lam->CELLcar); /* eval each form in lam body */
1007 X lam = lam->CELLcdr;
1010 X restorevars (vars); /* restore the binding of vars */
1013 X ARGSpop(); /* pop argutents */
1014 X return(obj); /* return the value of last form */
1019 evalvlam (vlam, args, stacked) /* evaluate a vlam application */
1020 X register kerncell vlam, args;
1021 X int stacked; /* non-zero when args are already stacked */
1024 X int arg1, save_argtop = argtop; /* for nested vlam calls */
1025 X kerncell obj, vars;
1027 X vlam = vlam->CELLcdr; /* drop vlam head */
1029 X if (! ISlist(vars = vlam->CELLcar) || checkvars(vars) != 1)
1030 X error (evalsym, err_pars, vars);
1034 X while (ISlist (args) ) {
1035 X obj = eval (args->CELLcar); /* evaluate each argument and */
1036 X ARGpush (obj); /* push it onto arg stack */
1037 X args = args->CELLcdr;
1041 X ARGpush (CONVcell (arg1) );
1046 X _argtop = argtop; /* save argtop - for use by 'arg
' function: */
1047 X savevars (vars); /* save current. binding of var */
1048 X /* var is set t,o the number of arguments: */
1050 X CONVsym(vars->CELLcar)->bind = mkinum(argtop - arg1);
1053 X vlam = vlam->CELLcdr;
1055 X while (ISlist(vlam)) {
1056 X obj = eval(vlam->CELLcar); /* eval each form in vlam body */
1057 X vlam = vlam->CELLcdr;
1059 X restorevars(vars); /* restore argtop */
1060 X _argtop = save_argtop; /* restore the binding of var */
1063 X ARGSpop (); /* pop arguments */
1065 X return (obj); /* retrunr the value of last form */
1070 X 3.2 Internal evaluation functions
1075 expand (fun, list, stacked) /* expand ulam/mlam application */
1076 X register kerncell fun;
1080 X kerncell fox, vars;
1082 X int ismacro = fun->CELLcar == CONVcell(mlamsym);
1084 X fun = fun->CELLcdr; /* drop ulam/mQam */
1086 X if ( !ISlist(vars = fun->CELLcar) || checkvars (vars) != 1)
1087 X error (evalsym, err_pars , vars);
1089 X /* the list of arguments is treated as 1 arg: */
1090 X fox = (stacked ? mkargslist (): list->CELLcdr);
1095 X CONVsym(vars->CELLcar) ->bind = argstk [argtop];
1099 X fun = fun->CELLcdr;
1101 X while (ISlist (fun) ) { /* evaluate body */
1103 X fox = eval (fun->CELLcar);
1105 X fun = fun->CELLcdr;
1108 X restorevars (vars);
1111 X return(ismacro && !stacked
1112 X ? (ISlist (fox) /* substitute the result */
1113 X ? (list->CELLcar = fox->CELLcar,
1114 X list->CELLcdr = fox->CELLcdr, list)
1115 X : (list->CELLcar = CONVcell (voidsym),
1116 X list->CELLcdr = mkcell(fox,nil), list))
1122 evalvector (head, tail, stacked) /* vector application */
1123 X kerncell head, tail;
1124 X int stacked; /* non-zero when args are already stacked */
1129 X if (stacked ? (argtop - ARGidx1 != 1 || !ISint(index = ARGnum1))
1130 X :(tail == NIL ) || tail->CELLcdr != nil
1131 X || !ISint (index = eval (tail->CELLcar)))
1133 X error (evalsym, "bad vector index", index);
1135 X if (index->CELLinum < 0 ||
1136 X index->CELLinum >= head->CELLdim->CELLinum)
1137 X error (evalsym, "vector index out of range", index);
1142 X return (* (head->CELLvec + index->CELLinum) );
1146 checkvars (vars) /* check that elements of vars are all symbols */
1147 X register kerncell vars; /* returns the length of the vars list */
1151 X while (ISlist (vars) ) {
1154 X if (!ISsym(vars->CELLcar) || ISconst(vars->CELLcar))
1156 X error (evalsym, err_pars, vars->CELLcar );
1158 X vars = vars->CELLcdr;
1163 savevars (vars) /* save the bindings of vars in varstk */
1164 X register kerncell vars;
1167 X register kernsym var;
1169 X while (ISlist (vars) ) {
1171 X var = CONVsym(vars->CELLcar);
1173 X /* NOTE: property lists are not stacked: */
1175 X VARpush(var, var->flag, var->bind);
1177 X var->flag = VARIABLE;
1179 X vars = vars->CELLcdr;
1183 restorevars (vars) /* restore the binding of variables */
1184 X register kerncell vars;
1187 X while (ISlist(vars) ) {
1190 X vars = vars->CELLcdr;
1198 mkargslist () /* make an argument list using the entries on argstk */
1201 X register int argi = ARGidx1;
1202 X register kerncell arglist = NIL, list;
1204 X while (argi < argtop)
1205 X if (arglist == NIL)
1206 X arglist = list = mkcell(argstk[argi++],nil);
1208 X list = list->CELLcdr = mkcell(argstk[argi++],nil);
1215 Leval () /* (eval 'expr) */
1218 X CHECKlargs
(evalsym
, 1);
1219 X
return (eval(ARGnum1
)) ;
1226 Vcall
() /* (call
'fun 'argl ...
'argn) */
1231 X CHECKvargs1 (callsym, 1);
1233 X fox = ARGnum1; /* the function to be called */
1235 X argstk[argtop] = CONVcell(CONVint(argstk[argtop]) + 1);
1237 X fox = evalcall(fox,nil,1); /* do the call */
1239 X argstk [argtop] = CONVcell (CONVint (argstk [argtop] ) - 1);
1246 Lapply () /* (apply 'fun
'arglist) */
1249 X kerncell arg1 = ARGnum1;
1251 X register kerncell arg2 = ARGnum2;
1252 X kerncell fox = CONVcell (argtop + 1);
1254 X CHECKlargs (applysym, 2);
1255 X CHECKlist (applysym, arg2);
1257 X while (ISlist (arg2) ) { /* stack the arguments */
1259 X ARGpush(arg2->CELLcar);
1261 X arg2 = arg2->CELLcdr;
1265 X fox = evalcall(arg1, nil, 1);
1272 (set 20 10 09 19 22 18 43 'apli
/eval.c
'; eval "$shar_touch") &&
1273 chmod 0644 'apli
/eval.c
'
1275 then ${echo} 'restore of apli
/eval.c failed
'
1279 ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'apli
/eval.c
: MD5 check failed
'
1281 5b97d37d7998cf9151cf5750dd48dee8 apli/eval.c
1284 test `LC_ALL=C wc -c < 'apli
/eval.c
'` -ne 9497 && \
1285 ${echo} 'restoration warning
: size of apli
/eval.c is not
9497'
1288 # ============= apli/flow.c ==============
1289 if test -f 'apli
/flow.c
' && test "$first_param" != -c; then
1290 ${echo} 'x
-SKIPPING apli
/flow.c
(file already exists
)'
1292 ${echo} 'x
- extracting apli
/flow.c
(text
)'
1293 sed 's
/^X
//' << 'SHAR_EOF
' > 'apli
/flow.c
' &&
1294 /* 118 ItIonstandard Flow of Control and Iteratton */
1301 X if (++cattop < CATSTKSIZE) { \
1302 X catstk[cattop].evaltop = evaltop; \
1303 X catstk[cattop].celltop = celltop; \
1304 X catstk[cattop].vartop = vartop; \
1305 X catstk[cattop].argtop = argtop; \
1306 X catstk[cattop]._argtop = _argtop; \
1307 X } else faterr(err_catstk) ;
1309 #define CATpop() --cattop
1311 struct catframe { /* catch frame */
1312 X jmp_buf jmp; /* for setjmp and longjmp */
1313 X int evaltop; /* evaltop at the tirade of setjmp */
1314 X int celltop; /* celltop at the tine of setjmp */
1315 X int vartop; /* vartop at the timbre of setjmp */
1316 X int argtop; /* argtop at the tim of setjmp */
1317 X int _argtop; /* argtop of the last vlam */
1320 struct catframe catstk[CATSTKSIZE]; /* the catch stack */
1321 int cattop = -1; /* top of jump stack */
1322 int errtrap = 0; /* no error capture when zero */
1323 int errshow = 1; /* errors are reported when -non-zero */
1324 int errocc = 0; /* set when an error occurs */
1325 int level = 0; /* kernel level */
1328 Ucatch () /* (catch 'expr ['tag]) */
1330 X kerncell list = argstk [argtop];
1332 X if (list == NIL || list->CELLcdr != NIL)
1333 X error (catchsym, err_args,0);
1335 X return(catch (list->CELLcar, eval(list->CELLcdr->CELLcar),NULL));
1339 /* 119 9.1 Nonstandard flo~ of control
1342 catch (expr, tag, more) /* catch throws during evaluation */
1343 X kerncell expr, tag;
1349 X /* get ready for throws: */
1350 X int res = setjmp(catstk[cattop].jmp);
1352 X if ( !CONVcell( res )) {
1355 X kerncell (* cfun) () = expr;
1356 X expr = (* cfun) (); /* cfun may have throws */
1358 X expr = (* cfun) (more); /* cfun may have throws */
1361 X expr = eval(expr); /* expr may contain throws */
1364 X else if (tag == NIL
1365 X && !ISinternal(CONVsym(catres->CELLcar))
1366 X || catres->CELLcar == NIL
1367 X && !ISinternal(tag)
1369 X || catres->CELLcar == tag
1371 X && memq(catres->CELLcar, tag)) {
1376 X CATpop (); /* catch the throw and */
1378 X return (catres->CELLcdr); /* return its result */
1381 X else if (cattop < 1) /* one catch is reserved for top level */
1382 X error(catchsym,"no catch for this tag",catres->CELLcar);
1386 X longjmp (catstk [CATpop () ] . jmp, catres); /* try another catch */
1389 X CATpop(); /* there was no throw, so ignore the catch */
1394 /* 120 Nonstandard Flow of Control and IteraMn */
1395 cleanup () /* clean up stacks after a throw */
1397 X register int vtop = catstk[cattop].vartop;
1399 X while (vtop < vartop) /* restore non-global vars */
1402 X evaltop = catstk[cattop].evaltop; /* restore eval stack */
1403 X celltop = catstk[cattop].celltop; /* restore eval stack */
1404 X argtop = catstk[cattop].argtop; /* restore arg stack */
1405 X _argtop = catstk[cattop]._argtop; /* restore _argtop */
1410 Vthrow () /* (throw 'obj
['tag]) */
1412 X CHECKvargs (throwsym, 1,2);
1414 X return(throw(ARGnum1, (argtop - ARGidx1 == 1 ? NIL: ARGnum2) ) ) ;
1420 throw (expr,tag) /* evaluate and throw expr, plus its tag */
1421 X kerncell expr, tag;
1424 X catres->CELLcar = tag;
1425 X catres->CELLcdr = expr;
1426 X longjmp(catstk[cattop].jmp, catres);
1431 /* 121 kl Nonstandard flow of control */
1434 Ucaperr() /* (caperr 'expr [hide
]) */
1436 X kerncell list
= argstk
[argtop
];
1438 X
if (list
== NIL || list-
>CELLcdr-
>CELLcdr
!= NIL
)
1439 X error
(caperrsym
, err_args
, 0);
1441 X
return (caperr
(list-
>CELLcar
, list-
>CELLcdr-
>CELLcar
, NULL
) );
1446 caperr
(expr, hide
,more) /* captures errors during evaluation of
expr */
1447 X kerncell
expr, hide
; /* when hide is non-nil error messages are hidden
*/
1451 X int savetrap
= errtrap
; /* save the values of errtrap
, */
1452 X int saveshow
= errshow
; /* errshow
, and
*/
1453 X int saveocc
= errocc
; /* errocc
*/
1456 X errtrap
= 1; /* came here when error occurs
*/
1458 X errshow
= eval(hide
) == NIL
; /* activate
/hide error messages
*/
1460 X errocc
= 0; /* pretend there were no previous errors
*/
1462 X res
= catch
(expr, _errtagsym
,more); /* evaluate r
*/
1464 X res
= (errocc ? NIL
: mkcell
(res
,NIL
)); /* result depends on error
*/
1466 X errtrap
= savetrap
; /* restore the things we changed
*/
1468 X errshow
= saveshow
;
1476 /* 122 Nonstandard Flo~ of Control and Iteration
*/
1478 Verror
() /* (error
'source 'message
['extra]) */
1482 X printf("start of Verror\n");
1483 X CHECKvargs (errorsym, 2, 3);
1484 X printf("check vargs\n");
1488 X error (ARGnum1, GETstr (errorsym, arg2),
1489 X (argtop == ARGidx1 == 2 ? 0 : ARGnum3)) ;
1495 error (source, message, extra) /* error handling routine */
1500 X errocc = 1 ; /* set error flag */
1502 X /* 123 9.l Nonstandard flow of control */
1503 X if (errshow) { /* error to be shown? */
1504 X bufprint(PRINT, _outchan, "ERROR, ");
1505 // bufprint(PRINT, _errchan,"ERROR, ");
1507 X if (source != 0) {
1509 X PRINTchan (source, errchan);
1510 X bufprint (PRINT, _errchan, ": ");
1513 X bufprint (PRINT, _errchan, "%s", message);
1517 X bufprint (PRINT, _errchan,": ", 0);
1519 X PRINTchan (extra, errchan);
1521 X bufprint (PRINT, _errchan, "\n", 0) ;
1523 X if (errtrap) /* error to be trapped? */
1525 X throw (NIL, _errtagsym); /* throw this to the catch of capexx */
1528 X EVALpush (CONVcell (errorsym) );
1530 X errlevel (); /* enter error level */
1533 errlevel () /* error level's read-eval-print
*/
1537 X
++level
; /* increment the level
*/
1539 X
for (;;) { /* read-eval-print
*/
1541 X bufprint
(PRINT
, _outchan
, "=%1d=> ",level
); /* prompt
*/
1543 X obj
= catch
(read_and_eval
, _errtagsym
, NULL
);
1545 X
if (obj
== CONVcell
(eofsym
) ) { /* quit this level?
*/
1548 X throw
(NIL
, _errtagsym
); /* go to previous level
*/
1552 X bufprint
(PRINT
,_outchan
, "\n", 0);
1556 faterr
(message
) /* fatal error handling
*/
1559 X
printf ("FATAL ERROR: %s\n", message
);
1566 /* 125 9.2 E~li cit iteratioa
function */
1569 topexec
() /* kernel executive
*/
1571 X bufprint
(PRINT
, _outchan
, "KERNEL V1, Aug 87\n");
1574 X errtrap
= errocc
= 0;
1578 X level
= 0; /* top level
: level is zero
*/
1581 X catch
(top_lev_call
, top_lev_tags
, NULL
);
1583 X bufprint
(PRINT
, _outchan
,"\n[KERNEL, top level]\n");
1588 Ltoplevel
() /* (toplevel
} */
1592 X CHECKlargs
(toplevelsym
, 0);
1594 X
for (;;) { /* read-eval-print loop
*/
1596 X bufprint
(PRINT
, _outchan
, "=> ") ;
1599 X
if ( (obj
= eval (read_and_eval
) ) == CONVcell
(eofsym
) ) {
1600 X bufprint
(PRINT
, _outchan
, "\n");
1606 X bufprint
(PRINT
,_outchan
, "\n");
1613 Lreset
() /* (reset) */
1615 X CHECKlargs
(resetsym
, 0);
1616 X throw
(NIL
, _toptagsym
);
1621 Vexit
() /* (exit ['code]) */
1625 X int idx1 = ARGidx1;
1628 X CHECKvargs2 (exitsym, 1);
1629 X if (argtop == idx1 + 1) {
1633 X exitcode = GETint(exitsym, arg);
1641 (set 20 10 09 19 22 18 43 'apli
/flow.c
'; eval "$shar_touch") &&
1642 chmod 0644 'apli
/flow.c
'
1644 then ${echo} 'restore of apli
/flow.c failed
'
1648 ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'apli
/flow.c
: MD5 check failed
'
1650 ac1362c7e755a6cfe38820bb142d8de0 apli/flow.c
1653 test `LC_ALL=C wc -c < 'apli
/flow.c
'` -ne 7383 && \
1654 ${echo} 'restoration warning
: size of apli
/flow.c is not
7383'
1657 # ============= apli/globals.c ==============
1658 if test -f 'apli
/globals.c
' && test "$first_param" != -c; then
1659 ${echo} 'x
-SKIPPING apli
/globals.c
(file already exists
)'
1661 ${echo} 'x
- extracting apli
/globals.c
(text
)'
1662 sed 's
/^X
//' << 'SHAR_EOF
' > 'apli
/globals.c
' &&
1665 char *err_args = "incorrect number of arguments";
1666 char *err_pars = "bad parameter(s)";
1667 char *err_evalstk = "evaluation stack overflow";
1668 char *err_varstk = "variable stack overflow";
1669 char *err_argstk = "arguxrent stack overflow" ;
1670 char *err_catstk = "catch stack overflow";
1671 char *err_memory = "memory space exhausted";
1672 char *err_int = "integer number expected" ;
1676 char *err_real = "real nurber expected";
1677 char *err_num = "number expected";
1678 char *err_str = "string expected";
1679 char *err_chan1 = "channel expected";;
1680 char *err_chan2 = "bad channel";
1681 char *err_sym1 = "symbol expected" ;
1682 char *err_sym2 = "non-constant syrrbol expected";
1683 char *err_pair = "non-nil list expected";
1684 char *err_list = "list expected";
1685 char *err_var = "bad variable";
1686 char *err_dom = "bad domain designator";
1688 kerncell catres; /* catch result pair */
1689 kerncell golabel; /* label specified by go in prog */
1691 kerncell read_and_eval, top_lev_call, top_lev_tags;
1692 kerncell inchan, outchan, errchan;
1693 iochan _inchan, _outchan, _errchan;
1694 char strbuf [STRBUFSIZE+2] ; /* string buffer */
1695 struct variable varstk[VARSTKSIZE+1] ; /* variable stack */
1696 kerncell evalstk [EVALSTKSIZE+1]; /* evaluation stack (also cell stack) */
1698 kerncell argstk[ARGSTKSIZE+1]; /* argument stack */
1699 int evaltop = -1; /* top of evaluation stack */
1700 int celltop = EVALSTKSIZE; /* top of cell stack */
1701 int vartop = -1; /* top of variable stack */
1702 int argtop = -1; /* top of argument stack */
1703 int _argtop = -1; /* argtop for the last vlam */
1704 int (* org_interrupt) () ; /* original interrupt handler */
1706 kernsym /* internals: */
1707 _bquotesym, _commasym, _atsym,
1708 _toptagsym, _errtagsym, _rettagsym, _gotagsym, _tempsym, _cxxrsym;
1710 kernsym /* constants: */
1711 nil, ttt, eofsym, inchansym, outchansym, errchansym;
1713 kernsym /* unbounds: */
1714 lamsym, vlamsym, ulamsym, mlamsym;
1716 kernsym /* eval.c: */
1717 evalsym, callsym, applysym;
1720 opensym, closesym, flushsym, readsym, printsym, princsym, tabsym,
1721 X terprisym, prlensym, iobufsym, chanpsym, ppsym;
1723 kernsym /* arith.c: */
1724 plussym, minussym, timessym, divsym, sumsym, prodsym, remsym,
1725 X powsym, incsym, decsym, abssym, negsym, intsym,realsym,
1726 X a_ltsym, a_gtsym, a_lesym,a_gesym, a_eqsym, a_nesym,
1727 X numberpsym, intpsym, realpsym;
1729 kernsym /* str.c: */
1730 s_ltsym, s_gtsym, s_eqsym, strcmpsym, nthcharsym, substrsym,
1731 X strlensym, strconcsym, nilstrpsym, stringpsym;
1733 kernsym /* sym.c: */
1734 symnamesym, synonymsym, gensymsym, concatsym, bindingsym,
1740 X symbolpsym, boundpsym;
1742 X kernsym /* list.c: */
1743 X carsym, cdrsym, nthelemsym, nthpairsym, rplacasym, rplacdsym,
1744 X lastelemsym, lastpairsym, conssym, listsym, lengthsym, concsym,
1745 X dconcsym, removesym, dremovesym, substsym, dsubstsym, reversesym,
1746 X dreversesym, membersym, memqsym, equalsym, nequalsym, eqsym, neqsym,
1747 X atompsym, listpsym, pairpsym, nullpsym;
1749 kernsym /* set.c: */
1750 convsetsym, dconvsetsym, convlistsym, dconvlistsym,
1751 X esetsym, isetsym, unionsym, intsecsym, diffsym, subsetsym;
1753 kernsym /* logic.c: */
1754 notsym, andsym, orsym, condsym, implysym, equivsym,
1755 X allsym, existsym, onesym;
1757 kernsym /* prop.c: */
1758 putpropsym, rempropsym, getsym, plistsym, setplistsym,
1759 X assocsym, assqsym;
1761 kernsym /* vec.c: */
1762 vectorsym, storesym, dimensionsym, vectorpsym;
1764 kernsym /* flow.c: */
1765 catchsym, throwsym, caperrsym, errorsym, toplevelsym,
1766 X resetsym, exitsym;
1768 kernsym /* iter.c: */
1769 progsym, gosym, returnsym, dosym;
1771 kernsym /* map.c: */
1772 mapcarsym, mapasym, mapcdrsym, mapdsym;
1774 kernsym /* misc.c: */
1775 voidsym, quotesym, kwotesym, defsym, funsym, argsym, letsym,
1776 X setsym, setqsym, constsym, sssym, loadsym, shellsym;
1779 (set 20 10 09 19 22 18 43 'apli
/globals.c
'; eval "$shar_touch") &&
1780 chmod 0644 'apli
/globals.c
'
1782 then ${echo} 'restore of apli
/globals.c failed
'
1786 ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'apli
/globals.c
: MD5 check failed
'
1788 1f5dd1b3cb2b752a411c792c50201df6 apli/globals.c
1791 test `LC_ALL=C wc -c < 'apli
/globals.c
'` -ne 3790 && \
1792 ${echo} 'restoration warning
: size of apli
/globals.c is not
3790'
1795 # ============= apli/init.c ==============
1796 if test -f 'apli
/init.c
' && test "$first_param" != -c; then
1797 ${echo} 'x
-SKIPPING apli
/init.c
(file already exists
)'
1799 ${echo} 'x
- extracting apli
/init.c
(text
)'
1800 sed 's
/^X
//' << 'SHAR_EOF
' > 'apli
/init.c
' &&
1811 X error(0, "interrupted - to exit type (exit)", 0);
1821 X catres = mkcell(nil, nil); /* catch result pair */
1825 X _bquotesym = CONVsym(&_bquotesym);
1826 X _commasym = CONVsym(&_commasym);
1827 X _atsym = CONVsym(&_atsym);
1829 X INTERNALsym(_toptagsym); _toptagsym->bind = CONVcell (_toptagsym);
1830 X INTERNALsym(_errtagsym); _errtagsym->bind = CONVcell (_errtagsym);
1831 X INTERNALsym(_rettagsym); _rettagsym->bind = CONVcell (_rettagsym);
1832 X INTERNALsym(_gotagsym); _gotagsym->bind = CONVcell (_gotagsym);
1833 X INTERNALsym(_tempsym); _tempsym->bind = CONVcell (_tempsym);
1834 X INTERNALsym(_cxxrsym); _cxxrsym->name = "c..r";
1836 X _tempstr = mkstr("");
1839 X nil = newsym("nil", CONSTANT,0); nil->bind = nil->prop = NIL;
1840 X ttt = newsym("t", CONSTANT,0); ttt->bind = TTT;
1841 X eofsym = newsym("eof", CONSTANT,0); eofsym->bind = CONVcell (eofsym);
1843 X inchansym = newsym("inchan", CONSTANT, inchan);
1844 X outchansym = newsym ("outchan", CONSTANT, outchan);
1845 X errchansym = newsym("errchan", CONSTANT, errchan);
1849 X initialization, Integration and Compilation
1852 X lamsym = newsym("1am", UNBOUND, nil);
1853 X vlamsym = newsym("vlam" , UNBOUND, nil);
1854 X ulamsym = newsym("ulam" , UNBOUND, nil) ;
1855 X mlamsym = newsym("mlam", UNBOUND, nil);
1858 X evalsym = newsym("eval", LBINARY, Leval);
1859 X callsym = newsym("call", VBINARY, Vcall);
1860 X applysym = newsym("apply", LBINARY, Lapply);
1863 X opensym = newsym("open", LBINARY, Lopen);
1864 X closesym = newsym("close", LBINARY, Lclose);
1865 X flushsym = newsym("flush", VBINARY, Vflush);
1866 X readsym = newsym("read", VBINARY, Vread);
1867 X printsym = newsym("print", VBINARY, Vprint);
1868 X princsym = newsym("princ", VBINARY, Vprinc);
1869 X tabsym = newsym("tab", VBINARY, Vtab);
1870 X terprisym = newsym("terpri", VBINARY, Vterpri);
1871 X prlensym = newsym("prlen", VBINARY, Vprlen);
1872 X iobufsym = newsym("iobuf", VBINARY, Viobuf);
1873 X chanpsym = newsym("chan?", LBINARY, Lchanp);
1874 X ppsym = newsym("pp", VBINARY, Vpp);
1877 X plussym = newsym("+", LBINARY,Lplus);
1878 X minussym = newsym("-", LBINARY,Lminus);
1879 X timessym = newsym("*", LBINARY, Ltimes);
1880 X divsym = newsym("/", LBINARY, Ldiv);
1881 X sumsym = newsym("sum", VBINARY,Vsum);
1882 X prodsym = newsym("prod",VBINARY, Vprod);
1883 X remsym = newsym("%", LBINARY, Lrem);
1884 X powsym = newsym("^", LBINARY, Lpow);
1885 X incsym = newsym("++", LBINARY, Linc);
1886 X decsym = newsym("--", LBINARY, Ldec);
1887 X abssym = newsym("abs", LBINARY, Labs);
1888 X negsym = newsym("neg", LBINARY, Lneg);
1889 X intsym = newsym("int", LBINARY, Lint);
1890 X realsym = newsym("real", LBINARY, Lreal);
1891 X a_ltsym = newsym("<", LBINARY,La_lt);
1892 X a_gtsym = newsym(">", LBINARY,La_gt);
1893 X a_lesym = newsym("<=", LBINARY,La_le);
1894 X a_lesym = newsym("> ", LBINARY,La_ge);
1895 X a_eqsym = newsym("=", LBINARY, La_eq);
1896 X a_nesym = newsym("/=", LBINARY, La_ne);
1897 X numberpsym = newsym("number?", LBINARY, Lnumberp);
1898 X intpsym = newsym("int?", LBINARY,Lintp);
1899 X realpsym = newsym("real?", LBINARY, Lrealp);
1902 X s_ltsym = newsym("<<", LBINARY, Ls_lt);
1903 X s_gtsym = newsym(">>", LBINARY, Ls_gt);
1904 X s_eqsym = newsym("==", LBINARY, Ls_eq);
1905 X strcmpsym = newsym("strcmp", LBINARY, Lstrcmp);
1906 X nthcharsym = newsym("nthchar", LBINARY, Lnthchar);
1907 X substrsym = newsym("substr", LBINARY, Lstrlen);
1908 X strlensym = newsym("strlen", LBINARY, Lstrlen);
1909 X strconcsym = newsym("strconc", LBINARY, Lstrconc);
1910 X nilstrpsym = newsym("nilstrp", LBINARY, Lnilstrp);
1911 X stringpsym = newsym("string?", LBINARY, Lstringp) ;
1916 X 11.1 Initialization
1919 X symnamesym = newsym("symname", LBINARY, Lsymname);
1920 X synonymsym = newsym("synonym", UBINARY, Usynonym);
1921 X gensymsym = newsym("gensym", LBINARY, Lgensym);
1922 X concatsym = newsym("concat", VBINARY, Vconcat);
1923 X bindingsym = newsym("binding", LBINARY, Lbinding);
1924 X symbolpsym = newsym("symbol?", LBINARY, Lsymbolp);
1925 X boundpsym = newsym("Mund?", LBINARY, Lboundp);
1928 X carsym = newsym("car", LBINARY,Lcar);
1929 X cdrsym = newsym("cdr", LBINARY, Lcdr);
1930 X nthelemsym = newsym("nthelem", LBINARY, Lnthelem);
1931 X nthpairsym = newsym("nthpair", LBINARY, Lnthpair);
1932 X rplacasym = newsym("rplaca", LBINARY, Lrplaca);
1933 X rplacdsym = newsym("rplacd", LBINARY,Lrplacd);
1934 X lastelemsym = newsym("lastelem", LBINARY, Llastelem);
1935 X lastpairsym = newsym("lastpair", LBINARY, Llastpair);
1936 X conssym = newsym("cons", LBINARY, Lcons);
1937 X listsym = newsym("list", VBINARY,Vlist);
1938 X lengthsym = newsym("length", LBINARY, Llength);
1939 X concsym = newsym("conc", VBINARY,Vconc);
1940 X dconcsym = newsym("*conc", VBINARY,Vdconc);
1941 X removesym = newsym("rerreve", LBINARY,Lremove);
1942 X dremovesym = newsym("*rermve", LBINARY,Ldremove);
1943 X substsym = newsym("subst", LBINARY,Lsubst);
1944 X dsubstsym = newsym("*subst", LBINARY,Ldsubst);
1945 X reversesym = newsym("reverse", LBINARY,Lreverse);
1946 X dreversesym = newsym("reverse", LBINARY,Ldreverse);
1947 X membersym = newsym("member", LBINARY, Lmember);
1948 X memqsym = newsym("memq", LBINARY, Lmemq);
1949 X equalsym = newsym("equal", LBINARY, Lequal);
1950 X nequalsym = newsym("nequal", LBINARY, Lnequal);
1951 X eqsym = newsym("eq", LBINARY, Leq);
1952 X neqsym = newsym("neq", LBINARY, Lneq);
1953 X atompsym = newsym("atom?", LBINARY, Latomp);
1954 X listpsym = newsym("list?", LBINARY, Llistp);
1955 X pairpsym = newsym("pair?", LBINARY, Lpairp);
1956 X nullpsym = newsym("null?", LBINARY, Lnullp);
1959 X convsetsym = newsym("convset", LBINARY, Lconvset);
1960 X dconvsetsym = newsym("*convset", LBINARY, Ldconvset);
1961 X convlistsym = newsym("convlist", LBINARY, Lconvlist);
1962 X dconvlistsym = newsym("*convlist", LBINARY, Ldconvlist);
1963 X esetsym = newsym("eset", VBINARY, Veset);
1964 X isetsym = newsym("iset", UBINARY,Uiset);
1965 X unionsym = newsym("union", VBINARY,Vunion);
1966 X intsecsym = newsym("intsec", VBINARY,Vintsec);
1967 X diffsym = newsym("diff", LBINARY,Ldiff);
1968 X subsetsym = newsym("subset", LBINARY, Lsubset);
1971 X notsym = newsym("not", LBINARY,Lnot);
1972 X andsym = newsym("and", UBINARY,Uand);
1973 X orsym = newsym("or", UBINARY,Uor);
1974 X condsym = newsym("cond", UBINARY,Ucond);
1975 X implysym = newsym("imply", UBINARY,Limply);
1976 X equivsym = newsym("equiv", UBINARY,Lequiv);
1977 X allsym = newsym("all", UBINARY,Uall);
1978 X existsym = newsym("exist", UBINARY,Uexist);
1982 X Initialization, Integration and Compilation
1984 X onesym = newsym("one", UBINARY, Uone);
1987 X putpropsym = newsym("putprop", LBINARY, Lputprop);
1988 X rempropsym = newsym("remprop", LBINARY, Lremprop);
1989 X getsym = newsym("get", LBINARY, Lget);
1990 X plistsym = newsym("plist", LBINARY, Lplist);
1991 X setplistsym = newsym("setplist", LBINARY, Lsetplist);
1992 X assocsym = newsym("assoc", LBINARY, Lassoc);
1993 X assqsym = newsym("assq", LBINARY,Lassq);
1996 X vectorsym = newsym("vector", LBINARY, Lvector);
1997 X storesym = newsym("store", UBINARY,Ustore);
1998 X dimensionsym = newsym("dimension",LBINARY,Ldimension);
1999 X vectorpsym = newsym("vector?", LBINARY,Lvectorp);
2002 X catchsym = newsym("catch", UBINARY,Ucatch);
2003 X throwsym = newsym("thrower", VBINARY,Vthrow);
2004 X caperrsym = newsym("caperr", UBINARY, Ucaperr);
2005 X errorsym = newsym("error", VBINARY, Verror);
2006 X toplevelsym= newsym("toplevel", LBINARY, Ltoplevel);
2007 X resetsym = newsym("reset", LBINARY, Lreset);
2008 X exitsym = newsym("exit", VBINARY,Vexit);
2011 X progsym = newsym("prog", UBINARY, Uprog);
2012 X gosym = newsym("go", UBINARY, Ugo);
2013 X returnsym = newsym("return", VBINARY,Vreturn);
2014 X dosym = newsym("do", UBINARY, Udo);
2017 X mapcarsym = newsym("mapcar", VBINARY,Vmapcar);
2018 X mapasym = newsym("mapa", VBINARY,Vmapa);
2019 X mapcdrsym = newsym("mapcdr", VBINARY,Vmapcdr);
2020 X mapdsym = newsym("mapd", VBINARY, Vmapd);
2023 X voidsym = newsym("void", UBINARY,Uvoid);
2024 X quotesym = newsym("quote", UBINARY, Uquote);
2025 X kwotesym = newsym("kwote", LBINARY, Lkwote);
2026 X defsym = newsym("def", UBINARY, Udef );
2027 X argsym = newsym("arg", LBINARY, Larg);
2028 X letsym = newsym("let", MBINARY,Mlet);
2029 X setsym = newsym("set", LBINARY, Lset);
2030 X setqsym = newsym("setq", UBINARY, Usetq);
2031 X constsym = newsym("const", UBINARY, Uconst);
2032 X sssym = newsym("ss", VBINARY, Vss);
2033 X loadsym = newsym("load", VBINARY,Vload);
2036 X shellsym = newsym("!", UBINARY, Ushell);
2041 X read_and_eval = mkcell(evalsym,mkcell(mkcell(readsym, nil), nil));
2042 X top_lev_call = mkcell(toplevelsym, nil);
2043 X top_lev_tags = mkcell(_toptagsym, mkcell(_errtagsym, nil));
2046 X org_interrupt = signal(SIGINT, SIG_IGN);
2047 X signal(SIGINT, _interrupt);
2056 X error(0, "interrupted - to exit type (exit)", 0);
2061 (set 20 10 09 19 22 18 43 'apli
/init.c
'; eval "$shar_touch") &&
2062 chmod 0644 'apli
/init.c
'
2064 then ${echo} 'restore of apli
/init.c failed
'
2068 ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'apli
/init.c
: MD5 check failed
'
2070 551c23b1de5cf69cfefa52c95af9330c apli/init.c
2073 test `LC_ALL=C wc -c < 'apli
/init.c
'` -ne 8984 && \
2074 ${echo} 'restoration warning
: size of apli
/init.c is not
8984'
2077 # ============= apli/io.c ==============
2078 if test -f 'apli
/io.c
' && test "$first_param" != -c; then
2079 ${echo} 'x
-SKIPPING apli
/io.c
(file already exists
)'
2081 ${echo} 'x
- extracting apli
/io.c
(text
)'
2082 sed 's
/^X
//' << 'SHAR_EOF
' > 'apli
/io.c
' &&
2095 #define LPARENTOK 1 /* ( */
2096 #define RPARENTOK 2 /* ) */
2097 #define LBRACKTOK 3 /* [ */
2098 #define RBRACKTOK 4 /* ] */
2099 #define LBRACETOK 5 /* { */
2100 #define RBRACETOK 6 /* } */
2101 #define QUOTETOK 7 /* ' */
2102 #define BQUOTETOK 8 /* ` */
2103 #define COMMATOK 9 /* , */
2104 #define ATTOK 10 /* @ */
2105 #define HASHTOK 11 /* # */
2106 #define STRTOK 12 /* string token */
2107 #define SYMTOK 13 /* symbol token */
2108 #define EOLTOK 14 /* end-of-line token */
2109 #define EOFTOK 15 /* endmf-file token */
2110 #define INUMTOK 16 /* integer number token */
2111 #define RNUMTOK 17 /* real number token */
2114 #define NEXTtok(chan) ((chan)->tok = nexttok(chan))
2115 #define ISdigit(ch) ((ch) >= '0' && (ch) <= '9')
2116 #define DIGITvalue(ch) ((ch) - '0')
2121 /* for use by pp
: */
2122 int ppcols
= MAXCOLS
; /* maximum no. of columns on the screen
*/
2123 int ppgap
= MAXCOLS
; /* free gap
for printing
*/
2124 int llimit
= MAXCOLS
- 30; /* left limit
*/
2125 int rlimit
= MAXCOLS
+ 15; /* right limit
*/
2127 kerncell readaux1
(register iochan
, int
); /* read an s-expression
: for internal use ONLY
*/
2129 bufprint
( int
, iochan
, char
*, ...
);
2133 openchan
(file,mode
) /* open channel
*/
2138 X register iochan chan
;
2140 X chan
= CONVchan
(new
(sizeof
(struct channel
) ) );
2142 X chan-
>buf
= new
(CHANBUFSIZE
+2);
2146 X chan-
>tok
= EOLTOK
;
2148 X chan-
>pos
= chan-
>len
= 0;
2150 X chan-
>mode
= mode
;
2152 X chan-
>file = file;
2159 closechan
(chan
) /* close channel
*/
2163 X
if (chan-
>mode
== OUTCHAN
&& chan-
>len
> 0)
2164 X bufprint
(PRINT
, chan
, "\n"); /* flush the buffer
*/
2166 X fclose
(chan-
>file);
2167 X free
(chan-
>buf
);
2173 initio
() /* initialize I
/O channels
*/
2175 X inchan
= mkchan
(_inchan
= openchan
(stdin
, INCHAN
));
2176 X outchan
= mkchan
(_outchan
= openchan
(stdout
,OUTCHAN
));
2177 X errchan
= mkchan
(_errchan
= openchan
(stderr
, OUTCHAN
));
2182 nextch
(chan
) /* returns the next character fram chan
*/
2183 X register iochan chan
;
2188 X
if (chan-
>pos
< chan-
>len
) /* more chars
in buffer
'P */
2190 X return (chan->ch = chan->buf [chan->pos++] );
2192 X chan->pos = chan->len = 0;
2194 X while ((ch = getc(chan->file) ) != EOL && ch != EOF)
2196 X if (chan->len < CHANBUFSIZE) /* store it in the buffer */
2198 X chan->buf[chan->len++] = ch;
2202 X chan->buf [chan->len] = 0;
2204 X while ((ch = getc(chan->file) ) != EOL && ch != EOF)
2205 X ; /* skip till end of line */
2207 X error(readsym,"line too long", _mkstr(chan->buf));
2210 X if (chan->len == 0) /* empty line? */
2211 X return (chan->ch = ch); /* ch is one of EOL, EOF */
2212 X chan->buf[ chan->len++] = EOL; /* put a newline at the end */
2214 X chan->buf[chan->len] = 0; /* null the end of string */
2216 X return (chan->ch = chan->buf[chan->pos++]);
2221 nexttok (chan) /* fetch and return the next token fran chan */
2222 X register iochan chan;
2226 X while (chan->ch == SPACE || chan->ch == TAB) /* skip blanks */
2230 X switch (chan->ch) {
2232 X case '(': nextch(chan); return(LPARENTOK);
2234 X case ')': nextch(chan); return(RPARENTOK);
2236 X case '[': nextch (chan); return (LBRACKTOK);
2238 X case ']': nextch(chan); return (RBRACKTOK);
2240 X case '{': nextch (chan); return (LBRACETOK);
2242 X case '}': nextch (chan); return (RBRACETOK);
2244 X case '\\': nextch (chan); return (QUOTETOK);
2246 X case '`': nextch(chan); return(BQUOTETOK);
2248 X case ',': nextch (chan); return (COMMATOK);
2250 X case '@': nextch (chan); return (ATTOK);
2252 X case '#': nextch (chan); return (HASHTOK);
2254 X case ';': chan->pos = chan->len = 0; /* ignore comments */
2259 X { register int i = 0; /* string is stored in strbuf */
2261 X while (nextch(chan) != '"' &&
2262 X chan->ch != EOL && chan->ch != EOF)
2264 X strbuf [i++] = (chan->ch == '\\' ? nextch(chan): chan->ch);
2268 X if (chan->ch == EOL || chan->ch == EOF)
2269 X error (readsym, "broken string", _mkstr(strbuf) );
2278 X register int i = 0; /* strange atom is stored in strbuf */
2280 X strbuf [i++] = chan->ch;
2282 X while (nextch(chan) != '|' &&
2283 X chan->ch != EOL && chan->ch != EOF)
2285 X strbuf[i++] = (chan->ch == '\\' ? nextch(chan): chan->ch);
2288 X strbuf [i++] = '|';
2292 X if (chan->ch == EOL || chan->ch == EOF)
2293 X error (readsym, "broken atom", _mkstr(strbuf ) );
2299 X case EOL: return (EOLTOK); /* end-of-line is reported */
2300 X case EOF: return (EOFTOK); /* end-of-file is reported */
2301 X case ESCAPE: nextch (chan); /* ignore escapes */
2306 X register int i = 0; /* nums and syms are stored in strbuf */
2308 X strbuf [i++] = chan->ch;
2310 X while (nextch(chan) != '(' && chan->ch != ')'
2311 X && chan->ch != '[' && chan->ch != ']'
2312 X && chan->ch != '(' && chan->ch != '}'
2313 X && chan->ch != SPACE && chan->ch != TAB
2314 X && chan->ch != EOL && chan->ch != EOF)
2316 X strbuf [i++] = chan->ch;
2318 X return (atomkind(strbuf));
2323 skipeoltok (chan, flag) /* skip eol token and return the next token */
2324 X register iochan chan;
2330 X while (chan->tok == EOLTOK) { /* skip eol's */
2334 X return(chan->tok);
2338 atomkind (name) /* work out whether nane is a number or symbol */
2339 X register char *name;
2342 X int sign = 1, frac = 0, places = 0;
2345 X if (isnum(name)) {
2347 X rnumber = inumber = 0;
2349 X if (*name == '+' || *name == '-') /* signed rnumber? */
2350 X sign = (*name++ == '+' ? 1 : -1);
2352 X while (*name && *name != '.') {
2353 X inumber = 10*inumber + DIGITvalue (*name);
2358 X if (*name == '.') {
2361 X while (*name && ISdigit (*name) ) { /* work out fraction */
2362 X frac = 10*frac + DIGITvalue(*name);
2366 X rnumber = (float) (sign*(inumber+((double) frac) *
2367 X pow(10.0, - (double) places)));
2368 X return (RNUMTOK); /* real number */
2371 X return (INUMTOK); /* integer number */
2373 X return (SYMTOK); /* symbol */
2377 isnum (name) /* is name a number string? */
2378 X register char *name;
2382 X if (*name == '+' || *name == '-' )
2384 X /* ~y name can'0 be number */
2388 X while (*name && (ISdigit (*name) || *name == '.')) {
2390 X if (*name == '.') { /* at most 1 decjmal point allowed */
2397 X ++name; /* skip all digjts and deciHHLL point */
2399 X return (*name == 0); /* there most be nothing left */
2407 X 42 lnternal I/O functfons
2411 readaux(chan,bq) /* read an suppression fran chan */
2413 X int bq; /* non-zero when in a back~uoted s-expression */
2415 X int save_celltop = celltop; /* save top of cell stack */
2418 X if (chan == _inchan && _outchan->len > 0) {
2419 X fprintf (_outchan->file,"%s", _outchan->buf); /* flush output */
2420 X _outchan->len = 0;
2423 X obj = readaux1 (chan,bq);
2424 X celltop = save_celltop; /* restore top of cell stack */
2425 X return (CELLpush(obj));
2430 readaux1 (chan, bq) /* read an s-expression: for internal use ONLY */
2431 X register iochan chan;
2432 X int bq; /* non-zero when in a backquoted s~ression */
2438 X skipeoltok (chan, 0);
2440 X switch (chan->tok) {
2443 X obj = CONVcell (mksym(strbuf) );
2448 X obj = mkinum(inumber);
2453 X obj = mkrnum(rnumber);
2458 X obj = mkstr(strbuf);
2464 X { /* NOTE: ) matches ( only, and ] matches [ only */
2465 X int right = (chan->tok == LPARENTOK ? RPARENTOK : RBRACKTOK);
2466 X register kerncell list;
2468 X if (skipeoltok (chan, 1) == right) {
2474 X obj = list = mkcell (readaux1(chan,bq), nil); /* (* ... ) */
2476 X while (skipeoltok(chan, 0),
2477 X chan->tok != RPARENTOK && chan->tok != RBRACKTOK
2478 X && chan->tok != EOFTOK) {
2480 X list->CELLcdr = mkcell (readaux1 (chan,bq), nil);
2482 X list = list->CELLcdr;
2484 X if (chan->tok == EOFTOK)
2485 X error (readsym, "unexpected end of file", 0);
2487 X if (chan->tok != right) {
2488 X if (chan->tok == RPARENTOK)
2489 X error(readsym,"[ ... ) is not allowed",0);
2491 X error(readsym,"( ... ] is not allowed",0);
2498 X { register kerncell set;
2500 X if (skipeoltok (chan, 1) == RBRACETOK) {
2502 X return (NIL); /* {} */
2504 X obj = set = mkset(readaux1(chan,bq),nil); /* (* ... ) */
2505 X while (skipeoltok (chan, 0),
2506 X chan->tok != RBRACETOK && chan->tok != EOFTOK) {
2507 X set->CELLcdr = mkset (readaux1 (chan, bq), nil);
2508 X set = set->CELLcdr;
2511 X if (chan->tok == EOFTOK)
2512 X error (readsym, "unexpected end of file",0);
2513 X obj = remrep(obj);
2520 X obj = mkcell (quotesym,mkcell (readaux1 (chan,bq), nil) );
2525 X obj = transform(readaux1 (chan, 1) );
2531 X error (readsym, " ', ' outside a back~ted smxpresion", 0);
2532 X obj = mkcell (_commasym, readaux1 (chan,bq) );
2539 X error (readsym, " '9 ' outside a backdated pression",0);
2540 X obj = mkcell(_atsym, readaux1(chan,bq));
2545 X obj = eval(readaux1 (chan,bq) );
2554 X return (CONVcell (eofsym) );
2558 X error (readsym, "unexpected ')'", 0);
2562 X error (readsym, "unexpected ']'", 0);
2566 X error (readsym, "unexpected '}'", 0);
2577 hasmacro (expr) /* returns non-zero when expr contains ',' or '@' */
2578 X register kerncell expr;
2580 X if (! ISlist (expr) )
2582 X if (expr->CELLcar == CONVcell(_commasym) ||
2583 X expr->CELLcar == CONVcell(_atsym))
2586 X while (ISlist (expr) ) {
2587 X if (hasmacro (expr->CELLcar) )
2589 X expr = expr->CELLcdr;
2597 transform (list) /* transform back-quoted s-expressions */
2606 X if (! hasmacro(list) )
2607 X return (mkcell(quotesym,mkcell (list, nil) ) );
2609 X if (! ISlist(obj = list->CELLcar) ) {
2610 X if (obj == CONVcell(_commasym) || obj == CONVcell(_atsym) )
2611 X return (eval(transform(list->CELLcdr) ) );
2613 X return (mkcell(conssym,
2614 X mkcell(mkcell (quotesym,mkcell (obj, nil) ),
2615 X mkcell (transform(list->CELLcdr, nil)))));
2617 X if (obj->CELLcar == CONVcell(_commasym))
2618 X return (mkcell(conssym,
2619 X mkcell(eval(transform(obj->CELLcdr)),
2620 X mkcell (transform(list->CELLcdr), nil) ) ) );
2622 X if (obj->CELLcar == CONVcell(_atsym))
2623 X return (mkcell(concsym,
2624 X mkcell(eval(transform(obj->CELLcdr) ),
2625 X mkcell (transform(list->CELLcdr), nil))));
2627 X return (mkcell (conssym,
2628 X mkcell (transform(obj),
2629 X mkcell(transform(list->CELLcdr), nil))));
2633 printaux (flag, expr, chan, max) /* auxiliary */
2635 X register kerncell expr;
2637 X int max; /* max specifies an upper bound when flag is LENGTH */
2639 X // printf("\tIn printaux\n");
2640 X // printf("\tb4 ISsym\n");;
2641 X if (ISsym(expr)) /* is expr a symbol? */
2643 // printf("\tIt is symbol\n");
2644 X return(bufprint((flag == PRINC && *CONVsym(expr)->name == '|'
2646 X chan, "%s", CONVsym(expr)->name));
2652 X // printf("\tb4 switch\n");;
2653 X switch (expr->flag) {
2656 // printf("\tIt is integer\n");
2657 X return (bufprint (flag, chan, "%ld", expr->CELLinum) );
2661 // printf("\tIt is real\n");
2662 X return (bufprint (flag, chan, "%f", expr->CELLrnum) );
2666 // printf("\tIt is string\n");
2667 X return (bufprint (flag, chan,
2668 X (flag == PRINC ? "%s" : "\"%s\""),
2673 // printf("\tIt is channel\n");
2674 X return (bufprint (flag, chan, "<channel:%1d>", expr->CELLchan));
2679 // printf("\tIt is vector\n");
2680 X return (bufprint (flag, chan, "vector [Old] ",
2681 X expr->CELLdim->CELLinum));
2685 // printf("\tIt is list\n");
2686 X if (expr->CELLcar == CONVcell (quotesym)) {
2687 X bufprint (flag, chan, " ' ");
2688 X return(1 + printaux(flag, expr->CELLcdr->CELLcar, chan, max));
2691 X case SETOBJ: /* handles lists and sets */
2693 X int oflag = expr->flag;
2695 // printf("\tIt is object\n");
2696 X size = bufprint(flag, chan,(oflag == LISTOBJ ? "(" : "{"));
2697 X if (flag == LENGTH && size > max)
2700 X size += printaux(flag,expr->CELLcar,chan,max);
2701 X if ((expr = expr->CELLcdr) != NIL) {
2702 X if (expr->flag != oflag) {
2703 X if (flag == LENGTH && size > max)
2706 X size += bufprint(flag, chan, " . ");
2707 X size += printaux(flag,expr,chan,max);
2711 X size += bufprint (flag, chan, " ");
2713 X } while (expr != NIL);
2715 X size += bufprint(flag, chan, (oflag == LISTOBJ ? ")" : "}"));
2719 X return(bufprint( flag, chan, "<@:%1d>", expr->CELLcar));
2728 extern int count_percent( char *);
2730 bufprint (int flag, iochan chan, char *format, ...) /* buffered print */
2737 X static char outputbuf [CHANBUFSIZE+2];
2738 X char *outbuf = outputbuf;
2740 X va_start( args, format); /* variable length argument */
2742 X // len = count_percent( format );
2743 X vsprintf (outbuf, format, args);
2746 X if (flag == LENGTH)
2747 X return (strlen (outputbuf ) );
2748 X else if (flag == STRIP) { /* strip (symbol) to symbol */
2750 X *(outbuf + strlen(outbuf) - 1) = 0;
2753 X if (chan->len > 0)
2754 X --(chan->len); /* get rid of the last null char */
2757 X *(chan->buf + chan->len++) = *outbuf;
2759 X if (*outbuf == EOL || chan->len > CHANBUFSIZE) {
2760 X *(chan->buf + chan->len) = 0;
2761 X fprintf (chan->file, "%s" , chan->buf );
2764 X if (!*(outbuf + 1))
2768 X } while (*outbuf++);
2770 X return (strlen(outputbuf));
2775 Lopen () /* (open 'name 'mode) */
2778 X kerncell arg1 = ARGnum1;
2779 X kerncell arg2 = ARGnum2;
2781 X CHECKlargs(opensym, 2);
2783 X GETstr(opensym, arg1),
2784 X GETstr(opensym, arg2)));
2790 openaux (name,mode) /* open a channel */
2791 X char *name, *mode;
2794 X FILE *file, *fopen();
2796 X if ((file = fopen(name, mode) ) == NULL)
2797 X error (opensym, "can't open file", mkstr (name) );
2798 X return (mkchan (openchan (file,
2800 X ? (*++mode != 0 ? INOUTCHAN: INCHAN)
2806 Lclose () /* (close 'chan) */
2808 X kerncell arg = ARGnum1;
2810 X CHECKlargs ( closesym, 1);
2812 X closechan (GETchan(closesym, arg) );
2814 X arg->flag = VOID; /* arg is no more a channel */
2822 Vflush () /* (flush ['chan]) */
2827 X CHECKvargs2 (flushsym, 1);
2829 X chan = (ARGidx1 == argtop
2831 X : (arg = ARGnum1, GETchan(flushsym,arg) ) );
2833 X if (chan->len == 0)
2836 X if (chan->mode == OUTCHAN || chan->mode == INOUTCHAN)
2837 X bufprint (PRINT, chan, "\n");
2848 X /* (read ['chan]) */
2852 X CHECKvargs2 (readsym, 1);
2854 X if (argtop == ARGidx1)
2855 X return (readaux (_inchan,0) ) ;
2859 X if ( !ISchan( arg= ARGnum1) || arg->CELLchan->mode == OUTCHAN)
2860 X error(readsym, err_chan2, arg);
2862 X return (readaux ( arg->CELLchan, 0));
2868 Vprint () /* (print 'expr ['chan]) */
2872 X CHECKvargs(printsym, 1, 2);
2874 X if (argtop - ARGidx1 == 1)
2875 X printaux (PRINT, ARGnum1, outchan, 2);
2878 X if (! ISchan(arg2 = ARGnum2) || arg2->CELLchan->mode == INCHAN)
2879 X error (printsym, err_chan2, arg2);
2881 X printaux(PRINC, ARGnum1, arg2->CELLchan, 2);
2888 Vprinc () /* (princ 'expr ['chan]) */
2892 X if (argtop - ARGidx1 == 1)
2893 X printaux (PRINC, ARGnum1, outchan, 2);
2896 X if (! ISchan(arg2 = ARGnum2) || arg2->CELLchan->mode == INCHAN)
2897 X error (princsym, err_chan2, arg2);
2898 X printaux(PRINC, ARGnum1, arg2->CELLchan, 2);
2905 Vtab () /* (tab 'column f'chan]) */
2907 X kerncell arg1 = ARGnum1, arg2;
2910 X CHECKvargs (tabsym, 1, 2);
2912 X if (argtop - ARGidx1 == 1)
2916 X if (! ISchan (arg2 = ARGnum2) || arg2->CELLchan->mode == INCHAN)
2917 X error (tabsym, err_chan2, arg2);
2918 X chan = arg2->CELLchan;
2923 X tab (GETint (tabsym, arg1), chan);
2929 tab (column, chan) /* tab */
2933 X if (column > CHANBUFSIZE)
2934 X column = CHANBUFSIZE;
2936 X if (chan->len > column)
2937 X bufprint (PRINT, chan, "\n");
2942 X while (chan->len < column)
2943 X *(chan->buf + chan->len++) = SPACE ;
2944 X *(chan->buf + chan->len) = 0;
2949 Vterpri () /* (terpri ['chan]} */
2954 X CHECKvargs2 (terprisym, 1);
2956 X if (argtop == ARGidx1)
2957 X bufprint (PRINT, outchan, "\n");
2959 X if ( !ISchan(arg = ARGnum1) || arg->CELLchan->mode == INCHAN)
2960 X error (terprisym, err_chan2, arg);
2962 X bufprint (PRINT, arg->CELLchan, "\n");
2970 Vprlen () /* (prlen 'expr ['max] } */
2975 X CHECKvargs (prlensym, 1, 2);
2977 X max = (argtop - ARGidx1 == 1
2979 X : (arg2 = ARGnum2, GETint (prlensym,arg2) ) );
2981 X return (mkinum(printaux (LENGTH, ARGnum1, outchan,max) ) ) ;
2985 Viobuf () /* (iobuf ['chan]) */
2990 X CHECKvargs2 (iobufsym,1 );
2991 X return (mkinum(ARGidx1 == argtop
2993 X :(arg = ARGnum1, GETchan (iobufsym, arg)->len) ) );
2998 Lchanp() /* (chan? 'expr) */
3000 X CHECKlargs (chanpsym, 1);
3001 X return(ISchan(ARGnum1) ? TTT : NIL) ;
3007 Vpp() /* (pp 'expr ['chan]) */
3009 X kerncell arg1 = ARGnum1;
3012 X CHECKvargs (ppsym, 1, 2);
3015 X pp ( (ISfun(arg1) ? CONVsym(arg1)->bind : arg1),
3016 X (argtop - ARGidx1 == 1
3018 X : (!ISchan (arg2 = ARGnum2) || arg2->CELLchan->mode == INCHAN
3019 X ? CONVchan (error (ppsym,err_chan2, arg2) )
3020 X : arg2->CELLchan) ),
3028 pp (expr, chan, lmar, rmar) /* pretty print expr within the margins */
3029 X register kerncell expr;
3033 X int flag = expr->flag;
3036 X if (lmar > llimit && printaux(LENGTH,expr,chan,rlimit) > rlimit) {
3037 X bufprint (PRINT, chan, "\n; <<=== continued left ===<<");
3038 X pp(expr, chan, 4, 0);
3039 X bufprint (PRINT, chan, "\n; >>=== continued right ===>>\n");
3044 X if (! ISlist (expr) ) {
3045 X printaux (PRINT, expr, chan, 2);
3049 X bufprint(PRINT, chan, (flag == LISTOBJ ? "(" : "{"));
3050 X if (printlen(expr, chan, rmar) < ppgap)
3053 X pp (expr->CELLcar, chan, chan->len, rmar);
3055 X if ((expr = expr->CELLcdr) != NIL)
3056 X if (expr->flag != flag) {
3057 X bufprint(PRINT,chan," . "); /* dotted pair */
3058 X pp(expr, chan, chan->len, rmar);
3063 X bufprint(PRINT, chan, " ") ;
3065 X } while (expr != NIL);
3068 X if (! ISlist(expr->CELLcar) && ISlist(expr->CELLcdr->CELLcdr)) {;
3070 X pp(expr->CELLcar, chan, chan->len, rmar);
3071 X bufprint(PRINT, chan, " ") ;
3072 X expr = expr->CELLcdr;
3076 X 43 Kernel Ilo funcaons
3079 X lmarl = chan->len; /* freeze left margin */
3082 X pp (expr->CELLcar, chan, lmarl,
3083 X (expr->CELLcdr == NIL ? rmar + 1: rmar) );
3085 X if ( (expr = expr->CELLcdr) != NIL) {
3086 X if (expr->flag != flag) {
3087 X bufprint (PRINT, chan," . "); /* dotted pair */
3088 X pp(expr, chan, lmarl, rmar);
3092 X bufprint (PRINT, chan, " ");
3094 X } while (expr != NIL);
3096 X bufprint (PRINT, chan, (flag = LISTOBJ ? ") ": "}") );
3100 printlen (expr, chan, rmar) /* length of expr */
3107 X ppgap = ppcols - chan->len;
3109 X len = printaux (LENGTH, expr, chan, ppgap);
3111 X return(rmar + (len > ppgap ? ppgap: len) );
3115 (set 20 10 09 19 22 18 43 'apli/io.c'; eval "$shar_touch") &&
3116 chmod 0644 'apli/io.c'
3118 then ${echo} 'restore of apli/io.c failed'
3122 ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'apli/io.c: MD5 check failed'
3124 e1e79ca2a98ec93aa61bc5908b847aac apli/io.c
3127 test `LC_ALL
=C
wc -c < 'apli/io.c'` -ne 21896 && \
3128 ${echo} 'restoration warning: size of apli/io.c is not 21896'
3131 # ============= apli/iter.c ==============
3132 if test -f 'apli/iter.c' && test "$first_param" != -c; then
3133 ${echo} 'x -SKIPPING apli/iter.c (file already exists)'
3135 ${echo} 'x - extracting apli/iter.c (text)'
3136 sed 's/^X//' << 'SHAR_EOF' > 'apli/iter.c' &&
3137 /* 126 Nonstandard Flo~ of Control and Iteration */
3143 Uprog () /* (prog (. ~ .vars...) ...gody...) */
3145 X kerncell list = argstk[argtop];
3146 X register kerncell vars, save;
3148 X register kernsym sym;
3150 X /* 127 9.2 Explicit iteration functions */
3152 X if (list == NIL || (!ISlist (vars = list->CELLcar) && vars != NIL))
3153 X error (progsym, "bad variable list" ,vars);
3155 X save = vars; /* save a pointer to vars */
3157 X while (ISlist (vars) ) { /* Process variable */
3159 X if (ISsym(fox = vars->CELLcar) && !ISconst(CONVsym(fox))) {
3161 X VARpush (sym = CONVsym(fox) , sym->flag, sym->bind);
3163 X sym->flag = VARIABLE;
3165 X sym->bind = NIL; /* in which case it is bound to nil */
3168 X else if (ISlist(fox)) { /* or a llst: (var init) */
3170 X /* some bugs to fix, since w/o the brace, compile error apppears */
3171 X if (ISsym(sym = CONVsym(fox->CELLcar)) && !ISconst(sym)) { /* this brace for prevent
3173 X VARpush (sym, sym->flag, sym->bind);
3176 X error (progsym, err_var, sym);
3177 X sym->flag = VARIABLE; /* in which case lt is bound to init */
3178 X sym->bind = eval (fox->CELLcdr->CELLcar);
3181 X error (progsym, err_var, fox);
3183 X vars = vars->CELLcdr;
3185 X fox = catch (prog, _rettagsym, list->CELLcdr) ; /* take care of returns */
3186 X while (ISlist (save) ) { /* restore varlable bindings, etc. */
3189 X save = save->CELLcdr;
3195 prog (list) /* list lS the body of the prog */
3196 X register kerncell list;
3198 X kerncell save = list;
3203 X if (catch (progaux,_gotagsym, list) == CONVcell( _gotagsym)) {
3205 X for (list=save; ISlist (list) ; list=list->CELLcdr)
3206 X if (list->CELLcar == golabel) {
3208 X list = list->CELLcdr;
3211 X error (gosym, "no such label", golabel);
3221 progaux (list) /* auxilliary */
3222 X register kerncell list;
3224 X while (ISlist (list)) { /* evaluate each list, but */
3225 X if (ISlist (list->CELLcar) )
3226 X eval (list->CELLcar);
3228 X list = list->CELLcdr;
3234 Ugo() /* (G0 label) */
3236 X if (!ISlist (argstk [argtop ] ))
3237 X error (gosym, "label required", 0);
3239 X golabel = argstk [argtop] ->CELLcar;
3241 X throw(_gotagsym,_gotagsym);
3246 Vreturn () /* (return ['result]) */
3248 X CHECKvargs2 (returnsym, 1);
3250 X throw((ARGidx1 == argtop ? NIL : ARGnum1), _rettagsym);
3255 /* 129 9.3 Implicit iteration functions */
3258 Udo () /* (do n exprl exprn) */
3261 X kerncell list = argstk[argtop];
3262 X kerncell res = NIL;
3263 X register kerncell fox;
3264 X register int times;
3266 X if (list->CELLcdr == NIL)
3267 X error (dosym, err_args, 0);
3269 X fox = eval (list->CELLcar);
3271 X times = GETint (dosym, fox);
3273 X list = list->CELLcdr;
3275 X while (times-- > 0) {
3279 X while (ISlist (fox) ) {
3281 X res = eval (fox->CELLcar);
3283 X fox = fox->CELLcdr;
3290 (set 20 10 09 19 22 18 43 'apli/iter.c'; eval "$shar_touch") &&
3291 chmod 0644 'apli/iter.c'
3293 then ${echo} 'restore of apli/iter.c failed'
3297 ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'apli/iter.c: MD5 check failed'
3299 bbef4e3e8fbdacdc809a9e293acdb45c apli/iter.c
3302 test `LC_ALL
=C
wc -c < 'apli/iter.c'` -ne 2972 && \
3303 ${echo} 'restoration warning: size of apli/iter.c is not 2972'
3306 # ============= apli/kcomp.c ==============
3307 if test -f 'apli/kcomp.c' && test "$first_param" != -c; then
3308 ${echo} 'x -SKIPPING apli/kcomp.c (file already exists)'
3310 ${echo} 'x - extracting apli/kcomp.c (text)'
3311 sed 's/^X//' << 'SHAR_EOF' > 'apli/kcomp.c' &&
3317 typedef struct snode { /* symbol/string node */
3319 X char *str; /* string/symbol name */
3320 X kernsym sym; /* denoting variable */
3321 X struct snode *left, *right; /* child nodes */
3325 typedef struct inode { /* integer node */
3327 X int inum; /* integer value */
3328 X kernsym sym; /* denoting variable */
3329 X struct inode *left, *right; /* child nodes */
3333 typedef struct rnode { /* real node */
3335 X real rnum; /* real value */
3336 X kernsym sym; /* denoting Variable */
3337 X struct rnode *left, *right; /* child nodes */
3341 stree symtree = NULL; /* symbol tree */
3342 stree strtree = NULL; /* string tree */
3343 itree inumtree = NULL; /* integer tree */
3344 rtree rnumtree = NULL; /* real tree */
3345 kernsym lastsym; /* last symbol */
3347 char *source, *target; /* source and target file names */
3349 main (argn, argv) /* main */
3355 X // char *malloc();
3357 X kerncell compile();
3361 X fprintf (stderr, "no source file\n");
3365 X if ((len = strlen(source = argv[1])) < 3 || /* check source */
3366 X source[len-2] != '.' || source[len-1] != 'k') {
3368 X fprintf (stderr, "bad source file\n");
3375 X if ((len = strlen (target = argv[2])) < 3 || /* check target */
3376 X target [len-2] != '.' || target[len-1] != 'c') {
3378 X fprintf (stderr, "bad target file\n");
3383 X /* default tarqet */
3387 X target = malloc (len + 1);
3389 X strcpy (target, source);
3391 X target [len-1] = 'c';
3397 X if (catch(compile, _toptagsym, 1) == NIL) {
3399 X fprintf (stderr, "compilation aborted\n");
3408 compile () /* compile */
3411 X kerncell compaux ();
3413 X return (caperr(compaux,NIL, 1) );
3420 compaux() /* auxiliary */
3422 X kerncell schan, tchan;
3423 X register kerncell form, forms = NIL;
3424 X kerncell procform();
3426 X schan = openaux (source, "r"); /* open source file */
3428 X tchan = openaux (target, "w"); /* open target file .*/
3430 X while (eval (readaux(schan->CELLchan, 0)) != CONVcell (eofsym));
3432 X closechan (schan->CELLchan); /* close source file */
3434 X schan = openaux (source, "r"); /* re-open source file */
3436 X while ((form = readaux(schan->CELLchan, 0)) != CONVcell(eofsym));
3438 X forms = mkcell(procform(form, 1) ,forms);
3440 X closechan (schan->CELLchan); /* close source file */
3442 X forms = dreverse (forms);
3444 X bufprint (PRINC, tchan->CELLchan, /* produce object code: */
3445 X "#include \" /user/hekmat/kern/kernel.h\"\n");
3447 X bufprint (PRINC, tchan->CELLchan, "auxillary ()\n{\n");
3449 X gensyms (symtree, tchan->CELLchan); /* generate symbols */
3451 X genstrs (strtree, tchan->CELLchan); /* generate strings */
3453 X geninums (inumtree, tchan->CELLchan); /* generate :Lntegers */
3455 X genrnums (rnumtree,tchan->CELLchan); /* generate reals */
3457 X gencode (forms , tchan->CELLchan); /* qenerate code for the forms */
3459 X bufprint (PRINC, tchan->CELLchan, "}\n");
3461 X bufprint (PRINC, tchan->CELLchan, /* main functlon */
3462 X "main() {initialize(); auxiliary(); topexec();}\n");
3464 X closechan (tchan->CELLchan);
3472 procform (form, expd) /* process a fonn */
3473 X register kerncell form;
3476 X kerncell convert (), head;
3481 X if (ISsym(form)) {
3482 X symtree = addstr (symtree, CONVsym( form) ->name);
3483 X return (CONVcell (lastsym) );
3486 X if (ISstr (form) ) {
3487 X strtree = addstr (strtree, form->CELLstr);
3488 X return (CONVcell (lastsym) );
3490 X if (ISint (form)) {
3491 X inumtree = addinum(inumtree, form->CELLinum);
3492 X return (CONVcell (lastsym) );
3494 X if (ISreal (form) ) {
3495 X rnumtree = addrnum(rnumtree, form->CELLrnum);
3496 X return (CONVcell (lastsym) );
3499 X if ((form->CELLcar) == CONVcell(quotesym) )
3500 X return (convert (form, 0) );
3503 X ((ISfun(form->CELLcar) &&
3504 X ((head = CONVsym(form->CELLcar)->bind)->CELLcar)
3505 X == CONVcell(mlamsym)) ||
3506 X (ISlist(head = form->CELLcar) &&
3507 X (head->CELLcar == CONVcell(mlamsym)))))
3508 X procform (expand (head, form, 0) , expd);
3510 X return (convert (form, expd) );
3516 convert (form, expd) /* convert a form */
3523 X return (mkcell (procform (form->CELLcar, expd),
3524 X convert (form->CELLcdr, expd) ) );
3528 addstr (tree, str) /* add string/ symbol to string/ symbol tree */
3533 X // char *malloc();
3536 X if (tree == NULL) {
3538 X if ((tree = (struct snode *)malloc(sizeof (struct snode))) == NULL){
3539 X fprintf (stderr, "insufficient memory\n");
3543 X tree->sym = lastsym = gensym();
3544 X tree->left = tree->right = NULL;
3546 X else if ((cmp - strcmp(str,tree->str)) < 0)
3547 X tree->left = addstr (tree->left, str);
3550 X tree->right = addstr (tree->right, str);
3553 X lastsym = tree->sym;
3561 addinum (tree, inum) /* add integer to integer tree */
3569 X /* char *malloc (); */
3571 X if (tree == NULL) {
3573 X if ((tree= (struct inode *)malloc(sizeof(struct inode))) == NULL) {
3574 X fprintf (stderr, "insufficient memory\n");
3577 X tree->inum = inum;
3578 X tree->sym = lastsym = gensym();
3579 X tree->left = tree->right = NULL;
3581 X else if (inum < tree->inum)
3582 X tree->left = addinum(tree->left,inum);
3584 X else if (inum > tree->inum)
3585 X tree->right = addinum(tree->right, inum);
3588 X lastsym = tree->sym;
3594 addrnum (tree, rnum) /*'add real to real tree */
3599 X /* char *malloc (); */
3601 X if (tree == NULL) {;
3603 X if ((tree= (struct rnode *)malloc(sizeof (struct rnode))) == NULL) {
3604 X fprintf (stderr, "insufficient memory\n");
3607 X tree->rnum = rnum;
3608 X tree->sym = lastsym = gensym();
3609 X tree->left = tree->right = NULL;
3611 X else if (rnum < tree->rnum)
3612 X tree->left = addrnum(tree->left,rnum);
3614 X else if (rnum > tree->rnum)
3615 X tree->right = addrnum(tree->right,rnum);
3618 X lastsym = tree->sym;
3626 gensym () /* generate a new symbol */
3628 X static int num = 0;
3630 X sprintf (strbuf, "s%04d" , num++ );
3632 X return (mksym(strbuf) );
3637 gencode (forms, chan) /* generate code for forms */
3641 X while (ISlist (forms)) {
3643 X bufprint (PRINC, chan, "eval (");
3644 X gencells (forms->CELLcar, chan);
3646 X bufprint (PRINC, chan, ");\n");
3648 X forms = forms->CELLcdr;
3652 gencells (form, chan) /* qenerate cells for fonn */
3656 X if (ISlist (form) ) {
3657 X bufprint (PRINC, chan, "mkcell(");
3659 X gencells (form->CELLcar, chan);
3661 X bufprint (PRINC, chan, ",");
3663 X gencells (form->CELLcdr, chan);
3665 X bufprint (PRINC, chan, "> ");
3668 X printaux (PRINC, form, chan);
3673 gensyms (tree, chan) /* generate code for making symbols */
3677 X if (tree != NULL) {
3678 X bufprint (PRINC, chan, "kernsym %s = ",tree->sym->name);
3680 X bufprint (PRINC, chan, "mksym(\"%s\") i\n" , tree->str);
3682 X gensyms (tree->left, chan);
3684 X gensyms (tree->right, chan);
3689 genstrs (tree, chan) /* generate code for making strings */
3693 X if (tree != NULL) {
3695 X bufprint (PRINC, chan, "kerncell %s = ", tree->sym->name);
3697 X bufprint (PRINC, chan, "mkstr (\"%s\");\n", tree->str);
3698 X genstrs (tree->left , chan);
3700 X genstrs (tree->right, chan);
3705 geninums (tree, chan) /* generate code for making :integers */
3709 X if (tree != NULL) {
3710 X bufprint (PRINC, chan, "kerncell %s = " , tree->sym->name);
3712 X bufprint (PRINC, chan, "mkinum (%1d);\n", tree->inum);
3713 X geninums (tree->left, chan);
3714 X geninums (tree->right, chan);
3720 genrnums (tree, chan) /* generate code for makinq reals */
3724 X if (tree != NULL) {
3726 X bufprint(PRINC, chan, "kerncell %s = ",tree->sym->name);
3727 X bufprint (PRINC, chan, "mkrnum (%f);\n" , tree->rnum);
3729 X genrnums (tree->left, chan);
3731 X genrnums (tree->right, chan);
3736 (set 20 10 09 19 22 18 43 'apli/kcomp.c'; eval "$shar_touch") &&
3737 chmod 0644 'apli/kcomp.c'
3739 then ${echo} 'restore of apli/kcomp.c failed'
3743 ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'apli/kcomp.c: MD5 check failed'
3745 301453a05f1a81f7294b067075fedd8a apli/kcomp.c
3748 test `LC_ALL
=C
wc -c < 'apli/kcomp.c'` -ne 8205 && \
3749 ${echo} 'restoration warning: size of apli/kcomp.c is not 8205'
3752 # ============= apli/kern.c ==============
3753 if test -f 'apli/kern.c' && test "$first_param" != -c; then
3754 ${echo} 'x -SKIPPING apli/kern.c (file already exists)'
3756 ${echo} 'x - extracting apli/kern.c (text)'
3757 sed 's/^X//' << 'SHAR_EOF' > 'apli/kern.c' &&
3771 (set 20 10 09 19 22 18 43 'apli/kern.c'; eval "$shar_touch") &&
3772 chmod 0644 'apli/kern.c'
3774 then ${echo} 'restore of apli/kern.c failed'
3778 ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'apli/kern.c: MD5 check failed'
3780 08db03171ebb5dd811c2e2ec1807526b apli/kern.c
3783 test `LC_ALL
=C
wc -c < 'apli/kern.c'` -ne 91 && \
3784 ${echo} 'restoration warning: size of apli/kern.c is not 91'
3787 # ============= apli/list.c ==============
3788 if test -f 'apli/list.c' && test "$first_param" != -c; then
3789 ${echo} 'x -SKIPPING apli/list.c (file already exists)'
3791 ${echo} 'x - extracting apli/list.c (binary)'
3792 sed 's/^X//' << 'SHAR_EOF' | uudecode &&
3793 begin 600 apli/list.c
3794 M+RH@.#,@-BXQ($QA<W0@9G5N8W1I;VYS("HO"@HO*B!L:7-T+F,@*B\*"B-I
3795 M;F-L=61E(")K97)N96PN:"(*"@EK97)N8V5L;`I
,8V
%R
*"D@+RH@*&-A<B`G
3796 M;&ES="D@
*B\
*>PH
):V5R
;F-E
;&P@
87)G
(#T@05)';G5M,3L*"@E#2$5#2VQA
3797 M
<F
=S
("AC87)S>6TL(#$I.PH*"7)E
='5R;B`H25-L:7-T("AA<F<I"@D)"3\@
3798 M87)G+3Y#14Q,8V%R"@D)"3H@*&%R9R`]/2!.24P@/R!.24P*"0D)"3H)0T].
3799 M5F-E;&P@*&5R<F]R("AC87)S>6TL(&5R<E]L:7-T+"!A<F<I("D@*2`I.PH*
3800 M?2`O*DQC87(@*B\*"@EK97)N8V5L;`I,8V1R("@I("\J("AC9'(@
)VQI
<W0I
3801 M
("HO"GL
*"6ME<FYC96QL(&%R9R`]($%21VYU;3$["@H
)0TA
%0TML87
)G
<R
`H
3802 M8V1R<WEM+"`Q
*3L*"@ER971U<FX@*$E3;&ES="`H87)G*0H*"0D)/R!A<F<M
3803 M/D-%3$QC9'(*"0D).BAA<F<@/3T@3DE,(#\@3DE,"@D)"0DZ($-/3E9C96QL
3804 M("AE<G)O<B`H8V1R
<WEM
+"!E<G)?;&ES="P@
87)G
*2`I("D@*3L*"GTO*B!,
3805 M8V1R("HO"@H):V5R;F-E;&P*3&-X>'(@*'AX*2`O
*B
`H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L;`I
,9'-U8G-T("@I("\J("@J<W5B<W0@
3950 M)W1H:7,@)W1H870@XH"8;&ES="D@*B\*>PH):V5R;F-E;&P@87)G,R`]($%2
3951 M1VYU;3,["@H)0TA%0TML87)G<R`H9'-U8G-T<WEM
+"`S*3L*"4-(14-+;&ES
3952 M
="`H9'-U8G-T<WEM+"!A
<F
<S
*3L*"@ER971U<FX@*"!D
<W5B
<W0@
*$
%21VYU
3953 M
;3$L($
%21VYU
;3(@
+"!A<F<S*2`I.PH*?2`O*B!,9'-U8G-T("HO
"@H):V5R
3954 M;F-E;&P@"F1S
=6)S
="`H87)G,2P@87)G,B`L(&%R9S,I("\J
(&1S
=6)S
="`H
3955 M=&AI<RP@=&AA="P@
;&ES
="D@*B\*"6ME
<FYC96QL
(&%R9S
$L(&%R9S
(["@ER
3956 M96=I<W1E<B!K97)N8V5L;"!A
<F
<S.PI
["@EK97)N8V5L;"!R97
,@
/2!A
<F
<S
3957 M.PH
)=VAI
;&4@
*$E3;&ES
="`H87)G,RD@*2!["@H
)"6EF("AE
<75A
;"`H87)G
3958 M,RT^0T5,3&-A<BP@87)G,BD@*0H)"0EA
<F
<S
+3Y
#14Q,8V%R(#T@87)G,3L*
3959 M
"@D)96QS92!I9B`H25-L:7-T("AA
<F
<S
+3Y
#14Q,8V%R*2`I"@D)"61S=6)S
3960 M
="`H87)G,2`L(&%R9S(@+"!A
<F
<S
+3Y
#14Q,8V%R*3L*"@D)87)G,R`](&%R
3961 M9S
,M
/D-
%3$QC9'(["@E]"@ER971U<FX@*')E
<RD
["@I]("\J
(&1S
=6)S
="`J
3962 M+PH*+RH@.3(@XH*L($QZ<W1S(&%N9"!3971S
("HO"@EK97
)N8V5L
;`I,<F5V
3963 M97)S92`H
*2`O*B`H
<F5V97
)S92
`G;&ES="D@*B\*>PH)<F5G:7-T97(@:V5R
3964 M;F-E;&P@87)G(#T@05)';G5M,3L*"@EK97)N8V5L;"!R97,@/2!.24P["@H)
3965 M0TA%0TML87)G<R`H
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R;B`H25-S>6T@*&%R
4045 M9RD@"@D)"7Q\($E3:6YT("AA<F<I('Q\
(`H)"0E)4W)E86PH87)G*2!\?"!)
4046 M4W-T<BAA<F<I(#\@5%14(#H@3DE,*3L*"GT@+RH@3&%T8WAN<"`J
+PH
*"6ME
4047 M<FYC96QL"DQL
:7-T<"`H*2`O*B`H;&ES=#\@)V5X<'(I("HO
"GL*"6ME
<FYC
4048 M96QL
(&%R9R
`]($%21VYU;3$["@H)0TA%0TML87)G<R`H
;&ES
='!S>6TL(#$I
4049 M.PH*"7)E='5R
;BA
)4VQI
<W0@
*&%R9RD@?
'P@87)G(#T]($Y)3"`_(%145"`Z
4050 M($Y)3"D["@I]("\J($QL:7-T<"`J+PH*"6ME<FYC96QL"DQP86ER<"@I("\J
4051 M("AP86ER/R`G97AP<BD@*B\*>PH)0TA%0TML87)G<R`H<&%I<G!S>6TL(#$I
4052 M.PH*"7)E='5R
;BA
)4VQI
<W0H05
)';G5M,2D@/R!45%0@.B!.24PI.PH*?2\J
4053 M($QP86ER<"`J+PH*"6ME<FYC96QL"DQN=6QL<"`H*2`O*BAN=6QL/R`G97AP
4054 M<BD@*B\*>PH)0TA%0TML87)G<R`H;G5L;'!S
>6TL
(#$I.PH*"7)E='5R;BA!
4055 J4D
=N
=6TQ
(#T]($Y)3#\@5%14(#H@3DE,*3L*"GTO*B!N=6QL<"`J+PH*
4059 (set 20 10 09 19 22 18 43 'apli/list.c'; eval "$shar_touch") &&
4060 chmod 0644 'apli/list.c'
4062 then ${echo} 'restore of apli/list.c failed'
4066 ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'apli/list.c: MD5 check failed'
4068 943fb8f425e970638c2440e087e93eac apli/list.c
4071 test `LC_ALL
=C
wc -c < 'apli/list.c'` -ne 11787 && \
4072 ${echo} 'restoration warning: size of apli/list.c is not 11787'
4075 # ============= apli/logic.c ==============
4076 if test -f 'apli/logic.c' && test "$first_param" != -c; then
4077 ${echo} 'x -SKIPPING apli/logic.c (file already exists)'
4079 ${echo} 'x - extracting apli/logic.c (text)'
4080 sed 's/^X//' << 'SHAR_EOF' > 'apli/logic.c' &&
4081 /* Condionals and logic
4089 Ucond () /* (cond --clause1 ... --clausen-- ) */
4092 X register kerncell list = argstk [ argtop];
4093 X register kerncell clause;
4097 X while (ISlist (list) ) {
4099 X clause = list->CELLcar;
4101 X CHECKlist(condsym, clause);
4103 X if ((obj = eval(clause->CELLcar) ) != NIL) {
4105 X while (ISlist(clause = clause->CELLcdr) )
4107 X obj = eval (clause->CELLcar);
4111 X list = list->CELLcdr;
4118 Lnot () /* (not 'expr) */
4121 X CHECKlargs (notsym, 1);
4123 X return(ARGnum1 == NIL ? TTT : NIL);
4128 Uand () /* (and exprl ... exprn ) */
4130 X register kerncell list = argstk[argtop];
4131 X kerncell obj = NIL;
4133 X while (ISlist (list) ) {
4135 X if ((obj = eval (list->CELLcar) ) == NIL)
4138 X list = list->CELLcdr;
4145 /* 106 Conditionals and Logic
4148 Uor () /* (or expr1 ... exprn) */
4150 X register kerncell list = argstk [argtop];
4153 X while (ISlist (list) ) {
4155 X if ((obj = eval(list->CELLcar) ) != NIL)
4158 X list = list->CELLcdr;
4165 Limply () /* ( > 'expr1 'expr2) */
4167 X CHECKlargs (implysym, 2);
4168 X return(ARGnum1 == NIL || ARGnum2 != NIL ? TTT : NIL);
4173 Lequiv () /* (< > 'expr1 'expr2) */
4175 X kerncell arg1 = ARGnum1;
4176 X kerncell arg2 = ARGnum2;
4178 X CHECKlargs (equivsym,2);
4180 X return (arg1 == arg2 ||
4181 X arg1 != NIL && arg2 != NIL ? TTT: NIL);
4186 /* 107 Condirionah and logic */
4189 Uall () /* (all (var1 dcxal ... varn domn) expr1 ... exprn) */
4191 X kerncell list = argstk [argtop];
4193 X if (list == NIL || checkdoms (list->CELLcar) )
4194 X error (allsym, err_dom,0);
4196 X return (all (list->CELLcar, list->CELLcdr) );
4200 checkdoms (doms) /* check domain designators */
4201 X register kerncell doms;
4203 X if (! ISlist (doms) )
4208 X if (! ISsym(doms->CELLcar) || ISconst (doms->CELLcar) ||
4209 X ! ISlist (doms = doms->CELLcdr) )
4212 X } while (ISlist (doms = doms->CELLcdr) );
4219 all (doms,body) /* universal quantifier */
4220 X kerncell doms, body;
4223 X kernsym sym = CONVsym(doms->CELLcar);
4224 X register kerncell dom = eval(doms->CELLcdr->CELLcar);
4225 X register kerncell list;
4227 X kerncell res = TTT;
4229 X VARpush (sym, sym->flag, sym->bind);
4230 X sym->flag = VARIABLE;
4232 X /* 108 conditionals and Logic
4235 X doms = doms->CELLcdr->CELLcdr;
4237 X if (!ISlist(dom) && dom != NIL)
4238 X error (allsym, err_dom, 0);
4240 X while (ISlist (dom) ) {
4242 X sym->bind = dom->CELLcar;
4244 X if (ISlist (doms) )
4245 X res = all(doms, body);
4250 X while (ISlist (list) ) {
4251 X res = eval (list->CELLcar);
4252 X list = list->CELLcdr;
4258 X dom = dom->CELLcdr;
4267 Uexist () /* (exist (var1 dc' [vari dc'.] ) expr ) */
4269 X kerncell list = argstk [argtop];
4271 X if (list == NIL || checkdoms (list->CELLcar) )
4272 X error (existsym, err_dom, 0);
4274 X return (exist ( list->CELLcar, list->CELLcdr ) ) ;
4280 exist (doms, body) /* existential quantifier */
4281 X kerncell doms, body;
4283 X kernsym sym = CONVsym(doms->CELLcar) ;
4284 X register kerncell dom = eval(doms->CELLcdr->CELLcar);
4285 X register kerncell list;
4286 X kerncell res = NIL;
4288 X VARpush (sym, sym->flag, sym->bind);
4289 X sym->flag = VARIABLE;
4291 X doms = doms->CELLcdr->CELLcdr;
4292 X if (! ISlist (dom) && dom != NIL)
4293 X error (existsym, err_dom, 0);
4295 X while (ISlist (dom) ) {
4297 X sym->bind = dom->CELLcar;
4299 X if (ISlist (doms) )
4300 X res = exist (doms,body);
4305 X while (ISlist (list) ) {
4307 X res = eval (list->CELLcar);
4309 X list = list->CELLcdr;
4316 X dom = dom->CELLcdr;
4325 Uone () /* (one (var1 doml deflt) exprl ... exprn) */
4327 X register kerncell list = argstk[argtop];
4328 X register kerncell dom;
4330 X kerncell body, deflt, res;
4334 X if (list == NIL || !ISlist(dom = list->CELLcar) ||
4335 X ! ISsym(sym = CONVsym(dom->CELLcar) ) || ISconst (sym) )
4336 X error (onesym, err_dom,0);
4338 X deflt = eval(dom->CELLcdr->CELLcdr->CELLcar);
4339 X VARpush (sym, sym->flag, sym->bind);
4341 X sym->flag = VARIABLE;
4343 X dom = eval(dom->CELLcdr->CELLcar);
4345 X if (! ISlist (dom) && dom != NIL)
4346 X error (onesym, err_dom, 0);
4348 X body = list->CELLcdr;
4350 X while (ISlist (dom) ) {
4352 X /* 110 Conditionals and Logic */
4354 X sym->bind = dom->CELLcar;
4357 X while (ISlist(list)) {
4358 X res = eval(list->CELLcar);
4359 X list = list->CELLcdr;
4364 X dom = dom->CELLcdr;
4368 X return (ISlist (dom) ? dom->CELLcar: deflt);
4386 (set 20 10 09 19 22 18 43 'apli/logic.c'; eval "$shar_touch") &&
4387 chmod 0644 'apli/logic.c'
4389 then ${echo} 'restore of apli/logic.c failed'
4393 ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'apli/logic.c: MD5 check failed'
4395 ad94a3c0751fa82b812ffd49e8c084fd apli/logic.c
4398 test `LC_ALL
=C
wc -c < 'apli/logic.c'` -ne 4836 && \
4399 ${echo} 'restoration warning: size of apli/logic.c is not 4836'
4402 # ============= apli/map.c ==============
4403 if test -f 'apli/map.c' && test "$first_param" != -c; then
4404 ${echo} 'x -SKIPPING apli/map.c (file already exists)'
4406 ${echo} 'x - extracting apli/map.c (binary)'
4407 sed 's/^X//' << 'SHAR_EOF' | uudecode &&
4408 begin 600 apli/map.c
4409 M+RH@,3,P($YO;G-T86YD87)D($9L;W<@;V8@0V]N=')O;"!A;F0@271E<F%A
4410 M;VX@*B\*+RH@;6%P+F,@*B\*"B-I;F-L=61E(")K97)N96PN:"(*"@EK97)N
4411 M8V5L;`I6
;6%P82
`H*2`O
*B
`H;6%P82`G9G5N
(.
*`F&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N8W1I;VX@*B\*"@D
)87)G
=&]P
(#T@87)G
4475 M
;BLQ.R
`O*B!K965P(&9U;B!O;B!T:&4@<W1A8VL@*B\*"7T*"6%R9W1O<"`]
4476 M
(&%R9VX
[("\J(')E<W1O<F4@87)G=&]P("HO
"@H)<F5T=7)N("AD
<F5V97
)S
4477 <92`H<F5S*2`I.PH
*?
2\J
(%9M87
!C9
'(@*B\*"@H)
4481 (set 20 10 09 19 22 18 43 'apli
/map.c
'; eval "$shar_touch") &&
4482 chmod 0644 'apli
/map.c
'
4484 then ${echo} 'restore of apli
/map.c failed
'
4488 ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'apli
/map.c
: MD5 check failed
'
4490 2193261ceb6cc5ccd489630423ba0641 apli/map.c
4493 test `LC_ALL=C wc -c < 'apli
/map.c
'` -ne 3088 && \
4494 ${echo} 'restoration warning
: size of apli
/map.c is not
3088'
4497 # ============= apli/misc.c ==============
4498 if test -f 'apli
/misc.c
' && test "$first_param" != -c; then
4499 ${echo} 'x
-SKIPPING apli
/misc.c
(file already exists
)'
4501 ${echo} 'x
- extracting apli
/misc.c
(binary
)'
4502 sed 's
/^X
//' << 'SHAR_EOF
' | uudecode &&
4503 begin 600 apli/misc.c
4504 M"B\J(#$S-"!-:7-C96QL86YE;W5S("HO"@HO*B!M:7-C+F,@*B\*"B-I;F-L
4505 M=61E(")K97)N96PN:"(*"@EK97)N8V5L;`I5=F]I9"@I("\J("AV;VED(%ME
4506 M>'!R72D@
*B\
*>PH
):V5R
;F-E
;&P@
;&ES
="`](&%R9W-T:UMA<F=T;W!=.PH*
4507 M"6EF
("AL:7-T+3Y#14Q,8V1R("$
]($Y)3"D*"0EE
<G
)O
<B
`H=F]I9'-Y;2P@
4508 M97)R7V%R9W,L(#`I.PH
*"7)E='5R;B`H;&ES="T^
0T5
,3&-A<BD
["@I]("\J
4509 M
(%5V
;VED
("HO"@H
):V5R
;F-E
;&P
*57%U
;W1E
("@I("\J
("AQ=6]T92!E>'!R
4510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 M6R=F<F%N97-=*2`J+PI["@ER96
=I
<W1E
<B
!I
;G0@
;F9R86UE
<RP@
979A
;&ED
4590 M
>#L*"6EN="!L96X@.PH):V5R;F-E;&P@87)G+"!P<F5V(#T@3E5,3#L*"7)E
4591 M9VES
=&5R
(&ME
<FYC96QL
(&9R86UE.PH
*"4-(14-+=F%R9W,R("AS
<W-Y
;2P@
4592 M
,2D
["@H);F9R86UE<R`]("AA
<F
=T
;W
`@/3T@05)':61X,2`_
($5604Q35$M3
4593 M25I
%("L@,2`*"0D
).BAA
<F
<@
+2!!4D
=N
=6TQ
+"!'151I;G0H<W-S>6TL87)G
4594 M*2DI.PH*"69O
<B
`H979A;&ED>#UE=F%L=&]P+3([(&YF<F%M97,@/B`P
("8F
4595 M(&5V86QI9'@@/CT@,#L@"@D
)"2TM;F9R86UE<RP@+2UE=F%L:61X*2!["@H
)
4596 M
"6QE;B`](&)U9G!R:6YT*%!224Y4+"!?
;W5T8VAA
;BPB6R4P
,F1
=("(@+&5V
4597 M86QI9'@I.PH)"69R86UE
(#T@979A;'-T:R!;979A;&ED>%T["@H)"6EF("@@
4598 M
(2!)4VQI
<W0@
*&9R86UE
*2`I(`H
)"0EP<FEN=&%U>"`H4%))3E0L(&9R86UE
4599 M+%]O=71C:&%N*3L*"@D)96QS92!["@H)"0EL96X@*ST@8G5F<')I;G0H4%))
4600 M3E0L7V]U=&-H86XL(B@B*3L*"@D)"7=H:6QE("A)4VQI<W0@*&9R86UE*2`I
4601 M
('L*"@D)"0EI9B`H9G)A;64M/D-%3$QC87(@/2!P<F5V*2`*"0D)"0EL96X@
4602 M*ST@8G5F<')I
;G0@
*%!224Y4
+%]O
=71C
:&%N
+"`B/"HJ
/B
(I.PH
*"0D)"65L
4603 M
<V4@
:68@
*&QE
;B
`K('!R:6YT875X*$Q%3D=42"P@9G)A;64M/D-%3$QC87(L
4604 M7V]U=&-H86XL(`H
)"0D)"0D
)34%80T
],4R
`M(&QE;BD@/B!-05A#3TQ3*2![
4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 M
<V4I
("\J(&%U>&EL;&%R>2`J+PH):V5R;F-E;&P@;F%M93L@"@EI
;G0@
=F5R
4622 M8F
]S93L
*>PH
)8VAA
<B
`J<W1R(#T@1T54<W1R("AL;V%D<WEM+"!N86UE*3L*
4623 M"6EN=`EL96X@
/2!S
=')L96X@*'-T<BD
["@E&24Q%("IF
:6QE
+"`J9F]P96X@
4624 M*"D
["@EI;V-H86X@8VAA;BP@;W!E;F-H86X@*"D
["@ER96=I<W1E<B!K97)N
4625 M8V5L;"!O8FH
["@H):68@*&QE;B`\(#,@?'P@<W1R6VQE;BTR72`A/2`@)RXG
4626 M('Q\('-T<EML96XM,5T@(3T@)VLG*0H)"65R
<F
]R
("AL;V%D<WEM+"`B8F%D
4627 M(&9I;&4@;F%M92(@+&YA;64I.PH*"6EF("@H9FEL92`]/2!F
;W
!E
;BAS
='(L
4628 M(G(B*2D@/3T@3E5,3"D*"0EE<G)O<BAL;V%D<WEM+")C86[B@)AT(&]P96X@
4629 M9FDQ92(L;F%M92D["@EC:&%N(#T@;W!E;F-H86X@*&9I;&4L($E.0TA!3BD[
4630 M"@H)=VAI;&4@*"AO8FH@+2!R96%D875X*&-H86XL,"DI("$]($-/3E9C96QL
4631 M*&5O9G-Y;2DI('L
*"@D);V)J(#T@979A;"AO8FHI.PH
*"0EI9B`H=F5R8F]S
4632 M92`F)B!O8FH@(3T@3DE,*2!["@D
)"5!224Y4;W5T("`H;V)J*3L*"@D)"51%
4633 M4E!226]U="@I.PH)"7T*"7T*"6-L;W-E8VAA;BAC:&%N*3L*?2`O
*B
!L
;V
%D
4634 M
("HO"@H
*+RH@
,30Q
($UI<V-E
;&QA
;F5O
=7,@
*B\
*"B-I9F1E9B!53DE8"B-I
4635 M
;F-L
=61E
(#QS:6=N86PN:#X*"@EK97)N8V5L;"`*57-H96QL("@I("\J("@A
4636 M
($E%24E14THI
("HO"GL
*"7)E9VES=&5R(&ME<FYC96QL(&QI<W0@/2!A<F=S
4637 M=&M;87)G=&]P73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W1A
='5S*2D@(3T@<')O8VED
("8F(&EW86ET("$
]("TQ
4654 M*2`@"@D
).PH
*"7-I9VYA;"A324
=)3E0L
('-A=F5?:6YT<BD[("\J(')E
<W1O
4655 M
<F4@
<V
%V960@
:6YT97
)R
=7!T
("HO"@ER971U
<FX@
*"!I=V%I="`]/2`M
,2`_
4656 M("TQ(#H@<W1A='5S*3L*?2`O
*B
!S
=6)S
:&5L;"`J+PH*(V5N9&EF(%5.25@@
4661 (set 20 10 09 19 22 18 43 'apli/misc.c'; eval "$shar_touch") &&
4662 chmod 0644 'apli/misc.c'
4664 then ${echo} 'restore of apli/misc.c failed'
4668 ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'apli/misc.c: MD5 check failed'
4670 73bbc93f876a6ae590fd1354603001e2 apli/misc.c
4673 test `LC_ALL=C wc -c < 'apli/misc.c'` -ne 6887 && \
4674 ${echo} 'restoration warning: size of apli/misc.c is not 6887'
4677 # ============= apli/prop.c ==============
4678 if test -f 'apli/prop.c' && test "$first_param" != -c; then
4679 ${echo} 'x -SKIPPING apli/prop.c (file already exists)'
4681 ${echo} 'x - extracting apli/prop.c (text)'
4682 sed 's/^X//' << 'SHAR_EOF' > 'apli/prop.c' &&
4684 Property Lists, Association Lists and Vectors
4690 Lputprop () /* (putprop 'sym 'value 'property) */
4692 X kerncell arg1 = ARGnum1;
4693 X kerncell arg2 = ARGnum2;
4694 X kerncell arg3 = ARGnum3;
4695 X register kerncell plist;
4697 X CHECKlargs (putpropsym, 3);
4699 X CHECKsym1 (putpropsym, arg1);
4701 X plist = CONVsym(arg1)->prop;
4703 X while (ISlist (plist) ) {
4705 X if (equal (plist->CELLcar, arg3) )
4706 X return (plist->CELLcdr->CELLcar = arg2);
4708 X plist = plist->CELLcdr->CELLcdr;
4710 X CONVsym(arg1)->prop = mkcell (arg3,mkcell (arg2, CONVsym(arg1)->prop) );
4718 Lremprop () /* (remprop 'sym 'property) */
4720 X kerncell arg1 = ARGnum1;
4721 X kerncell arg2 = ARGnum2;
4722 X register kerncell plist;
4725 X CHECKlargs (rempropsym,2);
4727 X CHECKsym1 (rempropsym, arg1);
4729 X plist = CONVsym(arg1) ->prop;
4731 X if (equal(plist->CELLcar, arg2) ) {
4732 X CONVsym(arg1) ->prop = plist->CELLcdr->CELLcdr;
4737 X plist = plist->CELLcdr;
4739 X while (ISlist (plist->CELLcdr) ) {
4740 X if (equal (plist->CELLcdr->CELLcar, arg2) ) {
4742 X res = plist->CELLcdr;
4744 X plist->CELLcdr = plist->CELLcdr->CELLcdr->CELLcdr;
4748 X plist = plist->CELLcdr->CELLcdr;
4754 /* 113 8.1 Property lists
4758 Lget () /* {get 'sym 'property) */
4760 X register kerncell arg1 = ARGnum1;
4761 X kerncell arg2 = ARGnum2;
4763 X CHECKlargs (getsym, 2);
4765 X CHECKsym1 (getsym, arg1);
4767 X arg1 = CONVsym(arg1) ->prop;
4768 X while (ISlist (arg1) ) {
4770 X if (equal (arg1->CELLcar, arg2) )
4772 X return (arg1->CELLcdr->CELLcar);
4774 X arg1 = arg1->CELLcdr->CELLcdr;
4780 Lplist () /* (plist 'sym) */
4782 X kerncell arg = ARGnum1;
4784 X CHECKlargs (plistsym, 1);
4786 X CHECKsym1 (plistsym, arg);
4788 X return (CONVsym(arg) ->prop);
4792 Lsetplist () /* (setplist 'sym 'plist} */
4794 X kerncell arg1 = ARGnum1;
4795 X kerncell arg2 = ARGnum2;
4797 X CHECKlargs (setplistsym, 2);
4799 X CHECKsym1 (setplistsym, arg1);
4801 X CHECKlist (setplistsym, arg2);
4803 X return (CONVsym(arg1) ->prop = arg2);
4808 /* 114 Property Lists, Association Lists and Vectors
4811 Lassoc () /* (assoc 'key 'alist) */
4813 X kerncell arg1 = ARGnum1;
4814 X register kerncell arg2 = ARGnum2;
4816 X CHECKlargs (assocsym, 2);
4817 X CHECKlist (assocsym, arg2);
4819 X while (ISlist (arg2) ) {
4820 X if ( !ISlist (arg2->CELLcar) )
4821 X error(assocsym, "bad alist element
", arg2->CELLcar);
4823 X if (equal (arg1, arg2->CELLcar->CELLcar) )
4824 X return (arg2->CELLcar);
4826 X arg2 = arg2->CELLcdr;
4833 Lassq () /* (assq 'key 'enlist) */
4835 X kerncell arg1 = ARGnum1;
4836 X register kerncell arg2 = ARGnum2;
4838 X CHECKlargs(assqsym, 2);
4839 X CHECKlist (assqsym, arg2);
4841 X while (ISlist(arg2)) {
4843 X if ( !ISlist (arg2->CELLcar) )
4844 X error(assqsym, "bad alist element
", arg2->CELLcar);
4846 X if (arg1 == arg2->CELLcar->CELLcar)
4847 X return (arg2->CELLcdr);
4849 X arg2 = arg2->CELLcdr;
4855 (set 20 10 09 19 22 18 43 'apli/prop.c'; eval "$shar_touch") &&
4856 chmod 0644 'apli/prop.c'
4858 then ${echo} 'restore of apli/prop.c failed'
4862 ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'apli/prop.c: MD5 check failed'
4864 6d5a2a50ca3e030cad16b410f603f7a1 apli/prop.c
4867 test `LC_ALL=C wc -c < 'apli/prop.c'` -ne 3014 && \
4868 ${echo} 'restoration warning: size of apli/prop.c is not 3014'
4871 # ============= apli/set.c ==============
4872 if test -f 'apli/set.c' && test "$first_param" != -c; then
4873 ${echo} 'x -SKIPPING apli/set.c (file already exists)'
4875 ${echo} 'x - extracting apli/set.c (text)'
4876 sed 's/^X//' << 'SHAR_EOF' > 'apli/set.c' &&
4883 X kerncell remrep (kerncell); /* remove repetitions frcm set */
4886 Lconvset () /* (convset 'list) */
4888 X register kerncell arg = ARGnum1;
4890 X kerncell res = NIL;
4892 X CHECKlargs (convsetsym, 1);;
4894 X CHECKlist (convsetsym, arg);
4896 X while (ISlist (arg) ) {
4898 X if (!member (arg->CELLcar, arg->CELLcdr) )
4899 X mkset (arg->CELLcar, res);
4901 X arg = arg->CELLcdr;
4910 Ldconvset ( ) /* (*convset ' list) */
4912 X register kerncell arg = ARGnum1;
4916 X CHECKlargs (dconvsetsym, 1);
4918 X CHECKlist (dconvsetsym, arg);
4920 X while (member (arg->CELLcar, arg->CELLcdr) )
4921 X arg = arg->CELLcdr;
4924 X while (ISlist (arg->CELLcdr) ) {
4926 X if (member(arg->CELLcdr->CELLcar, arg->CELLcdr->CELLcdr) )
4927 X arg->CELLcdr = arg->CELLcdr->CELLcdr;
4931 X arg->flag = SETOBJ;
4932 X arg = arg->CELLcdr;
4935 X if (ISlist (arg) )
4936 X arg->flag = SETOBJ;
4942 Lconvlist () /* (convlist 'set) */
4944 X register kerncell arg = ARGnum1;
4946 X kerncell res = NIL;
4948 X CHECKlargs (convlistsym, 1);
4950 X CHECKlist (convlistsym, arg);
4954 X while (ISlist (arg)) {
4955 X res = mkcell (arg->CELLcar, res);
4957 X arg = arg->CELLcdr;
4963 Ldconvlist () /* (*C0nvlist '8et) */
4965 X register kerncell arg = ARGnum1;
4967 X kerncell res = arg;
4969 X CHECKlargs (dconvlistsym, 1);
4971 X CHECKlist (dconvlistsym, arg);
4973 X while (ISlist (arg) ) {
4975 X arg->flag = LISTOBJ;
4977 X arg = arg->CELLcdr;
4983 Veset () /* (eset 'expr1 ... exprn) */
4985 X register int idx = ARGidx1;
4987 X register kerncell res = NIL;
4989 X while (idx < argtop)
4990 X res = mkset (argstk[idx++] ,res);
4992 X return (remrep (res) );
4996 remrep (set) /* remove repetitions frcm set */
4997 X register kerncell set;
5001 X while (member (set->CELLcar, set->CELLcdr) )
5002 X set = set->CELLcdr;
5006 X while (ISlist (set->CELLcdr) ) {
5008 X if (member (set->CELLcdr->CELLcar, set->CELLcdr->CELLcdr) )
5009 X set->CELLcdr = set->CELLcdr->CELLcdr;
5012 X set = set->CELLcdr;
5020 Uiset () /* (iset expr (varl doml exprl exprfl) */
5022 X kerncell list = argstk[argtop];
5024 X if (checkdoms (list->CELLcdr->CELLcar) )
5025 X error (isetsym, err_dom, 0);
5027 X return (iset (list->CELLcar,
5028 X list->CELLcdr->CELLcar,
5029 X list->CELLcdr->CELLcdr) );
5034 iset (gen, doms, body) /* lmplicii' set construction */
5035 X kerncell gen, doms, body;
5037 X kernsym sym = CONVsym(doms->CELLcar);
5039 X register kerncell dom = eval (doms->CELLcdr->CELLcar);
5041 X register kerncell list;
5043 X kerncell tmp, res = NIL;
5045 X VARpush (sym, sym->flag, sym->bind);
5047 X sym->flag = VARIABLE;
5049 X doms = doms->CELLcdr->CELLcdr;
5051 X if (!ISlist(dom) && dom != NIL)
5052 X error (isetsym, err_dom, 0);
5054 X while (ISlist(dom)) {
5055 X sym->bind = dom->CELLcar;
5059 X if (ISlist (doms) )
5060 X res = unionaux(iset (gen,doms,body) ,res);
5064 X while (ISlist (list)) {
5065 X tmp = eval (list->CELLcar);
5066 X list = list->CELLcdr;
5069 X res = mkset (eval (gen) , res);
5071 X dom = dom->CELLcdr;
5074 X return(ISlist(doms) ? res : remrep(res));
5078 unionaux (set1, set2) /* unlon or setl and set2 */
5079 X register kerncell set1, set2;
5081 X while (ISlist (set1) ) {
5083 X if (!member(set1->CELLcar, set2) )
5084 X set2 = mkset (set1->CELLcar, set2);;
5086 X set1 = set1->CELLcdr;
5092 Vunion () /* (union ' setl setn) */
5094 X register int idx = ARGidx1;
5095 X register kerncell argi;
5098 X if (idx == argtop)
5101 X if (idx+1 == argtop)
5106 X CHECKlist (unionsym, res);
5108 X while (++idx < argtop) {
5109 X argi = argstk [idx];
5111 X CHECKlist (unionsym, argi);
5113 X while (ISlist (argi) ) {
5115 X if (!member(argi->CELLcar, res) )
5116 X res = mkset(argi->CELLcar, res);
5118 X argi = argi->CELLcdr;
5128 Vintsec () /* (intsec ' setl setn) */
5130 X register int idx = ARGidx1;
5131 X register kerncell argi;
5132 X kerncell tmp, res;
5134 X if (idx == argtop )
5137 X if (idx+1 == argtop)
5142 X CHECKlist (intsecsym, tmp);
5144 X while (++idx < argtop ) {
5146 X argi = argstk [idx];
5148 X CHECKlist (intsecsym, argi);
5151 X while (ISlist (argi)) {
5153 X if (member(argi->CELLcar,tmp) )
5154 X res = mkset(argi->CELLcar, res);
5156 X argi = argi->CELLcdr;
5166 Ldiff () /* (diff 'set1 'set2) */
5168 X register kerncell arg1 = ARGnum1;
5169 X kerncell arg2 = ARGnum2;
5170 X kerncell res = NIL;
5172 X CHECKlargs (diffsym, 2);
5173 X CHECKlist (diffsym, arg1);
5174 X CHECKlist (diffsym, arg2);
5176 X while (ISlist (arg1)) {
5178 X if (!member(arg1->CELLcar, arg2) )
5179 X res = mkset (arg1->CELLcar, res);
5181 X arg1 = arg1->CELLcdr;
5187 Lsubset () /* (subset 'set1 'set2) */
5189 X register kerncell arg1 = ARGnum1;
5190 X kerncell arg2 = ARGnum2;
5192 X CHECKlargs (subsetsym,-2);
5193 X CHECKlist (subsetsym, arg1);
5194 X CHECKlist (subsetsym, arg2);
5196 X while (ISlist (arg1) ) {
5198 X if (!member(arg1->CELLcar,arg2) )
5201 X arg1 = arg1->CELLcdr;
5208 (set 20 10 09 19 22 18 43 'apli/set.c'; eval "$shar_touch") &&
5209 chmod 0644 'apli/set.c'
5211 then ${echo} 'restore of apli/set.c failed'
5215 ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'apli/set.c: MD5 check failed'
5217 ab9c444703c1f8af14454ea6671d80a5 apli/set.c
5220 test `LC_ALL=C wc -c < 'apli/set.c'` -ne 5265 && \
5221 ${echo} 'restoration warning: size of apli/set.c is not 5265'
5224 # ============= apli/str.c ==============
5225 if test -f 'apli/str.c' && test "$first_param" != -c; then
5226 ${echo} 'x -SKIPPING apli/str.c (file already exists)'
5228 ${echo} 'x - extracting apli/str.c (text)'
5229 sed 's/^X//' << 'SHAR_EOF' > 'apli/str.c' &&
5232 X $.2 String functions
5239 Ls_lt () /* (<< 'str1 'str2) */
5242 X kerncell arg1 = ARGnum1;
5243 X kerncell arg2 = ARGnum2;
5245 X CHECKlargs(s_ltsym, 2);
5247 X return (strcmp (GETstr (s_ltsym, arg1),
5249 X GETstr(s_ltsym,arg2)) < 0 ? TTT: NIL);
5254 Ls_gt () /* (>> 'strl 'str2) */
5256 X kerncell arg1 = ARGnum1;
5257 X kerncell arg2 = ARGnum2;
5259 X CHECKlargs(s_gtsym,2);
5261 X return (strcmp (GETstr (s_gtsym, arg1),
5262 X GETstr(s_gtsym,arg2)) > 0 ? TTT: NIL);
5268 Ls_eq () /* ( == 'strl 'str2) */
5270 X kerncell arg1 = ARGnum1;
5271 X kerncell arg2 = ARGnum2;
5273 X CHECKlargs(s_eqsym, 2);
5275 X return (strcmp (GETstr (s_eqsym, arg1),
5276 X GETstr (s_eqsym,arg2) ) == 0 ? TTT: NIL);
5281 Lstrcmp () /* (strcmp 'strl 'str2) */
5283 X kerncell arg1 = ARGnum1;
5284 X kerncell arg2 = ARGnum2;
5286 X CHECKlargs(strcmpsym, 2);
5288 X return (mkinum(strcmp (GETstr (strcmpsym, arg1),
5289 X GETstr(strcmpsym, arg2))));
5295 X Arithmetic, Strings_and SYmbols
5298 Lnthchar () /* (nthchar 'str 'n) */
5301 X kerncell arg1 = ARGnum1;
5302 X kerncell arg2 = ARGnum2;
5303 X register char *str;
5306 X CHECKlargs(nthcharsym, 2);
5308 X str = GETstr (nthcharsym, arg1);
5309 X n = GETint(nthcharsym, arg2);
5311 X while (n > 0 && *str != 0) {
5315 X return (mkinum(CONVint(*str)));
5319 Lsubstr () /* (substr 'str 'i 'j) */
5322 X kerncell arg1 = ARGnum1;
5323 X kerncell arg2 = ARGnum2;
5324 X kerncell arg3 = ARGnum3;
5325 X register char *str;
5328 X 5.2 Strfng functions
5331 X register int m, n;
5333 X CHECKlargs(substrsym, 3);
5334 X str = GETstr (substrsym, arg1);
5335 X m = GETint (substrsym, arg2);
5336 X n = GETint (substrsym, arg3);
5337 X while (m > 0 && *str != 0) { /* skip the first m chars_*/
5341 X if ((m = 0) >n) /* negative rarxye? */
5344 X else { /* copy the substring to strbuf */
5346 X while (m < n && *str)
5347 X strbuf[m++] = *str++;
5351 X return (mkstr (strbuf ) );
5358 Lstrlen () /* (strlen 'str) */
5360 X kerncell arg = ARGnum1;
5362 X CHECKlargs(strlensym, 1);
5363 X return (mkinum(strlen(GETstr (strlensym, arg))));
5368 Lstrconc () /* (strconc 'strl 'str2) */
5370 X kerncell arg1 = ARGnum1;
5371 X kerncell arg2 = ARGnum2;
5372 X char *strl, *str2;
5375 X CHECKlargs(strconcsym, 2);
5376 X m = strlen (strl = GETstr(strconcsym, arg1) );
5377 X n = strlen(str2 = GETstr(strconcsym,arg2));
5379 X if (m+n > STRBUFSIZE)
5380 X error (strconcsym, "string overflow
", 0);
5382 X strcpy (strbuf, strl);
5383 X strcpy (strbuf, str2);
5384 X strbuf [m + n] = 0;
5386 X return (mkstr (strbuf ) );
5390 /* 78 Arithmetic, Strings_and Symbols
5393 Lnilstrp () /* (nilstr? 'str) */
5395 X kerncell arg = ARGnum1;
5397 X CHECKlargs(nilstrpsym, 1);
5399 X return(*(GETstr(nilstrpsym, arg)) == 0 ? TTT: NIL);
5403 Lstringp () /* (string? 'str) */
5405 X CHECKlargs(stringpsym, 1);
5406 X return(ISstr(ARGnum1) ? TTT: NIL);
5413 (set 20 10 09 19 22 18 43 'apli/str.c'; eval "$shar_touch") &&
5414 chmod 0644 'apli/str.c'
5416 then ${echo} 'restore of apli/str.c failed'
5420 ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'apli/str.c: MD5 check failed'
5422 ac2e03b08891d0f4a7662d97f494572d apli/str.c
5425 test `LC_ALL=C wc -c < 'apli/str.c'` -ne 2993 && \
5426 ${echo} 'restoration warning: size of apli/str.c is not 2993'
5429 # ============= apli/sym.c ==============
5430 if test -f 'apli/sym.c' && test "$first_param" != -c; then
5431 ${echo} 'x -SKIPPING apli/sym.c (file already exists)'
5433 ${echo} 'x - extracting apli/sym.c (text)'
5434 sed 's/^X//' << 'SHAR_EOF' > 'apli/sym.c' &&
5435 /* 79 5.9 Symbol functions */
5441 Lsymname () /* (symnane 'syn) */
5443 X kerncell arg = ARGnum1;
5445 X CHECKlargs (symnamesym, 1);
5447 X CHECKsym1 (symnamesym, arg);
5449 X return (mkstr (CONVsym(arg) ->name) );
5453 Usynonym () /* (synonym sym1 sym2) */
5455 X kerncell list = argstk[argtop];
5456 X kernsym sym1, sym2;
5458 X if (list->CELLcdr == NIL || list->CELLcdr->CELLcdr != NIL)
5459 X error (synonymsym, err_args, 0);
5461 X sym1 = CONVsym(list->CELLcar);
5462 X sym2 = CONVsym(list->CELLcdr->CELLcar);
5464 X CHECKsym2 (symnamesym, sym1);
5465 X CHECKsym1 (symnamesym, sym2);
5467 X sym1->flag = sym2->flag;
5468 X sym1->bind = sym2->bind;
5469 X sym1->prop = sym2->prop;
5471 X return (CONVcell (sym1) );
5476 Lgensym () /* (gensym) */
5478 X static int num = 0;
5480 X CHECKlargs (gensymsym, 0);
5482 X sprintf (strbuf, "g
%04d
", num++);
5484 X return (CONVcell (mksym(strbuf ) ) );
5487 /* Arithmetic, Strings and SYmbols
5490 Vconcat () /* (concat 'strl ... 'strn) */
5494 X register int idx = ARGidx1;
5499 X char *buf = strbuf;
5501 X CHECKvargs1 (concatsym, 1);
5503 X while (idx < argtop) {
5505 X arg = argstk [idx++] ;
5506 X str = GETstr (concatsym, arg);
5508 X if ((len += strlen(str) ) > STRBUFSIZE)
5509 X error (concatsym, "string buffer overflow
", 0);
5511 X sprintf (buf, "%s
", str);
5512 X buf = strbuf + len;
5514 X return (CONVcell(mksym(strbuf) ) );
5518 Lbinding () /* (binding 'expr) */
5521 X kerncell arg = ARGnum1;
5523 X CHECKlargs (bindingsym, 1);
5526 X /* 81 5.3 Symbol functions */
5528 X switch (arg->flag) {
5533 X return (CONVsym(arg)->bind);
5536 X sprintf (strbuf, "lam
#%1d",CONVsym(arg)->bind);
5537 X
return (mkstr
(strbuf
) );
5540 X sprintf
(strbuf
, "vlam#%1d",CONVsym
(arg
)->bind);
5541 X
return (mkstr
(strbuf
) );
5544 X sprintf
(strbuf
, "ulam#%1d", CONVsym
(arg
)->bind);
5545 X
return (mkstr
(strbuf
) );
5548 X sprintf
(strbuf
, "mlam#%1d",CONVsym
(arg
)->bind);
5549 X
return (mkstr
(strbuf
) );
5557 Lsymbolp
() /* (symbol?
'expr) */
5559 X kerncell arg = ARGnum1;
5561 X CHECKlargs (symbolpsym, 1);
5562 X return(ISsym(arg) ? TTT: NIL);
5567 Lboundp () /* (bound? 'sym
) */
5569 X kerncell arg
= ARGnum1
;
5571 X CHECKlargs
(boundpsym
, 1);
5572 X CHECKsym1
(boundpsym
, arg
);
5574 X
return (ISunbound
(arg
) ? NIL
: TTT
);
5578 (set 20 10 09 19 22 18 43 'apli/sym.c'; eval "$shar_touch") &&
5579 chmod 0644 'apli/sym.c'
5581 then ${echo} 'restore of apli/sym.c failed'
5585 ${MD5SUM} -c >/dev
/null
2>&1 ||
${echo} 'apli/sym.c: MD5 check failed'
5587 5ff4558249bfb4815e0cc4bfdc389965 apli/sym.c
5590 test `LC_ALL=C wc -c < 'apli/sym.c'` -ne 2489 && \
5591 ${echo} 'restoration warning: size of apli/sym.c is not 2489'
5594 # ============= apli/symt.c ==============
5595 if test -f 'apli/symt.c' && test "$first_param" != -c; then
5596 ${echo} 'x -SKIPPING apli/symt.c (file already exists)'
5598 ${echo} 'x - extracting apli/symt.c (text)'
5599 sed 's/^X//' << 'SHAR_EOF' > 'apli/symt.c' &&
5600 /* ------------ symt.c
-------------- */
5603 extern kernsym _tempsym
;
5605 kernsym symtab
[HASHTABSIZE
]; /* symbol table
*/
5607 /* initialize the symbol table
*/
5613 X
for (i
=0; i
< HASHTABSIZE
; ++i
)
5618 hash (name
) /* the
hash function */
5619 X register char
*name
;
5621 X register int hashaddr
= 0;
5624 X hashaddr
+= *name
++;
5625 X
return (hashaddr
% HASHTABSIZE
);
5629 addsym
(name
) /* add a symbol to the symbol table
*/
5632 X int hashaddr
= hash(name
);
5634 X register kernsym newsym
, sym
;
5636 X newsym
= CONVsym
(new
(sizeof
(struct symbol
)));
5638 X newsym-
>flag
= UNBOUND
;
5640 X newsym-
>name
= new
((len
= strlen
(name
)) + 1);
5641 X strcpy
(newsym-
>name
, name
);
5642 X
*(newsym-
>name
+ len
) = 0;
5644 X
if ((sym
= symtab
[hashaddr
])== NULL || strcmp
(name
, sym-
>name
) <0) {
5645 X
/* insert
in front of list
*/
5646 X symtab
[hashaddr
] = newsym
;
5647 X newsym-
>link
= sym
;
5648 X
} else if (sym-
>link
== NULL
) { /* append to the end of list
*/
5649 X sym-
>link
= newsym
;
5650 X newsym-
>link
= NULL
;
5651 X
} else { /* insert
in list
*/
5652 X
while( strcmp
(name
, sym-
>link-
>name
) > 0 && (sym
= sym-
>link
)->link
)
5654 X newsym-
>link
= sym-
>link
;
5655 X sym-
>link
= newsym
;
5657 X newsym-
>prop
= NIL
;
5663 findsym
(name
) /* find a symbol
in the symbol table
*/
5666 X register kernsym sym
= symtab
[hash(name
)];
5669 X
while (sym
!= NULL
&& (cmp = strcmp
(name
, sym-
>name
)) > 0)
5672 X
if (sym
== NULL ||
cmp < 0) /* not found
*/
5675 X
return (sym
); /* found
*/
5680 X kernsym
/* make a symbol object
*/
5682 X register char
*name
;
5684 X kernsym sym
= findsym
(name
) ;
5686 X
if ( sym
== NULL
&& ISunbound
( sym
= addsym
(name
)) && *name
== 'c') {
5687 X
while (*++name
== 'a' ||
*name
== 'd'); /* look for c..r form
*/
5688 X
if (*name
== 'r' && *++name
== 0) {
5689 X sym-
>flag
= LBINARY
;
5690 X sym-
>bind = CONVcell
(Lcxxr
); /* see evalca11
in eval.c
*/
5697 _mksym
(name
) /* make a temporary symbol
*/
5701 X _tempsym-
>name
= name
;
5703 X
return ( _tempsym
);
5708 newsym
(name
, flag
, bind) /* make a new symbol object
*/
5709 X char
*name
; /* asks that symbol is not already
in the symbol table
*/
5715 X sym
= addsym
(name
);
5717 X sym-
>bind = bind ;
5724 (set 20 10 09 19 22 18 43 'apli/symt.c'; eval "$shar_touch") &&
5725 chmod 0644 'apli/symt.c'
5727 then ${echo} 'restore of apli/symt.c failed'
5731 ${MD5SUM} -c >/dev
/null
2>&1 ||
${echo} 'apli/symt.c: MD5 check failed'
5733 1d5903a9b5becbcbba92f94380ff0300 apli/symt.c
5736 test `LC_ALL=C wc -c < 'apli/symt.c'` -ne 2442 && \
5737 ${echo} 'restoration warning: size of apli/symt.c is not 2442'
5740 # ============= apli/vec.c ==============
5741 if test -f 'apli/vec.c' && test "$first_param" != -c; then
5742 ${echo} 'x -SKIPPING apli/vec.c (file already exists)'
5744 ${echo} 'x - extracting apli/vec.c (text)'
5745 sed 's/^X//' << 'SHAR_EOF' > 'apli/vec.c' &&
5747 /* 115 83 Vector ficnctions
*/
5752 Lvector
() /* (vector
'dim) */
5754 X kerncell arg = ARGnum1;
5755 X kerncell vector, *vec;
5758 X CHECKlargs (vectorsym, 1);
5760 X if ( !ISint(arg) || (dim = arg->CELLinum) <= 0)
5761 X error (vectorsym, "bad dimension", arg);
5763 X vec = CONVvector(new(sizeof (kerncell) * dim) );
5765 X vector = freshcell ();
5767 X vector->flag = VECTOROBJ;
5769 X vector->CELLdim = arg;
5770 X vector->CELLvec = vec;
5772 X while (dim-- ) /* initialize all slots to nil */
5781 /* 116 Property Lists Association Lists and Vectors */
5783 Ustore () /* (stor (vector idx) 'expr) */
5786 X kerncell list
= argstk
[argtop
];
5787 X kerncell slot
= list-
>CELLcar
;
5788 X kerncell vector
, index
;
5790 X
if (!ISlist
(slot
) ||
!ISvector
(vector
= eval(slot-
>CELLcar
))
5791 X ||
!ISint
(index
= eval(slot-
>CELLcdr-
>CELLcar
)))
5792 X error
(storesym
, "bad slot", slot
);
5794 X
if (index-
>CELLinum
< 0 ||
5795 X index-
>CELLinum
>= vector-
>CELLdim-
>CELLinum
)
5796 X error
(storesym
, "index out of range", index
);
5797 X
return ( *(vector-
>CELLvec
+ index-
>CELLinum
)
5798 X
= eval (list-
>CELLcdr-
>CELLcar
) );
5805 Ldimension
() /* (dimension
'vector) */
5808 X kerncell arg = ARGnum1;
5811 X CHECKlargs (dimensionsym, 1);
5813 X if (! ISvector (arg) )
5815 X error (dimensionsym, "non-vector argument", arg);
5817 X return (arg->CELLdim);
5822 Lvectorp () /* (vector? 'expr) */
5825 X kerncell arg
= ARGnum1
;
5827 X CHECKlargs
(vectorpsym
,1);
5828 X
return(ISvector
(arg
) ? TTT
: NIL
);
5834 (set 20 10 09 19 22 18 43 'apli/vec.c'; eval "$shar_touch") &&
5835 chmod 0644 'apli/vec.c'
5837 then ${echo} 'restore of apli/vec.c failed'
5841 ${MD5SUM} -c >/dev
/null
2>&1 ||
${echo} 'apli/vec.c: MD5 check failed'
5843 adbe04b3f663596948c00decb5231010 apli/vec.c
5846 test `LC_ALL=C wc -c < 'apli/vec.c'` -ne 1574 && \
5847 ${echo} 'restoration warning: size of apli/vec.c is not 1574'
5850 # ============= apli/kernel.h ==============
5851 if test -f 'apli/kernel.h' && test "$first_param" != -c; then
5852 ${echo} 'x -SKIPPING apli/kernel.h (file already exists)'
5854 ${echo} 'x - extracting apli/kernel.h (text)'
5855 sed 's/^X//' << 'SHAR_EOF' > 'apli/kernel.h' &&
5858 // Global Definitions
5861 /* debugging macros
*/
5863 # define DBG(s) printf("%s\n", (s));
5875 /* scalar constants
: */
5877 #define HASHTABSIZE 256 /* size of hash table */
5878 #define CELLTABSIZE 1024 /* Size of cell table */
5879 #define BLOCKSIZE 512 /* block size for cell allocation */
5880 #define EVALSTKSIZE 1024 /* size of evaluation stack */
5881 #define VARSTKSIZE 1024 /* size of variable stack */
5882 #define ARGSTKSIZE 1024 /* size of argument stack */
5883 #define CATSTKSIZE 256 /* size of catch stack */
5884 #define CHANBUFSIZE 126 /* size of channel buffer */
5885 #define STRBUFSIZE 126 /* size of string buffer */
5886 #define MAXCOLS 80 /* max no. of columns on the screen */
5887 #define SMALLINTLOW -128 /* least small integer */
5888 #define SMALLINTHIGH 127 /* greatest small integer */
5890 /* values
for flag
in symbol structure
: */
5891 #define UNBOUND 0 /* unbound symbol */
5892 #define CONSTANT 1 /* constant - cannot be changed */
5893 #define VARIABLE 2 /* bound variable */
5894 #define FUNCTION 3 /* non-binary function */
5895 #define LBINARY 4 /* binary lam */
5896 #define VBINARY 5 /* binary vlam */
5897 #define UBINARY 6 /* binary ulam */
5898 #define MBINARY 7 /* binary mlam */
5899 #define INTERNAL 8 /* internal object - not in symbol table */
5901 /* values
for flag
in cell structure
: */
5902 #define VOID 10 /* void dbject */
5903 #define INTOBJ 11 /* integer number */
5904 #define REALOBJ 12 /* real number */
5905 #define STROBJ 13 /* string */
5906 #define CHANOBJ 14 /* channel for I/O */
5907 #define VECTOROBJ 15 /* vector */
5911 #define LISTOBJ 16 /* list */
5912 #define SETOBJ 17 /* set */
5913 #define MARK 128 /* mark bit - for garbage collection */
5914 #define MASK7 127 /* for masking bit 7 in flag */
5916 /* channel kinds
: */
5917 #define INCHAN 0 /* input channel flag */
5918 #define OUTCHAN 1 /* output channel flag */
5919 #define INOUTCHAN 2 /* input-Output channel flag */
5921 /* values
for flag
in printaux and bufprint
: */
5922 #define PRINT 0 /* flag === PRINT ===> prim; */
5923 #define PRINC 1 /* flag == PRINC ==> princ */
5924 #define LENGTH 2 /* flag == LENGTH ==> prlen */
5925 #define STRIP 3 /* |symbol => symbol */
5927 typedef unsigned char byte
; /* the basic byte unit
*/
5928 typedef union
{int i
,*j
;} word
; /* the basic word.unit
*/
5929 typedef float real
; /* real
type - can be changed.to double
*/
5931 struct symbol
{ /* symbol structure
*/
5932 X byte flag
; /* symbol
type, always
< VOID
*/
5933 X struct cell
*bind; /* symbol handing
*/
5934 X struct cell
*prop
; /* symbol property list
*/
5935 X char
*name
; /* symbol name
*/
5936 X struct symbol
*link
; /* link to next symbol
*/
5939 struct cell
{ /* cons-cell structure
*/
5940 X byte flag
; /* cell
type, always
>= VOID
*/
5942 X int inum
; /* integer number
*/
5943 X real rnum
; /* real number
*/
5944 X char
*str
; /* string
*/
5945 X struct channel
*chan
; /* channel
*/
5946 X struct
{ /* for list
/set construction
*/
5947 X struct cell
*car
; /* car pointer
*/
5948 X struct cell
*cdr
; /* cdr pointer
*/
5950 X struct
{ /* for vector construction
*/
5951 X struct cell
*dim
; /* vector dinension
*/
5952 X struct cell
**vec
; /* vector block
*/
5957 struct channel
{ /* I
/O channel structure
*/
5958 X char ch
; /* current character
*/
5959 X unsigned short int tok
; /* current token
*/
5960 X unsigned short int pos
; /* current position
in buf
*/
5961 X unsigned short int len
; /* no. of chars
in buf
*/
5962 X char
*buf
; /* channel buffer
*/
5963 X byte mode
; /* one of INCHAN
,OUTCHAN
,INOUTCHAN
*/
5965 X FILE
*file; /* the
file associated with channel
*/
5968 struct variable
{ /* variable structure
for variable stack
*/
5969 X struct symbol
*sym
; /* variable symbo1
*/
5970 X byte flag
; /* its flag
*/
5971 X struct cell
*bind; /* its binding
*/
5974 typedef struct symbol
*kernsym
; /* symbol pointer
*/
5975 typedef struct cell
*kerncell
; /* cell pointer
*/
5976 typedef struct channel
*iochan
; /* I
/O channel
*/
5980 #define ISnotbinary(p) ((p)->flag < LBINARY)
5981 #define ISunbound(p) ((p)->flag == UNBOUND)
5982 #define ISconst(p) ((p)->flag == CONSTANT)
5983 #define ISvar(p) ((p)->flag == VARIABLE)
5984 #define ISfun(p) ((p)->flag == FUNCTION)
5985 #define ISlbin(p) ((p)->flag == LBINARY)
5986 #define ISvbin(p) ((p)->flag == VBINARY)
5987 #define ISubin(p) ((p)->flag == UBINARY)
5988 #define ISmbin(p) ((p)->flag == MBINARY)
5989 #define ISinternal(p) ((p)->flag == INTERNAL)
5991 #define ISsym(p) ((p)->flag < VOID)
5992 #define IScell(p) ((p)->flag >= VOID)
5993 #define ISvoid(p) ((p)->flag == VOID)
5994 #define ISint(p) ((p)->flag == INTOBJ)
5995 #define ISreal(p) ((p)->flag == REALOBJ)
5996 #define ISstr(p) ((p)->flag == STROBJ)
5997 #define ISchan(p) ((p)->flag == CHANOBJ)
5998 #define ISvector(p) ((p)->flag == VECTOROBJ)
5999 #define ISlist(p) ((p)->flag >= LISTOBJ)
6000 #define ISset(p) ((p)->flag == SETOBJ)
6001 #define ISmarked(p) (((p)->flag & MARK) == MARK)
6003 #define CELLinum part.inum
6004 #define CELLrnum part.rnum
6005 #define CELLstr part.str
6006 #define CELLchan part.chan
6007 #define CELLcar part.pair.car
6008 #define CELLcdr part.pair.cdr
6009 #define CELLdim part.vect.dim
6010 #define CELLvec part.vect.vec
6012 #define CONVbyte(p) ((byte) (p))
6013 #define CONVint(p) ((int) (p))
6014 #define CONVintp(p) ((int *) (p))
6015 #define CONVreal(p) ((real) (p))
6016 #define CONVstr(p) ((char *) (p))
6017 #define CONVchan(p) ((iochan) (p))
6021 /* 163 Global Definitions
*/
6023 #define CONVsym(p) ((kernsym) (p) )
6024 #define CONVcell(p) ((kerncell) (p) )
6025 #define CONVvector(p) ((kerncell *) (p) )
6026 #define NIL ((kerncell) nil)
6027 #define TTT ((kerncell) ttt)
6029 #define READin() readaux(_inchan, 0)
6030 #define READchan(chan) readaux((chan)->KELLchan,0)
6031 #define PRINTout(p) printaux(PRINT, (p), _outchan)
6032 #define PRINTchan(p, chan) printaux(PRINT, (p), (chan)->CELLchan)
6033 #define TERPRIout() bufprint(PRINT, _outchan, "\n", 0)
6034 #define TERPRIchan(chan) bufprint(PRINT, (chan)->CELLchan, "\n", 0)
6035 #define INTERNALsym(isym) \
6036 X
(isym
= CONVsym
(new
(sizeof
(struct symbol
))))->flag
= INTERNAL
6038 #define CHECKlargs(fun, n) \
6039 X
if (argtop
- CONVint
(argstk
[argtop
] ) != (n
) ) \
6040 X error
(fun
, err_args
,0)
6042 #define CHECKvargs(fun, m, n) \
6043 X
if (argtop
- CONVint
(argstk
[argtop
]) < (m
) || \
6044 X argtop
- CONVint
(argstk
[argtop
]) > (n
) ) \
6045 X error
(fun
, err_args
, 0)
6047 #define CHECKvargs1(fun, n) \
6048 X
if (argtop
- CONVint
(argstk
[argtop
] ) < (n
) ) \
6049 X error
(fun
, err_args
, 0)
6051 #define CHECKvargs2(fun, n) \
6052 X
if (argtop
- CONVint
(argstk
[argtop
] ) > (n
) ) \
6053 X error
(fun
, err_args
, 0)
6056 #define EVALpush(obj) \
6057 X
(++evaltop
< celltop ? evalstk
[evaltop
] = (obj
) \
6058 X
: CONVcell
(faterr
(err_evalstk
)))
6060 #define EVALpop() --evaltop
6062 #define CELLpush(obj) \
6063 X
(--celltop > evaltop ? evalstk
[celltop
] = (obj
) \
6064 X
: CONVcell
(faterr
(err_evalstk
)))
6066 #define CELLpop() ++celltop
6068 #define VARpush(s, f,b) \
6069 X
if (++vartop
< VARSTKSIZE
){ \
6070 X varstk
[vartop
].sym
= (s
); \
6071 X varstk
[vartop
].flag
= (f
); \
6072 X varstk
[vartop
].
bind = (b
); \
6073 X
} else faterr
(err_varstk
);
6076 X
{ varstk
[vartop
].sym-
>flag
= varstk
[vartop
].flag
; \
6077 X varstk
[vartop
].sym-
>bind = varstk
[vartop--
].
bind; }
6079 #define ARGpush(obj) \
6080 X
if (++argtop
< EVALSTKSIZE
) argstk
[argtop
] = (obj
); \
6081 X
else faterr
(err_argstk
);
6083 #define ARGpop() --argtop
6085 #define ARGSpop() argtop=CONVint(argstk[argtop])-1
6087 #define ARGidx1 CONVint(argstk[argtop])
6088 #define ARGnum1 argstk[ARGidx1]
6092 #define ARGnum2 argstk [ARGidx1 + 1]
6093 #define ARGnum3 argstk [ARGidx1 + 2]
6094 #define ARGnum4 argstk [ARGidx1 + 3]
6096 #define GETint(yyy, xxx) \
6097 X
(ISint
(xxx
) ? xxx-
>CELLinum
: CONVint
(error
(yyy
, err_int
, xxx
)))
6099 #define GETreal(yyy, xxx) \
6100 X
(ISreal
(xxx
) ?
(xxx
)->CELLrnum
: CONVint
(error
(yyy
, err_real
, xxx
)))
6102 #define GETnum(yyy, xxx) \
6103 X
(ISint
(xxx
) ?
(xxx
)->CELLinum \
6104 X
:(ISreal
(xxx
) ?
(xxx
)->CELLrnum \
6105 X
: CONVint
(error
((yyy
), err_num
, (xxx
)))))
6107 #define GETstr(yyy, xxx) \
6108 X
(ISstr
(xxx
) ? xxx-
>CELLstr \
6109 X
:(ISsym
(xxx
) ? CONVsym
(xxx
)->name \
6110 X
: CONVstr
(error
((yyy
),err_str
,(xxx
)))))
6112 #define GETchan(yyy, xxx) \
6113 X
(ISchan
(xxx
) ?
(xxx
)->CELLchan
: CONVchan
(error
((yyy
),err_chan1
,xxx
)))
6115 #define CHECKsym1(yyy, xxx) \
6116 X
if (xxx-
>flag
> VOID
) error
(yyy
, err_sym1
, xxx
)
6118 #define CHECKsym2(yyy, xxx) \
6119 X
if (xxx-
>flag
>= VOID || xxx-
>flag
== CONSTANT
) \
6120 error
(yyy
, err_sym2
, xxx
)
6122 #define CHECKpair(yyy, xxx) \
6123 X
if (xxx-
>flag
< LISTOBJ
) error
(yyy
, err_pair
, xxx
)
6125 #define CHECKlist(yyy, xxx) \
6126 X
if (xxx-
>flag
< LISTOBJ
&& xxx
!= NIL
) error
(yyy
,err_list
,xxx
)
6128 /* ---- external declarations
------ */
6131 *err_args
, *err_pars
,
6132 X
*err_evalstk
, *err_varstk
, *err_argstk
, *err_catstk
,
6133 X
*err_memory
, *err_list
,
6134 X
*err_int
, *err_real
, *err_num
, *err_str
, *err_chan1
, *err_chan2
,
6135 X
*err_sym1
, *err_sym2
, *err_pair
, *err_list
, *err_var
, *err_dom
;
6137 extern kerncell catres
;
6138 extern kerncell golabel
;
6139 extern kerncell _tempstr
;
6140 extern kerncell inchan
, outchan
, errchan
;
6141 extern iochan _inchan
, _outchan
, _errchan
;
6142 extern char strbuf
[];
6143 extern struct variable varstk
[];
6144 extern kerncell evalstk
[], argstk
[];
6145 extern int evaltop
, celltop
, vartop
, argtop
, _argtop
;
6146 extern kerncell read_and_eval
, top_lev_call
, top_lev_tags
;
6147 extern int
(* org_interrupt
) (); /* original interrupt handler
*/
6151 extern kernsym _bquotesym
, _commasym
, _atsym
,
6152 X _toptagsym
, _errtagsym
, _rettagsym
, _gotagsym
,
6153 X _tempsym
, _cxxrsym
;
6157 X Global Definitions
6161 extern kernsym nil
, ttt
, eofsym
, inchansym
, outchansym
, errchansym
;
6164 extern kernsym lamsym
,vlamsym
, ulamsym
, mlamsym
;
6167 extern kernsym addsym
(), findsym
(), mksym
(), _mksym
(), newsym
();
6170 extern char
*new
() ;
6171 extern kerncell freshcell
(), oo1lectgarb
(), mkinum
(), mkrnum
(),
6172 X mkstr
(), _mkstr
(), mkchan
(), mkcell
(), mkset
();
6175 extern kernsym evalsym
, callsym
, applysym
;
6177 extern kerncell Leval
(), eval(), Vcall
(), Lapply
(), evalcall
(),
6178 X evallamm
(), evalvlam
(), eva1ulam
(), evalmlam
(),
6179 X
expand(), evalvector
(), mkargslist
();
6181 extern kernsym opensym
, closesym
, flushsym
, readsym
, printsym
, princsym
,
6182 X tabsym
, terprisym
, prlensym
, iobufsym
, chanpsym
, ppsym
;
6184 extern kerncell readaux
() , readaux1
() , transform
() ,
6185 X Lopen
(), openaux
(), Lclose
(), Vflush
(), Vread
(), Vprint
(),
6186 X Vprinc
(), Vtab
(), Vterpri
(), Vprlen
(), Viobuf
(), Lchanp
(),
6191 extern kernsym plussym
, minussym
, timessym
, divsym
, sumsym
, prodsym
, remsym
,
6192 X powsym
, incsym
, decsym
, abssym
, negsym
, intsym
, realsym
,
6193 X a_ltsym
, a_gtsym
, a_lesym
, a_gesym
, a_eqsym
, a_nesym
,
6194 X numberpsym
, intpsym
, realpsym
;
6196 extern kerncell Lplus
(), Lminus
(), Ltimes
(), Ldiv
(), Vsum
(), Vprod
(),
6197 X Lrem
(), Lpow
(), Linc
(), Ldec
(),
6198 X Labs
(), Lneg
(), Lint
(), Lreal
(),
6199 X La_lt
(), La_gt
(), La_le
(), La_ge
(), La_eq
(), La_ne
(),
6200 X Lnumberp
(), Lintp
(), Lrealp
(), Lposp
(), Lnegp
();
6203 extern kernsym s_ltsym
, s_gtsym
, s_eqsym
, strcmpsym
, nthcharsym
, substrsym
,
6204 X strlensym
, strconcsym
, nilstrpsym
, stringpsym
;
6206 extern kerncell Ls_lt
(), Ls_gt
(), Ls_eq
(),
6207 X Lstrcmp
(), Lnthchar
(), Lsubstr
(), Lstrlen
(),
6208 X Lstrconc
(), Lnilstrp
(), Lstringp
();
6211 extern kernsym symnamesym
, synonymsym
, gensymsym
, concatsym
, bindingsym
,
6212 X symbolpsym
, boundpsym
;
6214 extern kerncell Lsymname
(), Usynonym
(), Lgensym
(), Vconcat
(), Lbinding
(),
6215 X Lsymbolp
(), Lboundp
();
6218 extern kernsym carsym
, cdrsym
, nthelemsym
, nthpairsym
, rplacasym
,
6219 X rplacdsym
, lastelemsym
, lastpairsym
, conssym
, listsym
,
6220 X lengthsym
, concsym
, dconcsym
, removesym
, dremovesym
,
6221 X substsym
, dsubstsym
, reversesym
, dreversesym
, membersym
,
6222 X memqsym
, equalsym
, nequalsym
, eqsym
, neqsym
, atompsym
,
6223 X listpsym
, pairpsym
, nullpsym
;
6225 extern kerncell Lcar
(), Lcdr
(), Lcxxr
(), Lnthelem
(), Lnthpair
(),
6226 X Lrplaca
(), Lrplacd
(), Llastelem
(), Llastpair
(), lastpair
(),
6231 X Lcons
(), Vlist
(), Llength
(), Vconc
(), Vdconc
(), copytop
(),
6232 X Lremove
(), Ldremove
(), Lsubst
(), subst
(), Ldsubst
(), dsubst
(),
6233 X Lreverse
(), Ldreverse
(), dreverse
(),
6234 X Lmember
(), Lmemq
(), Lequal
(), Lnequal
(), Leq
(), Lneq
(),
6235 X Latomp
(), Llistp
(), Lpairp
(), Lnullp
();
6238 extern kernsym convsetsym
, dconvsetsym
, convlistsym
, dconvlistsym
,
6239 X esetsym
, isetsym
, unionsym
, intsecsym
, diffsym
, subsetsym
;
6241 extern kerncell Lconvset
(), Ldconvset
() , Lconvlist
() , Ldconvlist
(),
6242 X Veset
(), Uiset
(), iset
(), unionaux
(), remreP
(),
6243 X Vunion
(), Vintsec
(), Ldiff
(), Lsubset
();
6246 extern kernsym notsym
, andsym
, orsym
, condsym
, implysym
, equivsym
,
6247 X allsym
, existsym
, onesym
;
6249 extern kerncell Lnot
(), Uand
(), Uor
(), Ucond
(), Limply
(), Lequiv
(),
6250 X Uall
(), all
(), Uexist
(), exist
(), Uone
();
6253 extern kernsym putpropsym
, rempropsym
, getsym
, plistsym
, setplistsym
,
6254 X assocsym
, assqsym
;
6256 extern kerncell Lputprop
(), Lremprop
(), Lget
() , Lplist
() , Lsetplist
() ,
6257 X Lassoc
(), Lassq
();
6260 extern kernsym vectorsym
, storesym
, dimensionsym
, vectorpsym
;
6262 extern kerncell Lvector
(), Ustore
(), Ldimension
(), Lvectorp
();
6265 extern kernsym catchsym
, throwsym
, caperrsym
, errorsym
, toplevelsym
,
6266 X resetsym
, exitsym
;
6268 extern kerncell catch
(), throw
(), caperr
(),
6269 X Ucatch
(), Vthrow
(), Ucaperr
(), Verror
(), Ltoplevel
(),
6270 X Lreset
(), Vexit
();
6273 extern kernsym progsym
, gosym
, returnsym
, dosym
;
6275 extern kerncell Uprog
(), prog
(), progaux
(), Ugo
(), Vreturn
(), Udo
();
6278 extern kernsym mapcarsym
, mapasym
, mapcdrsym
, mapdsym
;
6280 extern kerncell Vmapcar
(), Vmapa
(), Vmapcdr
(), Vmapd
();
6283 extern kernsym voidsym
, quotesym
, kwotesym
, defsym
, funsym
, argsym
, letsym
,
6284 X setsym
, setqsym
, constsym
, sssym
, loadsym
, shellsym
;
6286 extern kerncell Uvoid
(), Uquote
(), Lkwote
(), Udef
(), Mfun
(), Larg
(), Mlet
(),
6287 X Lset
(), Usetq
(), Uconst
(), Vss
(), Vload
(), Ushell
();
6289 (set 20 10 09 19 22 18 43 'apli/kernel.h'; eval "$shar_touch") &&
6290 chmod 0644 'apli/kernel.h'
6292 then ${echo} 'restore of apli/kernel.h failed'
6296 ${MD5SUM} -c >/dev
/null
2>&1 ||
${echo} 'apli/kernel.h: MD5 check failed'
6298 93828e9ebd2feb45d6a78f849fc292a7 apli/kernel.h
6301 test `LC_ALL=C wc -c < 'apli/kernel.h'` -ne 14099 && \
6302 ${echo} 'restoration warning: size of apli/kernel.h is not 14099'
6305 # ============= apli/README ==============
6306 if test -f 'apli/README' && test "$first_param" != -c; then
6307 ${echo} 'x -SKIPPING apli/README (file already exists)'
6309 ${echo} 'x - extracting apli/README (text)'
6310 sed 's/^X//' << 'SHAR_EOF' > 'apli/README' &&
6311 It is the
source code of the book
:
6312 LISP A Portable Implementation
6313 X Sharam Hekmatpour
/1989
6315 X The license of the code is belonged to the author of the book.
6317 Since the original floppy disk is lost
, the only way is to
type or ocr.
6318 I used several weeks to ocr and compile the
source code.
6320 During the process
, I learn a lot from the
source code and the book.
6321 It was compile under linux with gcc v4.5
.1/amd64. I think it should work under
32bits also.
6322 Tcc is not working well
, may be some days to fix the bugs. Any improve
/fix is welcome.
6324 perlawk
, 2010-Sep-25
6327 (set 20 10 09 19 22 34 27 'apli/README'; eval "$shar_touch") &&
6328 chmod 0644 'apli/README'
6330 then ${echo} 'restore of apli/README failed'
6334 ${MD5SUM} -c >/dev
/null
2>&1 ||
${echo} 'apli/README: MD5 check failed'
6336 99cb31c982127f1e4b59e5a835a3ec26 apli/README
6339 test `LC_ALL=C wc -c < 'apli/README'` -ne 559 && \
6340 ${echo} 'restoration warning: size of apli/README is not 559'
6343 # ============= apli/Makefile ==============
6344 if test -f 'apli/Makefile' && test "$first_param" != -c; then
6345 ${echo} 'x -SKIPPING apli/Makefile (file already exists)'
6347 ${echo} 'x - extracting apli/Makefile (text)'
6348 sed 's/^X//' << 'SHAR_EOF' > 'apli/Makefile' &&
6349 SRC
= arith.c cellt.c
eval.c flow.c globals.c init.c io.c iter.c \
6350 X list.c logic.c map.c misc.c prop.c
set.c str.c sym.c symt.c vec.c
6360 kern
: $
(OBJS
) kern.o
6361 X $
(CC
) -o $@ $
(LIBS
) $
(OBJS
) $@.o
6363 kcomp
: $
(OBJS
) kcomp.o
6364 X $
(CC
) -o $@ $
(LIBS
) $
(OBJS
) $@.o
6367 X $
(CC
) $
(CFLAGS
) $
< -o $@
6373 (set 20 10 09 19 22 34 39 'apli/Makefile'; eval "$shar_touch") &&
6374 chmod 0644 'apli/Makefile'
6376 then ${echo} 'restore of apli/Makefile failed'
6380 ${MD5SUM} -c >/dev
/null
2>&1 ||
${echo} 'apli/Makefile: MD5 check failed'
6382 533a85be7681edf78fd6d9a50abce0eb apli/Makefile
6385 test `LC_ALL=C wc -c < 'apli/Makefile'` -ne 393 && \
6386 ${echo} 'restoration warning: size of apli/Makefile is not 393'
6389 if rm -fr ${lock_dir}
6390 then ${echo} 'x - removed lock directory `'${lock_dir}\''.'
6391 else ${echo} 'x - failed to remove lock directory `'${lock_dir}\''.'