home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume8 / elk / part07 < prev    next >
Text File  |  1989-09-23  |  62KB  |  2,225 lines

  1. Newsgroups: comp.sources.misc
  2. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  3. Subject: v08i055: Elk (Extension Language Toolkit) part 07 of 14
  4. Reply-To: net@tub.UUCP (Oliver Laumann)
  5.  
  6. Posting-number: Volume 8, Issue 55
  7. Submitted-by: net@tub.UUCP (Oliver Laumann)
  8. Archive-name: elk/part07
  9.  
  10. [Let this be a lesson to submitters:  this was submitted as uuencoded,
  11. compressed files.  I lost the source information while unpacking it; this
  12. is the best approximation I could come up with.  ++bsa]
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then unpack
  16. # it by saving it into a file and typing "sh file".  To overwrite existing
  17. # files, type "sh file -c".  You can also feed this as standard input via
  18. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  19. # will see the following message at the end:
  20. #        "End of archive 7 (of 14)."
  21. # Contents:  src/debug.c src/stack.s src/promise.c src/stack.s.68k
  22. #   src/stack.s.386 src/scheme.h src/stab.c scm/toplevel scm/pp
  23. #   scm/debug scm/apropos scm/flame scm/macros scm/qsort
  24. #   scm/toplevel.simple scm/qsort.mit scm/struct scm/describe scm/oda
  25. #   scm/cscheme scm/xlib scm/setf scm/gray scm/xlib.more scm/parse
  26. #   scm/xt scm/expt scm/xwidgets tst/gcd
  27. # Wrapped by net@tub on Sun Sep 17 17:32:28 1989
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f src/debug.c -a "${1}" != "-c" ; then 
  30.   echo shar: Will not over-write existing file \"src/debug.c\"
  31. else
  32. echo shar: Extracting \"src/debug.c\" \(929 characters\)
  33. sed "s/^X//" >src/debug.c <<'END_OF_src/debug.c'
  34. X/* Backtrace, etc.
  35. X */
  36. X
  37. X#include "scheme.h"
  38. X
  39. XObject P_Backtrace_List (argc, argv) Object *argv; {
  40. X    register GCNODE *p, *gp = GC_List;
  41. X    register delta = 0;
  42. X    Object cp, list, tail, cell, vec;
  43. X    GC_Node3;
  44. X
  45. X    if (argc > 0) {
  46. X    cp = argv[0];
  47. X    Check_Type (cp, T_Control_Point);
  48. X    delta = *(int *)(CONTROL(cp)->stack);
  49. X    gp = CONTROL(cp)->gclist;
  50. X    }
  51. X    vec = list = tail = Null;
  52. X    GC_Link3 (vec, list, tail);
  53. X    for ( ; gp; gp = p->next) {
  54. X    p = (GCNODE *)NORM(gp);
  55. X    switch (p->gclen) {
  56. X    case TAG_ENV:
  57. X        vec = Make_Vector (3, Null);
  58. X        VECTOR(vec)->data[2] = *(Object *)NORM(p->gcobj);
  59. X        break;
  60. X    case TAG_FUN:
  61. X        VECTOR(vec)->data[0] = *(Object *)NORM(p->gcobj);
  62. X        break;
  63. X    case TAG_ARGS:
  64. X        VECTOR(vec)->data[1] = *(Object *)NORM(p->gcobj);
  65. X        cell = Cons (vec, Null);
  66. X        if (Nullp (list))
  67. X        list = cell;
  68. X        else
  69. X        P_Setcdr (tail, cell);
  70. X        tail = cell;
  71. X    }
  72. X    }
  73. X    GC_Unlink;
  74. X    return list;
  75. X}
  76. END_OF_src/debug.c
  77. if test 929 -ne `wc -c <src/debug.c`; then
  78.     echo shar: \"src/debug.c\" unpacked with wrong size!
  79. fi
  80. # end of overwriting check
  81. fi
  82. if test -f src/stack.s -a "${1}" != "-c" ; then 
  83.   echo shar: Will not over-write existing file \"src/stack.s\"
  84. else
  85. echo shar: Extracting \"src/stack.s\" \(1112 characters\)
  86. sed "s/^X//" >src/stack.s <<'END_OF_src/stack.s'
  87. X/* int stksize();
  88. X * int saveenv(char* envbuf);
  89. X * dead jmpenv(const char* envbuf, int retcode);
  90. X */
  91. X    .globl    _stksize
  92. X    .globl    _Special
  93. X_stksize:
  94. X    movl    _stkbase,d0
  95. X    subl    sp,d0
  96. X    addl    #120,d0
  97. X    rts
  98. X
  99. X    .globl    _saveenv
  100. X_saveenv:
  101. X    movl    sp@(4),a0
  102. X    movl    a6,a0@(12)        /* save frame pointer of caller */
  103. X    movl    sp@+,a1            /* pop return address */
  104. X    movl    a1,a0@(4)        /* save pc of caller */
  105. X    movl    sp,a0@(8)
  106. X    moveml    #0xBCFC,a0@(40)        /* XXX (shouldn't need this) XXX */
  107. X    movl    sp,a2
  108. X    movl    _stkbase,a3
  109. X    movl    a0,a4
  110. X    addl    #110,a4
  111. Xrep1:    movl    a2@+,a4@+
  112. X    cmpl    a2,a3
  113. X    jcc    rep1
  114. X    movl    a4,d0            /* New pointer */
  115. X    subl    a2,d0            /* Minus old pointer */
  116. X    movl    d0,a0@            /* is the relocation offset */
  117. X    moveml    a0@(40),#0xBCFC        /* XXX (shouldn't need this) XXX */
  118. X    movl    _Special,d0
  119. X    jmp    a1@
  120. X
  121. X    .globl    _jmpenv
  122. X_jmpenv:
  123. X    movl    sp@(8),d0        /* return value */
  124. X    movl    sp@(4),a0        /* fetch buffer */
  125. X
  126. X    movl    a0@(8),sp
  127. X    movl    sp,a2
  128. X    movl    _stkbase,a3
  129. X    movl    a0,a4
  130. X    addl    #110,a4
  131. Xrep2:    movl    a4@+,a2@+
  132. X    cmpl    a2,a3
  133. X    jcc    rep2
  134. X    moveml    a0@(40),#0xBCFC        /* XXX (shouldn't need this) XXX */
  135. X    movl    a0@(12),a6        /* restore frame pointer */
  136. X    movl    a0@(4),a1        /* pc */
  137. X    jmp    a1@
  138. END_OF_src/stack.s
  139. if test 1112 -ne `wc -c <src/stack.s`; then
  140.     echo shar: \"src/stack.s\" unpacked with wrong size!
  141. fi
  142. # end of overwriting check
  143. fi
  144. if test -f src/promise.c -a "${1}" != "-c" ; then 
  145.   echo shar: Will not over-write existing file \"src/promise.c\"
  146. else
  147. echo shar: Extracting \"src/promise.c\" \(888 characters\)
  148. sed "s/^X//" >src/promise.c <<'END_OF_src/promise.c'
  149. X/* Delay and force
  150. X */
  151. X
  152. X#include "scheme.h"
  153. X
  154. XObject P_Promisep (x) Object x; {
  155. X    return TYPE(x) == T_Promise ? True : False;
  156. X}
  157. X
  158. XObject P_Delay (argl) Object argl; {
  159. X    Object d;
  160. X    register char *p;
  161. X    GC_Node;
  162. X
  163. X    GC_Link (argl);
  164. X    p = Get_Bytes (sizeof (struct S_Promise));
  165. X    GC_Unlink;
  166. X    SET(d, T_Promise, (struct S_Promise *)p);
  167. X    PROMISE(d)->done = 0;
  168. X    PROMISE(d)->env = The_Environment;
  169. X    PROMISE(d)->thunk = Car (argl);
  170. X    return d;
  171. X}
  172. X
  173. XObject P_Force (d) Object d; {
  174. X    Object ret, a[2];
  175. X    GC_Node;
  176. X
  177. X    Check_Type (d, T_Promise);
  178. X    if (PROMISE(d)->done)
  179. X    return PROMISE(d)->thunk;
  180. X    GC_Link (d);
  181. X    a[0] = PROMISE(d)->thunk; a[1] = PROMISE(d)->env;
  182. X    ret = P_Eval (2, a);
  183. X    GC_Unlink;
  184. X    PROMISE(d)->done = 1;
  185. X    return PROMISE(d)->thunk = ret;
  186. X}
  187. X
  188. XObject P_Promise_Env (p) Object p; {
  189. X    Check_Type (p, T_Promise);
  190. X    return PROMISE(p)->env;
  191. X}
  192. END_OF_src/promise.c
  193. if test 888 -ne `wc -c <src/promise.c`; then
  194.     echo shar: \"src/promise.c\" unpacked with wrong size!
  195. fi
  196. # end of overwriting check
  197. fi
  198. if test -f src/stack.s.68k -a "${1}" != "-c" ; then 
  199.   echo shar: Will not over-write existing file \"src/stack.s.68k\"
  200. else
  201. echo shar: Extracting \"src/stack.s.68k\" \(1112 characters\)
  202. sed "s/^X//" >src/stack.s.68k <<'END_OF_src/stack.s.68k'
  203. X/* int stksize();
  204. X * int saveenv(char* envbuf);
  205. X * dead jmpenv(const char* envbuf, int retcode);
  206. X */
  207. X    .globl    _stksize
  208. X    .globl    _Special
  209. X_stksize:
  210. X    movl    _stkbase,d0
  211. X    subl    sp,d0
  212. X    addl    #120,d0
  213. X    rts
  214. X
  215. X    .globl    _saveenv
  216. X_saveenv:
  217. X    movl    sp@(4),a0
  218. X    movl    a6,a0@(12)        /* save frame pointer of caller */
  219. X    movl    sp@+,a1            /* pop return address */
  220. X    movl    a1,a0@(4)        /* save pc of caller */
  221. X    movl    sp,a0@(8)
  222. X    moveml    #0xBCFC,a0@(40)        /* XXX (shouldn't need this) XXX */
  223. X    movl    sp,a2
  224. X    movl    _stkbase,a3
  225. X    movl    a0,a4
  226. X    addl    #110,a4
  227. Xrep1:    movl    a2@+,a4@+
  228. X    cmpl    a2,a3
  229. X    jcc    rep1
  230. X    movl    a4,d0            /* New pointer */
  231. X    subl    a2,d0            /* Minus old pointer */
  232. X    movl    d0,a0@            /* is the relocation offset */
  233. X    moveml    a0@(40),#0xBCFC        /* XXX (shouldn't need this) XXX */
  234. X    movl    _Special,d0
  235. X    jmp    a1@
  236. X
  237. X    .globl    _jmpenv
  238. X_jmpenv:
  239. X    movl    sp@(8),d0        /* return value */
  240. X    movl    sp@(4),a0        /* fetch buffer */
  241. X
  242. X    movl    a0@(8),sp
  243. X    movl    sp,a2
  244. X    movl    _stkbase,a3
  245. X    movl    a0,a4
  246. X    addl    #110,a4
  247. Xrep2:    movl    a4@+,a2@+
  248. X    cmpl    a2,a3
  249. X    jcc    rep2
  250. X    moveml    a0@(40),#0xBCFC        /* XXX (shouldn't need this) XXX */
  251. X    movl    a0@(12),a6        /* restore frame pointer */
  252. X    movl    a0@(4),a1        /* pc */
  253. X    jmp    a1@
  254. END_OF_src/stack.s.68k
  255. if test 1112 -ne `wc -c <src/stack.s.68k`; then
  256.     echo shar: \"src/stack.s.68k\" unpacked with wrong size!
  257. fi
  258. # end of overwriting check
  259. fi
  260. if test -f src/stack.s.386 -a "${1}" != "-c" ; then 
  261.   echo shar: Will not over-write existing file \"src/stack.s.386\"
  262. else
  263. echo shar: Extracting \"src/stack.s.386\" \(1052 characters\)
  264. sed "s/^X//" >src/stack.s.386 <<'END_OF_src/stack.s.386'
  265. X    .file "stack.s"
  266. X
  267. X    .globl    stksize
  268. X    .globl saveenv
  269. X    .globl jmpenv
  270. X    .globl    Special
  271. X
  272. Xstksize:
  273. X    movl    stkbase,%eax
  274. X    subl    %esp,%eax
  275. X    addl    $120,%eax
  276. X    ret
  277. X
  278. Xsaveenv:
  279. X    movl    4(%esp),%eax
  280. X    movl    %ebp,12(%eax)
  281. X    movl   %ebx,40(%eax)
  282. X    movl    (%esp),%ebx
  283. X    movl    %ebx,4(%eax)
  284. X    addl    $4,%esp
  285. X    movl    %esp,8(%eax)
  286. X    movl   %esi,44(%eax)
  287. X    movl   %edi,48(%eax)
  288. X    movl   %ebp,52(%eax)
  289. X    movl   %edx,56(%eax)
  290. X
  291. X    movl    %esp,%esi
  292. X    movl    %eax,%edi
  293. X    addl    $80,%edi
  294. X
  295. X    movl    stkbase,%ecx
  296. X    subl    %esi,%ecx
  297. X    shr    $2,%ecx
  298. X    repz
  299. X     movsl    
  300. X    subl    %esi,%edi
  301. X    movl    %edi,(%eax)
  302. X    movl    40(%eax),%ebx
  303. X    movl    44(%eax),%esi
  304. X    movl    48(%eax),%edi
  305. X    movl    52(%eax),%ebp
  306. X    movl    56(%eax),%edx
  307. X    movl    %eax,%ecx
  308. X    movl    Special,%eax
  309. X    jmp    *4(%ecx)
  310. X
  311. Xjmpenv:
  312. X    movl    8(%esp),%ecx
  313. X    movl    4(%esp),%eax
  314. X    movl    8(%eax),%esp
  315. X    movl    %esp,%edi
  316. X    movl    %eax,%esi
  317. X    addl    $80,%esi
  318. X    movl    %ecx,%ebx
  319. X    movl    stkbase,%ecx
  320. X    subl    %edi,%ecx
  321. X    shr    $2,%ecx
  322. X    repz
  323. X    movsl
  324. X    movl    %ebx,%ecx
  325. X    movl    40(%eax),%ebx
  326. X    movl    44(%eax),%esi
  327. X    movl    48(%eax),%edi
  328. X    movl    52(%eax),%ebp
  329. X    movl    56(%eax),%edx
  330. X    movl    12(%eax),%ebp
  331. X    xchg    %eax,%ecx
  332. X    jmp    *4(%ecx)
  333. X
  334. END_OF_src/stack.s.386
  335. if test 1052 -ne `wc -c <src/stack.s.386`; then
  336.     echo shar: \"src/stack.s.386\" unpacked with wrong size!
  337. fi
  338. # end of overwriting check
  339. fi
  340. if test -f src/scheme.h -a "${1}" != "-c" ; then 
  341.   echo shar: Will not over-write existing file \"src/scheme.h\"
  342. else
  343. echo shar: Extracting \"src/scheme.h\" \(100 characters\)
  344. sed "s/^X//" >src/scheme.h <<'END_OF_src/scheme.h'
  345. X#include <stdio.h>
  346. X
  347. X#include "config.h"
  348. X#include "object.h"
  349. X#include "extern.h"
  350. X#include "macros.h"
  351. END_OF_src/scheme.h
  352. if test 100 -ne `wc -c <src/scheme.h`; then
  353.     echo shar: \"src/scheme.h\" unpacked with wrong size!
  354. fi
  355. # end of overwriting check
  356. fi
  357. if test -f src/stab.c -a "${1}" != "-c" ; then 
  358.   echo shar: Will not over-write existing file \"src/stab.c\"
  359. else
  360. echo shar: Extracting \"src/stab.c\" \(3985 characters\)
  361. sed "s/^X//" >src/stab.c <<'END_OF_src/stab.c'
  362. X/* Read and manage symbol tables from object modules
  363. X */
  364. X
  365. X#include "scheme.h"
  366. X
  367. X#if defined(CAN_LOAD_OBJ) || defined (INIT_OBJECTS)
  368. X
  369. X#ifdef COFF
  370. X#  include <filehdr.h>
  371. X#  include <syms.h>
  372. X#  undef TYPE         /* ldfnc.h defines a TYPE macro. */
  373. X#  include <ldfcn.h>
  374. X#  undef TYPE
  375. X#  ifdef USE_BITFIELDS
  376. X#    define TYPE(x) ((int)(x).s.type)
  377. X#  else
  378. X#    define TYPE(x) ((int)((x) >> VALBITS))
  379. X#  endif
  380. X#else
  381. X#  include <a.out.h>
  382. X#  include <sys/types.h>
  383. X#endif
  384. X
  385. Xchar *Safe_Malloc (size) {
  386. X    char *ret;
  387. X
  388. X    if ((ret = malloc (size)) == 0)
  389. X    Primitive_Error ("not enough memory to allocate ~s bytes",
  390. X        Make_Fixnum (size));
  391. X    return ret;
  392. X}
  393. X
  394. X#ifdef COFF
  395. X
  396. XSYMTAB *Snarf_Symbols (lf, ep) LDFILE *lf; {
  397. X    SYMTAB *tab;
  398. X    register SYM *sp, **nextp;
  399. X    SYMENT sym;
  400. X    long inx;
  401. X    char *p;
  402. X    extern char *ldgetname();
  403. X
  404. X    if (ldtbseek (lf) == FAILURE) {
  405. X    ldclose (lf, NULL);
  406. X    Primitive_Error ("can't ldtbseek");
  407. X    }
  408. X    tab = (SYMTAB *)Safe_Malloc (sizeof (SYMTAB));
  409. X    tab->first = 0;
  410. X    tab->strings = 0;
  411. X    nextp = &tab->first;
  412. X    while (1) {
  413. X    inx = ldtbindex (lf);
  414. X    if (ldtbread (lf, inx, &sym) == FAILURE)
  415. X        break;
  416. X    if (sym.n_scnum == N_UNDEF || sym.n_scnum == N_DEBUG
  417. X        || sym.n_scnum > HEADER(lf).f_nscns)
  418. X        continue;
  419. X    if ((p = ldgetname (lf, &sym)) == NULL)
  420. X        continue;
  421. X    sp = (SYM *)Safe_Malloc (sizeof (SYM));
  422. X    sp->name = Safe_Malloc (strlen (p) + 1);
  423. X    strcpy (sp->name, p);
  424. X    sp->type = sym.n_type;
  425. X    sp->value = sym.n_value;
  426. X    *nextp = sp;
  427. X    nextp = &sp->next;
  428. X    *nextp = 0;
  429. X    }
  430. X    return tab;
  431. X}
  432. X
  433. XSYMTAB *Open_File_And_Snarf_Symbols (name) char *name; {
  434. X    LDFILE *f;
  435. X    SYMTAB *tab;
  436. X
  437. X    if ((f = ldopen (name, NULL)) == FAILURE)
  438. X    Primitive_Error ("can't ldopen a.out file");
  439. X    tab = Snarf_Symbols (f);
  440. X    ldclose (f);
  441. X    return tab;
  442. X}
  443. X
  444. X#else
  445. X
  446. XSYMTAB *Snarf_Symbols (f, ep) FILE *f; struct exec *ep; {
  447. X    SYMTAB *tab;
  448. X    register SYM *sp, **nextp;
  449. X    int nsyms, strsiz;
  450. X    struct nlist nl;
  451. X
  452. X    tab = (SYMTAB *)Safe_Malloc (sizeof (SYMTAB));
  453. X    tab->first = 0;
  454. X    tab->strings = 0;
  455. X    nextp = &tab->first;
  456. X    (void)fseek (f, (long)N_SYMOFF(*ep), 0);
  457. X    for (nsyms = ep->a_syms / sizeof (nl); nsyms > 0; nsyms--) {
  458. X    if (fread ((char *)&nl, sizeof (nl), 1, f) != 1) {
  459. X        Free_Symbols (tab);
  460. X        fclose (f);
  461. X        Primitive_Error ("corrupt symbol table in object file");
  462. X    }
  463. X    if (nl.n_un.n_strx == 0 || nl.n_type & N_STAB)
  464. X        continue;
  465. X    sp = (SYM *)Safe_Malloc (sizeof (SYM));
  466. X    sp->name = (char *)nl.n_un.n_strx;
  467. X    sp->type = nl.n_type;
  468. X    sp->value = nl.n_value;
  469. X    *nextp = sp;
  470. X    nextp = &sp->next;
  471. X    *nextp = 0;
  472. X    }
  473. X    if (fread ((char *)&strsiz, sizeof (strsiz), 1, f) != 1) {
  474. Xstrerr:
  475. X    Free_Symbols (tab);
  476. X    fclose (f);
  477. X    Primitive_Error ("corrupt string table in object file");
  478. X    }
  479. X    if (strsiz <= 4)
  480. X    goto strerr;
  481. X    tab->strings = Safe_Malloc (strsiz);
  482. X    strsiz -= 4;
  483. X    if (fread (tab->strings+4, 1, strsiz, f) != strsiz)
  484. X    goto strerr;
  485. X    for (sp = tab->first; sp; sp = sp->next)
  486. X    sp->name = tab->strings + (long)sp->name;
  487. X    return tab;
  488. X}
  489. X
  490. XSYMTAB *Open_File_And_Snarf_Symbols (name) char *name; {
  491. X    struct exec hdr;
  492. X    FILE *f;
  493. X    SYMTAB *tab;
  494. X
  495. X    if ((f = fopen (name, "r")) == NULL)
  496. X    Primitive_Error ("can't open a.out file");
  497. X    if (fread ((char *)&hdr, sizeof hdr, 1, f) != 1) {
  498. X    fclose (f);
  499. X    Primitive_Error ("can't read a.out header");
  500. X    }
  501. X    tab = Snarf_Symbols (f, &hdr);
  502. X    fclose (f);
  503. X    return tab;
  504. X}
  505. X
  506. X#endif
  507. X
  508. XFree_Symbols (tab) SYMTAB *tab; {
  509. X    register SYM *sp;
  510. X
  511. X    for (sp = tab->first; sp; sp = sp->next) {
  512. X#ifdef COFF
  513. X    free (sp->name);
  514. X#endif
  515. X    free ((char *)sp);
  516. X    }
  517. X    if (tab->strings)
  518. X    free (tab->strings);
  519. X}
  520. X
  521. XCall_Initializers (tab, addr) SYMTAB *tab; char *addr; {
  522. X    register SYM *sp;
  523. X
  524. X    for (sp = tab->first; sp; sp = sp->next) {
  525. X#ifndef COFF
  526. X    if ((sp->type & N_TYPE) != N_TEXT)
  527. X        continue;
  528. X#endif
  529. X    if (sp->name[0] == '_' && (char *)sp->value >= addr
  530. X        && (bcmp (sp->name, "__STI", 5) == 0
  531. X        || bcmp (sp->name, "_init_", 6) == 0))
  532. X        ((int (*)())sp->value)();
  533. X    }
  534. X}
  535. X
  536. X#endif
  537. END_OF_src/stab.c
  538. if test 3985 -ne `wc -c <src/stab.c`; then
  539.     echo shar: \"src/stab.c\" unpacked with wrong size!
  540. fi
  541. # end of overwriting check
  542. fi
  543. if test -f scm/toplevel -a "${1}" != "-c" ; then 
  544.   echo shar: Will not over-write existing file \"scm/toplevel\"
  545. else
  546. echo shar: Extracting \"scm/toplevel\" \(2687 characters\)
  547. sed "s/^X//" >scm/toplevel <<'END_OF_scm/toplevel'
  548. X;;; -*-Scheme-*-
  549. X;;;
  550. X;;; Read-eval-print loop and error handler
  551. X
  552. X(define (directory-filename s)
  553. X  (substring s 0
  554. X         (1+
  555. X          (do ((i (1- (string-length s)) (1- i)))
  556. X          ((or (zero? i) (char=? (string-ref s i) #\/)) i)))))
  557. X
  558. X(define top-dir (directory-filename (cadr load-path)))
  559. X
  560. X(append! load-path (list (string-append top-dir "lib")
  561. X             (string-append top-dir "tst")))
  562. X
  563. X(define call/cc call-with-current-continuation)
  564. X
  565. X(fluid-let ((autoload-notify? #f))
  566. X  (require 'macros))
  567. X
  568. X(autoload 'pp 'pp)
  569. X(autoload 'apropos 'apropos)
  570. X(autoload 'flame 'flame)
  571. X(autoload 'sort 'qsort)
  572. X(autoload 'define-structure 'struct)
  573. X(autoload 'describe 'describe)
  574. X(autoload 'backtrace 'debug)
  575. X(autoload 'inspect 'debug)
  576. X(autoload 'expt 'expt)
  577. X
  578. X(define ?)
  579. X(define ??)
  580. X(define ???)
  581. X(define !)
  582. X(define !!)
  583. X(define !!!)
  584. X(define &)
  585. X
  586. X(define (rep-loop env)
  587. X  (define input)
  588. X  (define value)
  589. X  (let loop ()
  590. X    (set! ??? ??)
  591. X    (set! ?? ?)
  592. X    (set! ? &)
  593. X    ;;; X Windows hack
  594. X    (if (and (bound? 'display-flush-output) (bound? 'dpy) (display? dpy))
  595. X    (display-flush-output dpy))
  596. X    (if (> rep-level 0)
  597. X    (display rep-level))
  598. X    (display "> ")
  599. X    (set! input (read))
  600. X    (set! & input)
  601. X    (if (not (eof-object? input))
  602. X    (begin
  603. X      (set! value (eval input env))
  604. X      (set! !!! !!)
  605. X      (set! !! !)
  606. X      (set! ! value)
  607. X      (write value)
  608. X      (newline)
  609. X      (loop)))))
  610. X
  611. X(define rep-frames)
  612. X(define rep-level)
  613. X
  614. X(set! interrupt-handler
  615. X  (lambda ()
  616. X    (format #t "~%\7Interrupt!~%")
  617. X    (let ((next-frame (car rep-frames)))
  618. X      (next-frame #t))))
  619. X
  620. X(define-macro (push-frame control-point)
  621. X  `(begin
  622. X     (set! rep-frames (cons ,control-point rep-frames))
  623. X     (set! rep-level (1+ rep-level))))
  624. X
  625. X(define-macro (pop-frame)
  626. X  '(begin
  627. X     (set! rep-frames (cdr rep-frames))
  628. X     (set! rep-level (1- rep-level))))
  629. X
  630. X(define (error-print error-msg)
  631. X  (format #t "~s: " (car error-msg))
  632. X  (apply format `(#t ,@(cdr error-msg)))
  633. X  (newline))
  634. X
  635. X(set! error-handler
  636. X  (lambda error-msg
  637. X    (error-print error-msg)
  638. X    (let loop ((just-called #t))
  639. X      (if (call-with-current-continuation
  640. X       (lambda (control-point)
  641. X         (if just-called
  642. X         (push-frame control-point))
  643. X         (rep-loop (the-environment))
  644. X         #f))
  645. X      (loop #f)))
  646. X    (newline)
  647. X    (pop-frame)
  648. X    (let ((next-frame (car rep-frames)))
  649. X      (next-frame #t))))
  650. X
  651. X(define top-level-environment (the-environment))
  652. X
  653. X(define (top-level)
  654. X  (let loop ()
  655. X    (if (call-with-current-continuation
  656. X     (lambda (control-point)
  657. X       (set! rep-frames (list control-point))
  658. X       (set! top-level-control-point control-point)
  659. X       (set! rep-level 0)
  660. X       (rep-loop top-level-environment)
  661. X       #f))
  662. X    (loop))))
  663. X
  664. X(define (the-top-level)
  665. X  (top-level)
  666. X  (newline)
  667. X  (exit))
  668. X
  669. X(the-top-level)
  670. X
  671. X
  672. END_OF_scm/toplevel
  673. if test 2687 -ne `wc -c <scm/toplevel`; then
  674.     echo shar: \"scm/toplevel\" unpacked with wrong size!
  675. fi
  676. # end of overwriting check
  677. fi
  678. if test -f scm/pp -a "${1}" != "-c" ; then 
  679.   echo shar: Will not over-write existing file \"scm/pp\"
  680. else
  681. echo shar: Extracting \"scm/pp\" \(2757 characters\)
  682. sed "s/^X//" >scm/pp <<'END_OF_scm/pp'
  683. X;;; -*-Scheme-*-
  684. X;;;
  685. X;;; Trivial pretty-printer
  686. X
  687. X(provide 'pp)
  688. X
  689. X(define pp)
  690. X
  691. X(let ((max-pos 55) (pos 0) (tab-stop 8))
  692. X  
  693. X  (put 'lambda  'special #t)
  694. X  (put 'macro   'special #t)
  695. X  (put 'define  'special #t)
  696. X  (put 'define-macro     'special #t)
  697. X  (put 'define-structure 'special #t)
  698. X  (put 'fluid-let        'special #t)
  699. X  (put 'let     'special #t)
  700. X  (put 'let*    'special #t)
  701. X  (put 'letrec  'special #t)
  702. X  (put 'case    'special #t)
  703. X
  704. X  (put 'call-with-current-continuation 'long #t)
  705. X
  706. X  (put 'quote            'abbr "'")
  707. X  (put 'quasiquote       'abbr "`")
  708. X  (put 'unquote          'abbr ",")
  709. X  (put 'unquote-splicing 'abbr ",@")
  710. X
  711. X(set! pp (lambda (x)
  712. X  (set! pos 0)
  713. X  (cond ((eq? (type x) 'compound)
  714. X         (set! x (procedure-lambda x)))
  715. X    ((eq? (type x) 'macro)
  716. X     (set! x (macro-body x))))
  717. X  (fluid-let ((garbage-collect-notify? #f))
  718. X    (pp-object x))
  719. X  #v))
  720. X
  721. X(define (flat-size s)
  722. X  (fluid-let ((print-length 1000) (print-depth 100))
  723. X    (string-length (format #f "~a" s))))
  724. X
  725. X(define (pp-object x)
  726. X  (if (or (null? x) (pair? x))
  727. X      (pp-list x)
  728. X      (if (void? x)
  729. X      (display "#v")
  730. X          (write x))
  731. X      (set! pos (+ pos (flat-size x)))))
  732. X
  733. X(define (pp-list x)
  734. X  (if (and (pair? x)
  735. X       (symbol? (car x))
  736. X       (string? (get (car x) 'abbr))
  737. X       (= 2 (length x)))
  738. X      (let ((abbr (get (car x) 'abbr)))
  739. X    (display abbr)
  740. X    (set! pos (+ pos (flat-size abbr)))
  741. X    (pp-object (cadr x)))
  742. X      (if (> (flat-size x) (- max-pos pos))
  743. X      (pp-list-vertically x)
  744. X      (pp-list-horizontally x))))
  745. X
  746. X(define (pp-list-vertically x)
  747. X  (maybe-pp-list-vertically #t x))
  748. X
  749. X(define (pp-list-horizontally x)
  750. X  (maybe-pp-list-vertically #f x))
  751. X
  752. X(define (maybe-pp-list-vertically vertical? list)
  753. X  (display "(")
  754. X  (set! pos (1+ pos))
  755. X  (if (null? list)
  756. X      (begin
  757. X    (display ")")
  758. X    (set! pos (1+ pos)))
  759. X      (let ((pos1 pos))
  760. X    (pp-object (car list))
  761. X    (if (and vertical?
  762. X         (or
  763. X          (and (pair? (car list))
  764. X               (not (null? (cdr list))))
  765. X          (and (symbol? (car list))
  766. X               (get (car list) 'long))))
  767. X        (indent-newline (1- pos1)))
  768. X    (let ((pos2 (1+ pos)) (key (car list)))
  769. X      (let tail ((flag #f) (l (cdr list)))
  770. X        (cond ((pair? l)
  771. X           (if flag
  772. X               (indent-newline
  773. X            (if (and (symbol? key) (get key 'special))
  774. X                (1+ pos1)
  775. X                pos2))
  776. X               (display " ")
  777. X               (set! pos (1+ pos)))
  778. X           (pp-object (car l))
  779. X           (tail vertical? (cdr l)))
  780. X          (else
  781. X           (cond ((not (null? l))
  782. X              (display " . ")
  783. X              (set! pos (+ pos 3))
  784. X              (if flag (indent-newline pos2))
  785. X              (pp-object l)))
  786. X           (display ")")
  787. X           (set! pos (1+ pos)))))))))
  788. X
  789. X (define (indent-newline x)
  790. X   (newline)
  791. X   (set! pos x)
  792. X   (let loop ((i x))
  793. X     (cond ((>= i tab-stop)
  794. X        (display "\t")
  795. X        (loop (- i tab-stop)))
  796. X       ((> i 0)
  797. X        (display " ")
  798. X        (loop (1- i)))))))
  799. X
  800. END_OF_scm/pp
  801. if test 2757 -ne `wc -c <scm/pp`; then
  802.     echo shar: \"scm/pp\" unpacked with wrong size!
  803. fi
  804. # end of overwriting check
  805. fi
  806. if test -f scm/debug -a "${1}" != "-c" ; then 
  807.   echo shar: Will not over-write existing file \"scm/debug\"
  808. else
  809. echo shar: Extracting \"scm/debug\" \(4452 characters\)
  810. sed "s/^X//" >scm/debug <<'END_OF_scm/debug'
  811. X;;; -*-Scheme-*-
  812. X;;;
  813. X;;; A simple debugger (needs much work)
  814. X
  815. X(define (backtrace . args)
  816. X  (if (> (length args) 1)
  817. X      (error 'backtrace "too many arguments"))
  818. X  (if (not (null? args))
  819. X      (if (not (eq? (type (car args)) 'control-point))
  820. X      (error 'backtrace "argument must be a control point")))
  821. X  (let ((trace
  822. X     (apply backtrace-list args))
  823. X    (maxlen 28))
  824. X    (if (null? args)
  825. X    (set! trace (cdddr trace)))
  826. X    (for-each
  827. X     (lambda (frame)
  828. X       (let* ((func
  829. X          (format #f "~s" (vector-ref frame 0)))
  830. X         (indent 
  831. X          (- maxlen (string-length func))))
  832. X     (display func)
  833. X     (if (negative? indent)
  834. X         (begin
  835. X           (newline)
  836. X           (set! indent maxlen)))
  837. X     (do ((i indent (1- i)))
  838. X         ((> 0 i))
  839. X       (display " ")))
  840. X       (fluid-let
  841. X       ((print-depth 2)
  842. X        (print-length 3))
  843. X     (display (vector-ref frame 1)))
  844. X       (newline))
  845. X     trace))
  846. X  #v)
  847. X
  848. X(define (show env)
  849. X  (fluid-let
  850. X      ((print-length 2)
  851. X       (print-depth 2))
  852. X    (do ((f (environment->list env) (cdr f)))
  853. X    ((null? f))
  854. X      (do ((b (car f) (cdr b)))
  855. X      ((null? b))
  856. X    (format #t "~s\t~s~%" (caar b) (cdar b)))
  857. X      (print '-------)))
  858. X  #v)
  859. X
  860. X(define inspect)
  861. X
  862. X(let ((frame)
  863. X      (trace)
  864. X      (help-text
  865. X       '("q   -- quit inspector"
  866. X     "f   -- print current frame"
  867. X     "u   -- go up one frame"
  868. X     "d   -- go down one frame"
  869. X     "^   -- go to top frame"
  870. X     "$   -- go to bottom frame"
  871. X     "e   -- eval expressions in environment"
  872. X     "p   -- pretty-print procedure"
  873. X     "v   -- show environment"
  874. X     "<n> -- pretty-print n-th argument"
  875. X         "o   -- obarray information")))
  876. X  
  877. X  (define (inspect-command-loop)
  878. X    (let ((input) (done #f))
  879. X      (display "inspect> ")
  880. X      (set! input (read))
  881. X      (case input
  882. X    (q
  883. X     (set! done #t))
  884. X    (? 
  885. X     (for-each
  886. X      (lambda (msg)
  887. X        (display msg)
  888. X        (newline))
  889. X      help-text))
  890. X    (f
  891. X     (print-frame))
  892. X    (^
  893. X     (set! frame 0)
  894. X     (print-frame))
  895. X    ($
  896. X     (set! frame (1- (length trace)))
  897. X     (print-frame))
  898. X    (u
  899. X     (if (zero? frame)
  900. X         (format #t "Already on top frame.~%")
  901. X         (set! frame (1- frame))
  902. X       (print-frame)))
  903. X    (d
  904. X     (if (= frame (1- (length trace)))
  905. X         (format #t "Already on bottom frame.~%")
  906. X         (set! frame (1+ frame))
  907. X       (print-frame)))
  908. X    (v
  909. X     (show (vector-ref (list-ref trace frame) 2)))
  910. X    (e
  911. X     (format #t "Type ^D to return to Inspector.~%")
  912. X     (let loop ()
  913. X       (display "eval> ")
  914. X       (set! input (read))
  915. X       (if (not (eof-object? input))
  916. X           (begin
  917. X         (write (eval input
  918. X                  (vector-ref (list-ref trace frame) 2)))
  919. X         (newline)
  920. X         (loop))))
  921. X     (newline))
  922. X    (p
  923. X     (pp (vector-ref (list-ref trace frame) 0))
  924. X     (newline))
  925. X    (o
  926. X     (let ((l (map length (oblist))))
  927. X       (let ((n 0))
  928. X         (for-each (lambda (x) (set! n (+ x n))) l)
  929. X         (format #t "~s symbols " n)
  930. X         (format #t "(maximum bucket: ~s).~%" (apply max l)))))
  931. X    (else
  932. X     (cond
  933. X      ((integer? input)
  934. X       (let ((args (vector-ref (list-ref trace frame) 1)))
  935. X         (if (or (< input 1) (> input (length args)))
  936. X         (format #t "No such argument.~%")
  937. X         (pp (list-ref args (1- input)))
  938. X           (newline))))
  939. X      ((eof-object? input)
  940. X       (set! done #t))
  941. X      (else
  942. X       (format #t "Invalid command.  Type ? for help.~%")))))
  943. X      (if (not done)
  944. X      (inspect-command-loop))))
  945. X
  946. X  (define (print-frame)
  947. X    (format #t "~%Frame ~s of ~s:~%~%" (1+ frame) (length trace))
  948. X    (let* ((f (list-ref trace frame)) (args (vector-ref f 1)))
  949. X      (format #t "Procedure:    ~s~%" (vector-ref f 0))
  950. X      (format #t "Environment:  ~s~%" (vector-ref f 2))
  951. X      (if (null? args)
  952. X      (format #t "No arguments.~%")
  953. X      (fluid-let
  954. X          ((print-depth 2)
  955. X           (print-length 3))
  956. X        (do ((i 1 (1+ i)) (args args (cdr args))) ((null? args))
  957. X          (format #t "Argument ~s:   ~s~%" i (car args))))))
  958. X    (newline))
  959. X  
  960. X  (set! inspect
  961. X    (lambda ()
  962. X      (set! frame 0)
  963. X      (set! trace (backtrace-list))
  964. X      (set! trace (cddr trace))
  965. X      (do ((t trace (cdr t)) (f 1 (1+ f))) ((null? t))
  966. X        (if (not (null? (vector-ref (car t) 1)))
  967. X        (let ((last (last-pair (vector-ref (car t) 1))))
  968. X          (if (not (null? (cdr last)))
  969. X              (begin
  970. X            (format #t
  971. X "[inspector: fixing improper arglist in frame ~s]~%" f)
  972. X            (set-cdr! last (cons (cdr last) ())))))))
  973. X      (format #t "Inspector (type ? for help):~%")
  974. X      (let loop ((just-called #t))
  975. X        (if (call-with-current-continuation
  976. X         (lambda (control-point)
  977. X           (if just-called
  978. X               (push-frame control-point))
  979. X           (inspect-command-loop)
  980. X           #f))
  981. X        (loop #f)))
  982. X      (newline)
  983. X      (pop-frame)
  984. X      (let ((next-frame (car rep-frames)))
  985. X        (next-frame #t)))))
  986. X  
  987. END_OF_scm/debug
  988. if test 4452 -ne `wc -c <scm/debug`; then
  989.     echo shar: \"scm/debug\" unpacked with wrong size!
  990. fi
  991. # end of overwriting check
  992. fi
  993. if test -f scm/apropos -a "${1}" != "-c" ; then 
  994.   echo shar: Will not over-write existing file \"scm/apropos\"
  995. else
  996. echo shar: Extracting \"scm/apropos\" \(626 characters\)
  997. sed "s/^X//" >scm/apropos <<'END_OF_scm/apropos'
  998. X;;; -*-Scheme-*-
  999. X;;;
  1000. X;;; apropos -- print matching symbols
  1001. X
  1002. X(define apropos)
  1003. X
  1004. X(let ((found))
  1005. X
  1006. X(define (got-one sym)
  1007. X  (if (bound? sym)
  1008. X      (begin
  1009. X    (set! found #t)
  1010. X    (print sym))))
  1011. X
  1012. X(set! apropos (lambda (what)
  1013. X  (if (symbol? what)
  1014. X      (set! what (symbol->string what))
  1015. X      (if (not (string? what))
  1016. X      (error 'apropos "string or symbol expected")))
  1017. X  (set! found #f)
  1018. X  (do ((tail (oblist) (cdr tail))) ((null? tail))
  1019. X    (do ((l (car tail) (cdr l))) ((null? l))
  1020. X      (if (substring? what (symbol->string (car l)))
  1021. X      (got-one (car l)))))
  1022. X  (if (not found)
  1023. X      (format #t "~a: nothing appropriate~%" what))
  1024. X  #v)))
  1025. X    
  1026. END_OF_scm/apropos
  1027. if test 626 -ne `wc -c <scm/apropos`; then
  1028.     echo shar: \"scm/apropos\" unpacked with wrong size!
  1029. fi
  1030. # end of overwriting check
  1031. fi
  1032. if test -f scm/flame -a "${1}" != "-c" ; then 
  1033.   echo shar: Will not over-write existing file \"scm/flame\"
  1034. else
  1035. echo shar: Extracting \"scm/flame\" \(8934 characters\)
  1036. sed "s/^X//" >scm/flame <<'END_OF_scm/flame'
  1037. X;;; -*-Scheme-*-
  1038. X;;;
  1039. X;;; flame -- print a flame (ported from the Gnu-Emacs flame.el)
  1040. X
  1041. X(define flame)
  1042. X
  1043. X(let ((pos) (end-margin 55) (margin 65))
  1044. X
  1045. X(set! flame (lambda n
  1046. X    (cond ((null? n)
  1047. X       (set! n '(1)))
  1048. X      ((or (not (integer? (car n))) (negative? (car n)))
  1049. X       (error 'flame "positive integer argument expected")))
  1050. X    (set! pos 0)
  1051. X    (fluid-let ((garbage-collect-notify? #f))
  1052. X      (do ((i (car n) (1- i))) ((zero? i))
  1053. X    (if (> pos end-margin)
  1054. X        (begin
  1055. X          (set! pos 0) (newline)))
  1056. X    (flame-print #t (flatten (flame-expand '(sentence))))
  1057. X    (display "  "))
  1058. X      (newline))
  1059. X    #v))
  1060. X
  1061. X(define (flame-expand x)
  1062. X  (if (pair? x)
  1063. X      (map flame-expand ((eval (car x))))
  1064. X      x))
  1065. X
  1066. X(define (flatten x)
  1067. X  (if (pair? x)
  1068. X      (apply append (map flatten x))
  1069. X      (list x)))
  1070. X
  1071. X(define (capitalize w)
  1072. X  (display (char-upcase (string-ref w 0)))
  1073. X  (if (> (string-length w) 1)
  1074. X      (display (substring w 1 (string-length w)))))
  1075. X
  1076. X(define (flame-print first x)
  1077. X  (if (not (null? x))
  1078. X      (begin
  1079. X    (let* ((w (symbol->string (car x))) (len (string-length w)))
  1080. X      ((if first capitalize display) w)
  1081. X      (set! pos (+ 1 pos len))
  1082. X      (if (not (null? (cdr x)))
  1083. X          (begin
  1084. X        (if (not (memq (cadr x) '(? \. \, s! ! s \'s -loving)))
  1085. X            (if (< pos margin)
  1086. X            (display " ")
  1087. X            (set! pos 0) (newline)))
  1088. X        (flame-print #f (cdr x))))))))
  1089. X
  1090. X(define (choose class)
  1091. X  (list-ref class (modulo (random) (length class))))
  1092. X
  1093. X(define (sentence) (choose sentences))
  1094. X
  1095. X(define sentences
  1096. X  '((how can you say that (statement) ?)
  1097. X    (I can't believe how (adjective) you are.)
  1098. X    (only a (der-term) like you would say that (statement) \.)
  1099. X    ((statement) \, huh?) (so, (statement) ?)
  1100. X    ((statement) \, right?) (I mean, (sentence))
  1101. X    (don't you realise that (statement) ?)
  1102. X    (I firmly believe that (statement) \.)
  1103. X    (let me tell you something, you (der-term) \, (statement) \.)
  1104. X    (furthermore, you (der-term) \, (statement) \.)
  1105. X    (I couldn't care less about your (thing) \.)
  1106. X    (How can you be so (adjective) ?)
  1107. X    (you make me sick.)
  1108. X    (it's well known that (statement) \.)
  1109. X    ((statement) \.)
  1110. X    (it takes a (group-adj) (der-term) like you to say that (statement) \.)
  1111. X    (I don't want to hear about your (thing) \.)
  1112. X    (you're always totally wrong.)
  1113. X    (I've never heard anything as ridiculous as the idea that (statement) \.)
  1114. X    (you must be a real (der-term) to think that (statement) \.)
  1115. X    (you (adjective) (group-adj) (der-term) !)
  1116. X    (you're probably (group-adj) yourself.)
  1117. X    (you sound like a real (der-term) \.)
  1118. X    (why, (statement) !)
  1119. X    (I have many (group-adj) friends.)
  1120. X    (save the (thing) s!) (no nukes!) (ban (thing) s!)
  1121. X    (I'll bet you think that (thing) s are (adjective) \.)
  1122. X    (you know, (statement) \.)
  1123. X    (your (quality) reminds me of a (thing) \.)
  1124. X    (you have the (quality) of a (der-term) \.)
  1125. X    ((der-term) !)
  1126. X    ((adjective) (group-adj) (der-term) !)
  1127. X    (you're a typical (group-adj) person, totally (adjective) \.)
  1128. X    (man, (sentence))))
  1129. X
  1130. X(define (quality) (choose qualities))
  1131. X
  1132. X(define qualities
  1133. X  '((ignorance) (stupidity) (worthlessness)
  1134. X    (prejudice) (lack of intelligence) (lousiness)
  1135. X    (bad grammar) (lousy spelling)
  1136. X    (lack of common decency) (ugliness) (nastiness)
  1137. X    (subtlety) (dishonesty) ((adjective) (quality))))
  1138. X
  1139. X(define (adjective) (choose adjectives))
  1140. X
  1141. X(define adjectives
  1142. X  '((ignorant) (crass) (pathetic) (sick)
  1143. X    (bloated) (malignant) (perverted) (sadistic)
  1144. X    (stupid) (unpleasant) (lousy) (abusive) (bad)
  1145. X    (braindamaged) (selfish) (improper) (nasty)
  1146. X    (disgusting) (foul) (intolerable) (primitive)
  1147. X    (depressing) (dumb) (phoney)
  1148. X    ((adjective) and (adjective))
  1149. X    (as (adjective) as a (thing))))
  1150. X
  1151. X(define (der-term) (choose der-terms))
  1152. X
  1153. X(define der-terms
  1154. X  '(((adjective) (der-term)) (sexist) (fascist)
  1155. X    (weakling) (coward) (beast) (peasant) (racist)
  1156. X    (cretin) (fool) (jerk) (ignoramus) (idiot)
  1157. X    (wanker) (rat) (slimebag) (DAF driver)
  1158. X    (Neanderthal) (sadist) (drunk) (capitalist)
  1159. X    (wimp) (dogmatist) (wally) (maniac)
  1160. X    (whimpering scumbag) (pea brain) (arsehole)
  1161. X    (moron) (goof) (incompetant) (lunkhead) (Nazi)
  1162. X    (SysThug) ((der-term) (der-term))))
  1163. X
  1164. X(define (thing) (choose things))
  1165. X
  1166. X(define things
  1167. X  '(((adjective) (thing)) (computer)
  1168. X    (Honeywell DPS8) (whale) (operation)
  1169. X    (sexist joke) (ten-incher) (dog) (MicroVAX II)
  1170. X    (source license) (real-time clock)
  1171. X    (mental problem) (sexual fantasy)
  1172. X    (venereal disease) (Jewish grandmother)
  1173. X    (cardboard cut-out) (punk haircut) (surfboard)
  1174. X    (system call) (wood-burning stove)
  1175. X    (graphics editor) (right wing death squad)
  1176. X    (disease) (vegetable) (religion)
  1177. X    (cruise missile) (bug fix) (lawyer) (copyright)
  1178. X    (PAD)))
  1179. X
  1180. X(define (group-adj) (choose group-adjs))
  1181. X
  1182. X(define group-adjs
  1183. X  '((gay) (old) (lesbian) (young) (black)
  1184. X    (Polish) ((adjective)) (white)
  1185. X    (mentally retarded) (Nicaraguan) (homosexual)
  1186. X    (dead) (underpriviledged) (religious)
  1187. X    ((thing) -loving) (feminist) (foreign)
  1188. X    (intellectual) (crazy) (working) (unborn)
  1189. X    (Chinese) (short) ((adjective)) (poor) (rich)
  1190. X    (funny-looking) (Puerto Rican) (Mexican)
  1191. X    (Italian) (communist) (fascist) (Iranian)
  1192. X    (Moonie)))
  1193. X
  1194. X(define (statement) (choose statements))
  1195. X
  1196. X(define statements
  1197. X  '((your (thing) is great) ((thing) s are fun)
  1198. X    ((person) is a (der-term))
  1199. X    ((group-adj) people are (adjective))
  1200. X    (every (group-adj) person is a (der-term))
  1201. X    (most (group-adj) people have (thing) s)
  1202. X    (all (group-adj) dudes should get (thing) s)
  1203. X    ((person) is (group-adj)) (trees are (adjective))
  1204. X    (if you've seen one (thing) \, you've seen them all)
  1205. X    (you're (group-adj)) (you have a (thing))
  1206. X    (my (thing) is pretty good)
  1207. X    (the Martians are coming)
  1208. X    (the (paper) is always right)
  1209. X    (just because you read it in the (paper) that doesn't mean it's true)
  1210. X    ((person) was (group-adj))
  1211. X    ((person) \'s ghost is living in your (thing))
  1212. X    (you look like a (thing))
  1213. X    (the oceans are full of dirty fish)
  1214. X    (people are dying every day)
  1215. X    (a (group-adj) man ain't got nothing in the world these days)
  1216. X    (women are inherently superior to men)
  1217. X    (the system staff is fascist)
  1218. X    (there is life after death)
  1219. X    (the world is full of (der-term) s)
  1220. X    (you remind me of (person)) (technology is evil)
  1221. X    ((person) killed (person))
  1222. X    (the Russians are tapping your phone)
  1223. X    (the Earth is flat)
  1224. X    (it's OK to run down (group-adj) people)
  1225. X    (Multics is a really (adjective) operating system)
  1226. X    (the CIA killed (person))
  1227. X    (the sexual revolution is over)
  1228. X    (Lassie was (group-adj))
  1229. X    (the (group-adj) s have really got it all together)
  1230. X    (I was (person) in a previous life)
  1231. X    (breathing causes cancer)
  1232. X    (it's fun to be really (adjective))
  1233. X    ((quality) is pretty fun) (you're a (der-term))
  1234. X    (the (group-adj) culture is fascinating)
  1235. X    (when ya gotta go ya gotta go)
  1236. X    ((person) is (adjective))
  1237. X    ((person) \'s (quality) is (adjective))
  1238. X    (it's a wonderful day)
  1239. X    (everything is really a (thing))
  1240. X    (there's a (thing) in (person) \'s brain)
  1241. X    ((person) is a cool dude)
  1242. X    ((person) is just a figment of your imagination)
  1243. X    (the more (thing) s you have, the better)
  1244. X    (life is a (thing)) (life is (quality))
  1245. X    ((person) is (adjective))
  1246. X    ((group-adj) people are all (adjective) (der-term) s)
  1247. X    ((statement) \, and (statement))
  1248. X    ((statement) \, but (statement))
  1249. X    (I wish I had a (thing))
  1250. X    (you should have a (thing))
  1251. X    (you hope that (statement))
  1252. X    ((person) is secretly (group-adj))
  1253. X    (you wish you were (group-adj))
  1254. X    (you wish you were a (thing))
  1255. X    (I wish I were a (thing))
  1256. X    (you think that (statement))
  1257. X    ((statement) \, because (statement))
  1258. X    ((group-adj) people don't get married to (group-adj) people because (reason))
  1259. X    ((group-adj) people are all (adjective) because (reason))
  1260. X    ((group-adj) people are (adjective) \, and (reason))
  1261. X    (you must be a (adjective) (der-term) to think that (person) said (statement))
  1262. X    ((group-adj) people are inherently superior to (group-adj) people)
  1263. X    (God is Dead)))
  1264. X
  1265. X(define (paper) (choose papers))
  1266. X
  1267. X(define papers
  1268. X  '((Daily Mail) (Daily Express)
  1269. X    (Centre Bulletin) (Sun) (Daily Mirror)
  1270. X    (Daily Telegraph) (Beano) (Multics Manual)))
  1271. X
  1272. X(define (person) (choose persons))
  1273. X
  1274. X(define persons
  1275. X  '((Reagan) (Ken Thompson) (Dennis Ritchie)
  1276. X    (JFK) (the Pope) (Gadaffi) (Napoleon)
  1277. X    (Karl Marx) (Groucho) (Michael Jackson)
  1278. X    (Caesar) (Nietzsche) (Heidegger)
  1279. X    (Henry Kissinger) (Nixon) (Castro) (Thatcher)
  1280. X    (Attilla the Hun) (Alaric the Visigoth) (Hitler)))
  1281. X
  1282. X(define (reason) (choose reasons))
  1283. X
  1284. X(define reasons
  1285. X  '((they don't want their children to grow up to be too lazy to steal)
  1286. X    (they can't tell them apart from (group-adj) dudes)
  1287. X    (they're too (adjective))
  1288. X    ((person) wouldn't have done it)
  1289. X    (they can't spray paint that small)
  1290. X    (they don't have (thing) s) (they don't know how)
  1291. X    (they can't afford (thing) s)))
  1292. X)
  1293. END_OF_scm/flame
  1294. if test 8934 -ne `wc -c <scm/flame`; then
  1295.     echo shar: \"scm/flame\" unpacked with wrong size!
  1296. fi
  1297. # end of overwriting check
  1298. fi
  1299. if test -f scm/macros -a "${1}" != "-c" ; then 
  1300.   echo shar: Will not over-write existing file \"scm/macros\"
  1301. else
  1302. echo shar: Extracting \"scm/macros\" \(894 characters\)
  1303. sed "s/^X//" >scm/macros <<'END_OF_scm/macros'
  1304. X;;; -*-Scheme-*-
  1305. X;;;
  1306. X;;; Useful macros (loaded by the standard toplevel)
  1307. X
  1308. X(provide 'macros)
  1309. X
  1310. X(define (expand form)
  1311. X  (if (or (not (pair? form)) (null? form))
  1312. X      form
  1313. X      (let ((head (expand (car form))) (args (expand (cdr form))) (result))
  1314. X    (if (and (symbol? head) (bound? head))
  1315. X        (begin
  1316. X          (set! result (macro-expand (cons head args)))
  1317. X          (if (not (equal? result form))
  1318. X          (expand result)
  1319. X          result))
  1320. X        (cons head args)))))
  1321. X
  1322. X(define-macro (unwind-protect body . unwind-forms)
  1323. X  `(dynamic-wind
  1324. X    (lambda () #f)
  1325. X    (lambda () ,body)
  1326. X    (lambda () ,@unwind-forms)))
  1327. X
  1328. X(define-macro (while test . body)
  1329. X  `(let loop ()
  1330. X     (cond (,test ,@body (loop)))))
  1331. X
  1332. X(define-macro (when test . body)
  1333. X  `(and ,test ,@body))
  1334. X
  1335. X(define-macro (unless test . body)
  1336. X  `(when (not ,test) ,@body))
  1337. X
  1338. X(define-macro (multiple-value-bind vars form . body)
  1339. X  `(apply (lambda ,vars ,@body) ,form))
  1340. END_OF_scm/macros
  1341. if test 894 -ne `wc -c <scm/macros`; then
  1342.     echo shar: \"scm/macros\" unpacked with wrong size!
  1343. fi
  1344. # end of overwriting check
  1345. fi
  1346. if test -f scm/qsort -a "${1}" != "-c" ; then 
  1347.   echo shar: Will not over-write existing file \"scm/qsort\"
  1348. else
  1349. echo shar: Extracting \"scm/qsort\" \(845 characters\)
  1350. sed "s/^X//" >scm/qsort <<'END_OF_scm/qsort'
  1351. X;;; -*-Scheme-*-
  1352. X;;;
  1353. X;;; Quicksort (straight from Wirth, Algorithmen & Datenstrukturen, p. 117)
  1354. X
  1355. X(provide 'sort)
  1356. X
  1357. X(define (sort obj pred)
  1358. X  (if (vector? obj)
  1359. X      (sort! (vector-copy obj) pred)
  1360. X      (vector->list (sort! (list->vector obj) pred))))
  1361. X
  1362. X(define (sort! v pred)
  1363. X  (define (internal-sort l r)
  1364. X    (let ((i l) (j r) (x (vector-ref v (quotient (1- (+ l r)) 2))))
  1365. X      (let loop ()
  1366. X    (do () ((not (pred (vector-ref v i) x))) (set! i (1+ i)))
  1367. X    (do () ((not (pred x (vector-ref v j)))) (set! j (1- j)))
  1368. X    (if (<= i j)
  1369. X        (begin
  1370. X          (vector-set! v j (vector-set! v i (vector-ref v j)))
  1371. X          (set! i (1+ i))
  1372. X          (set! j (1- j))))
  1373. X    (if (<= i j)
  1374. X        (loop)))
  1375. X      (if (< l j)
  1376. X      (internal-sort l j))
  1377. X      (if (< i r)
  1378. X      (internal-sort i r))))
  1379. X  (let ((len (vector-length v)))
  1380. X    (if (> len 1)
  1381. X    (internal-sort 0 (1- len)))
  1382. X    v))
  1383. END_OF_scm/qsort
  1384. if test 845 -ne `wc -c <scm/qsort`; then
  1385.     echo shar: \"scm/qsort\" unpacked with wrong size!
  1386. fi
  1387. # end of overwriting check
  1388. fi
  1389. if test -f scm/toplevel.simple -a "${1}" != "-c" ; then 
  1390.   echo shar: Will not over-write existing file \"scm/toplevel.simple\"
  1391. else
  1392. echo shar: Extracting \"scm/toplevel.simple\" \(643 characters\)
  1393. sed "s/^X//" >scm/toplevel.simple <<'END_OF_scm/toplevel.simple'
  1394. X;;; -*-Scheme-*-
  1395. X;;;
  1396. X;;; Simple and stupid read-eval-print loop (for testing purposes)
  1397. X
  1398. X(define (top-level)
  1399. X  (letrec ((top-level-input)
  1400. X       (top-level-prompt "> ")
  1401. X       (top-level-environment (the-environment)))
  1402. X
  1403. X    (do () ((eof-object? top-level-input))
  1404. X      (call-with-current-continuation
  1405. X       (lambda (control-point)
  1406. X     (set! top-level-control-point control-point)
  1407. X     (do () ((eof-object? top-level-input))
  1408. X       (display top-level-prompt)
  1409. X       (set! top-level-input (read))
  1410. X       (if (eof-object? top-level-input)
  1411. X           (begin
  1412. X         (newline) (exit)))
  1413. X       (write (eval top-level-input top-level-environment))
  1414. X       (newline)))))))
  1415. X
  1416. X(top-level)
  1417. END_OF_scm/toplevel.simple
  1418. if test 643 -ne `wc -c <scm/toplevel.simple`; then
  1419.     echo shar: \"scm/toplevel.simple\" unpacked with wrong size!
  1420. fi
  1421. # end of overwriting check
  1422. fi
  1423. if test -f scm/qsort.mit -a "${1}" != "-c" ; then 
  1424.   echo shar: Will not over-write existing file \"scm/qsort.mit\"
  1425. else
  1426. echo shar: Extracting \"scm/qsort.mit\" \(1377 characters\)
  1427. sed "s/^X//" >scm/qsort.mit <<'END_OF_scm/qsort.mit'
  1428. X;;; -*-Scheme-*-
  1429. X;;;
  1430. X;;; Another quicksort (stolen from C-Scheme)
  1431. X
  1432. X(define (sort obj pred)
  1433. X  (if (vector? obj)
  1434. X      (sort! (vector-copy obj) pred)
  1435. X      (vector->list (sort! (list->vector obj) pred))))
  1436. X
  1437. X(define sort!
  1438. X  (let ()
  1439. X    
  1440. X    (define (exchange! vec i j)
  1441. X      ;; Speedup hack uses value of vector-set!.
  1442. X      (vector-set! vec j (vector-set! vec i (vector-ref vec j))))
  1443. X    
  1444. X    (lambda (obj pred)
  1445. X      (define (sort-internal! vec l r)
  1446. X    (cond
  1447. X     ((<= r l)
  1448. X      vec)
  1449. X     ((= r (1+ l)) 
  1450. X      (if (pred (vector-ref vec r)
  1451. X            (vector-ref vec l))
  1452. X          (exchange! vec l r)
  1453. X          vec))
  1454. X     (else
  1455. X      (quick-merge vec l r))))
  1456. X      
  1457. X      (define (quick-merge vec l r)
  1458. X    (let ((first (vector-ref vec l)))
  1459. X      (define (increase-i i)
  1460. X        (if (or (> i r)
  1461. X            (pred first (vector-ref vec i)))
  1462. X        i
  1463. X        (increase-i (1+ i))))
  1464. X      (define (decrease-j j)
  1465. X        (if (or (<= j l)
  1466. X            (not (pred first (vector-ref vec j))))
  1467. X        j
  1468. X        (decrease-j (1- j))))
  1469. X      (define (loop i j)
  1470. X        (if (< i j)
  1471. X        (begin (exchange! vec i j)
  1472. X               (loop (increase-i (1+ i)) (decrease-j (1- j))))
  1473. X        (begin
  1474. X          (cond ((> j l)
  1475. X             (exchange! vec j l)))
  1476. X          (sort-internal! vec (1+ j) r)
  1477. X          (sort-internal! vec l (1- j)))))
  1478. X      (loop (increase-i (1+ l))
  1479. X        (decrease-j r))))
  1480. X      
  1481. X      (if (vector? obj)
  1482. X      (begin (sort-internal! obj 0 (1- (vector-length obj))) obj)
  1483. X      (error 'sort! "works on vectors only")))))
  1484. END_OF_scm/qsort.mit
  1485. if test 1377 -ne `wc -c <scm/qsort.mit`; then
  1486.     echo shar: \"scm/qsort.mit\" unpacked with wrong size!
  1487. fi
  1488. # end of overwriting check
  1489. fi
  1490. if test -f scm/struct -a "${1}" != "-c" ; then 
  1491.   echo shar: Will not over-write existing file \"scm/struct\"
  1492. else
  1493. echo shar: Extracting \"scm/struct\" \(3423 characters\)
  1494. sed "s/^X//" >scm/struct <<'END_OF_scm/struct'
  1495. X;;; -*-Scheme-*-
  1496. X;;;
  1497. X;;; The Scheme part of the structures implementation
  1498. X;;;
  1499. X;;; (define-structure name slot slot ...)
  1500. X;;;
  1501. X;;; slot  =  slot-name  or  (slot-name initial-value)
  1502. X
  1503. X(require 'structures 'struct.o)
  1504. X
  1505. X(define-macro (define-structure name . slot-descr)
  1506. X  (if (not (symbol? name))
  1507. X      (error 'define-structure "structure name must be a symbol"))
  1508. X  (if (null? slot-descr)
  1509. X      (error 'define-structure "structure has no slots"))
  1510. X  (let* ((s (symbol->string name))
  1511. X     (constructor
  1512. X      (string->symbol (string-append "make-" s)))
  1513. X     (predicator
  1514. X      (string->symbol (string-append s "?")))
  1515. X     (copier
  1516. X      (string->symbol (string-append "copy-" s)))
  1517. X     (slots ()) (arg-slots ()))
  1518. X    (for-each
  1519. X     (lambda (slot)
  1520. X       (cond ((symbol? slot)
  1521. X          (set! slots (cons slot slots))
  1522. X          (set! arg-slots (cons slot arg-slots)))
  1523. X         ((pair? slot)
  1524. X          (if (or (not (pair? (cdr slot)))
  1525. X              (not (null? (cddr slot))))
  1526. X          (error 'define-structure "invalid slot specification")
  1527. X          (if (not (symbol? (car slot)))
  1528. X              (error 'define-structure "slot name must be a symbol"))
  1529. X          (set! slots (cons (car slot) slots))))
  1530. X         (else
  1531. X          (error 'define-structure "slot must be symbol or list"))))
  1532. X     slot-descr)
  1533. X    (set! slots (reverse slots))
  1534. X    `(begin
  1535. X       (make-constructor ,constructor ,name ,slots
  1536. X             ,(reverse arg-slots) ,slot-descr)
  1537. X       (make-predicator ,predicator ',name)
  1538. X       (make-copier ,copier)
  1539. X       ,@(let ((offset -1))
  1540. X       (map
  1541. X        (lambda (slot)
  1542. X          (let ((f
  1543. X             (string->symbol (format #f "~s-~s" name slot))))
  1544. X            (set! offset (1+ offset))
  1545. X            `(make-accessor ,f ',name ,offset)))
  1546. X        slots))
  1547. X       ,@(let ((offset -1))
  1548. X       (map
  1549. X        (lambda (slot)
  1550. X          (let ((f
  1551. X             (string->symbol (format #f "set-~s-~s!" name slot))))
  1552. X        (set! offset (1+ offset))
  1553. X        `(make-mutator ,f ',name ,offset)))
  1554. X        slots))
  1555. X       ',name)))
  1556. X
  1557. X(define-macro (make-constructor constructor name slots arg-slots descr)
  1558. X  `(define (,constructor ,@arg-slots)
  1559. X     (let ((,name (make-structure ',name ',slots)))
  1560. X       ,@(let ((offset -1))
  1561. X       (map
  1562. X        (lambda (slot)
  1563. X          (set! offset (1+ offset))
  1564. X          `(structure-set! ,name ',name ,offset
  1565. X                   ,(if (symbol? slot)
  1566. X                    slot
  1567. X                    (cadr slot))))
  1568. X        descr))
  1569. X       ,name)))
  1570. X       
  1571. X(define-macro (make-predicator predicator name)
  1572. X  `(define (,predicator x)
  1573. X     (and (structure? x) (eq? (structure-name x) ,name))))
  1574. X
  1575. X(define-macro (make-copier copier)
  1576. X  `(define (,copier x)
  1577. X     (copy-structure x)))
  1578. X
  1579. X(define-macro (make-accessor accessor name offset)
  1580. X  `(define (,accessor x)
  1581. X     (structure-ref x ,name ,offset)))
  1582. X
  1583. X(define-macro (make-mutator mutator name offset)
  1584. X  `(define (,mutator x val)
  1585. X     (structure-set! x ,name ,offset val)))
  1586. X
  1587. X(define (copy-structure s)
  1588. X  (let* ((slots (structure-slots s))
  1589. X     (name (structure-name s))
  1590. X     (new (make-structure name slots))
  1591. X     (size (length slots)))
  1592. X    (do ((offset 0 (1+ offset))) ((= offset size) new)
  1593. X      (structure-set! new name offset (structure-ref s name offset)))))
  1594. X
  1595. X(define (describe-structure s)
  1596. X  (format #t "a structure of type ~s.~%" (structure-name s))
  1597. X  (if (null? (structure-slots s))
  1598. X      (format #t "It has no slots.~%")
  1599. X      (format #t "Its slots are: ")
  1600. X      (let loop ((slots (structure-slots s))
  1601. X         (values (structure-values s)))
  1602. X    (if (null? slots)
  1603. X        (format #t ".~%")
  1604. X        (format #t " (~s ~s)" (car slots) (car values))
  1605. X        (loop (cdr slots) (cdr values))))))
  1606. END_OF_scm/struct
  1607. if test 3423 -ne `wc -c <scm/struct`; then
  1608.     echo shar: \"scm/struct\" unpacked with wrong size!
  1609. fi
  1610. # end of overwriting check
  1611. fi
  1612. if test -f scm/describe -a "${1}" != "-c" ; then 
  1613.   echo shar: Will not over-write existing file \"scm/describe\"
  1614. else
  1615. echo shar: Extracting \"scm/describe\" \(2209 characters\)
  1616. sed "s/^X//" >scm/describe <<'END_OF_scm/describe'
  1617. X;;; -*-Scheme-*-
  1618. X;;;
  1619. X;;; describe -- print information about a Scheme object
  1620. X
  1621. X(define (describe x)
  1622. X  (fluid-let
  1623. X      ((print-depth 2)
  1624. X       (print-length 3))
  1625. X    (format #t "~s is " (if (void? x) '\#v x)))
  1626. X  (case (type x)
  1627. X    (integer
  1628. X     (format #t "an integer.~%"))
  1629. X    (real
  1630. X     (format #t "a real.~%"))
  1631. X    (null
  1632. X     (format #t "an empty list.~%"))
  1633. X    (boolean
  1634. X     (format #t "a boolean value (~s).~%" (if x 'true 'false)))
  1635. X    (void
  1636. X     (format #t "void (the non-printing object).~%"))
  1637. X    (character
  1638. X     (format #t "a character, ascii value is ~s~%" (char->integer x)))
  1639. X    (symbol
  1640. X     (format #t "a symbol.")
  1641. X     (let ((l (symbol-plist x)))
  1642. X       (if (null? l)
  1643. X       (format #t "  It has no property list.~%")
  1644. X       (format #t "~%Its property list is: ~s.~%" l))))
  1645. X    (pair
  1646. X     (if (pair? (cdr x))
  1647. X     (let ((p (last-pair x)))
  1648. X       (if (null? (cdr p))
  1649. X           (format #t "a list of length ~s.~%" (length x))
  1650. X           (format #t "an improper list.~%")))
  1651. X     (format #t "a pair (cons cell).~%")))
  1652. X    (environment
  1653. X     (format #t "an environment.~%"))
  1654. X    (string
  1655. X     (if (eqv? x "")
  1656. X     (format #t "an empty string.~%")
  1657. X     (format #t "a string of length ~s.~%" (string-length x))))
  1658. X    (vector
  1659. X     (if (eqv? x #())
  1660. X     (format #t "an empty vector.~%")
  1661. X     (if (and (feature? 'oops) (memq (vector-ref x 0)
  1662. X                     '(class instance)))
  1663. X         (if (eq? (vector-ref x 0) 'class)
  1664. X         (begin
  1665. X           (format #t "a class.~%~%")
  1666. X           (describe-class x))
  1667. X         (format #t "an instance.~%~%")
  1668. X         (describe-instance x))
  1669. X         (format #t "a vector of length ~s.~%" (vector-length x)))))
  1670. X    (primitive
  1671. X     (format #t "a primitive procedure.~%"))
  1672. X    (compound
  1673. X     (format #t "a compound procedure (type ~s).~%"
  1674. X         (car (procedure-lambda x))))
  1675. X    (control-point
  1676. X     (format #t "a control point (continuation).~%"))
  1677. X    (promise
  1678. X     (format #t "a promise.~%"))
  1679. X    (port
  1680. X     (format #t "a port.~%"))
  1681. X    (end-of-file
  1682. X     (format #t "the end-of-file object.~%"))
  1683. X    (macro
  1684. X      (format #t "a macro.~%"))
  1685. X    (else
  1686. X     (let ((descr-func (string->symbol
  1687. X            (format #f "describe-~s" (type x)))))
  1688. X       (if (bound? descr-func)
  1689. X       ((eval descr-func) x)
  1690. X       (format #t "an object of unknown type (~s)~%" (type x)))))))
  1691. X
  1692. END_OF_scm/describe
  1693. if test 2209 -ne `wc -c <scm/describe`; then
  1694.     echo shar: \"scm/describe\" unpacked with wrong size!
  1695. fi
  1696. # end of overwriting check
  1697. fi
  1698. if test -f scm/oda -a "${1}" != "-c" ; then 
  1699.   echo shar: Will not over-write existing file \"scm/oda\"
  1700. else
  1701. echo shar: Extracting \"scm/oda\" \(903 characters\)
  1702. sed "s/^X//" >scm/oda <<'END_OF_scm/oda'
  1703. X;;; -*-Scheme-*-
  1704. X;;;
  1705. X;;; Useful hacks for the ISOTEXT project
  1706. X
  1707. X(define-macro (load* first . rest)
  1708. X  (let loop ((s "") (r rest))
  1709. X    (if (pair? r)
  1710. X    (loop
  1711. X     (string-append s (find-object-file (eval (car r))) " ") (cdr r))
  1712. X    `(fluid-let
  1713. X        ((load-libraries
  1714. X          (string-append ,s "-lC " load-libraries)))
  1715. X       (load ,first)))))
  1716. X
  1717. X(define-macro (stringify s)
  1718. X  `(if (symbol? ,s) (symbol->string ,s) ,s))
  1719. X
  1720. X(define (find-object-file f)
  1721. X  (if (not (or (symbol? f) (string? f)))
  1722. X      (error 'load* "file name must be string or symbol"))
  1723. X  (set! f (stringify f))
  1724. X  (if (eqv? f "")
  1725. X      (error 'load* "invalid filename"))
  1726. X  (set! f (tilde-expand f))
  1727. X  (if (eq? #\/ (string-ref f 0))
  1728. X      f
  1729. X      (let loop ((p load-path))
  1730. X    (if (null? p)
  1731. X        (error 'load* "no such load file: ~s" f))
  1732. X    (let ((ret (format #f "~a/~a" (stringify (car p)) f)))
  1733. X      (if (file-exists? ret)
  1734. X          ret
  1735. X          (loop (cdr p)))))))
  1736. X    
  1737. END_OF_scm/oda
  1738. if test 903 -ne `wc -c <scm/oda`; then
  1739.     echo shar: \"scm/oda\" unpacked with wrong size!
  1740. fi
  1741. # end of overwriting check
  1742. fi
  1743. if test -f scm/cscheme -a "${1}" != "-c" ; then 
  1744.   echo shar: Will not over-write existing file \"scm/cscheme\"
  1745. else
  1746. echo shar: Extracting \"scm/cscheme\" \(2920 characters\)
  1747. sed "s/^X//" >scm/cscheme <<'END_OF_scm/cscheme'
  1748. X;;; -*-Scheme-*-
  1749. X;;;
  1750. X;;; Some C-Scheme compatibility hacks
  1751. X
  1752. X(provide 'cscheme)
  1753. X
  1754. X(define-macro (syntax-table-define table name mac)
  1755. X  `(define ,(eval name) ,mac))
  1756. X
  1757. X(define mapcar map)
  1758. X
  1759. X(define user-initial-environment (global-environment))
  1760. X
  1761. X(define (rep-environment) (global-environment))
  1762. X
  1763. X(define (atom? x)
  1764. X  (not (pair? x)))
  1765. X
  1766. X(define nil ())
  1767. X
  1768. X(define *the-non-printing-object* #v)
  1769. X
  1770. X(define (integer->string i)
  1771. X  (format #f "~s" i))
  1772. X
  1773. X(define (get* sym prop)
  1774. X  (let ((ret (get sym prop)))
  1775. X    (if ret ret ())))
  1776. X
  1777. X(define-macro (access sym env)
  1778. X  `(eval ',sym ,env))
  1779. X
  1780. X(define-macro (in-package env . body)
  1781. X  `(eval '(begin ,@body) ,env))
  1782. X
  1783. X(define-macro (without-interrupts thunk)
  1784. X  `(,thunk))
  1785. X
  1786. X(define-macro (rec var exp)
  1787. X  `(letrec ((,var ,exp)) ,exp))
  1788. X
  1789. X(define (caaaar x) (car (caaar x)))
  1790. X(define (caaadr x) (car (caadr x)))
  1791. X(define (caadar x) (car (cadar x)))
  1792. X(define (caaddr x) (car (caddr x)))
  1793. X(define (cadaar x) (car (cdaar x)))
  1794. X(define (cadadr x) (car (cdadr x)))
  1795. X(define (caddar x) (car (cddar x)))
  1796. X(define (cadddr x) (car (cdddr x)))
  1797. X(define (cdaaar x) (cdr (caaar x)))
  1798. X(define (cdaadr x) (cdr (caadr x)))
  1799. X(define (cdadar x) (cdr (cadar x)))
  1800. X(define (cdaddr x) (cdr (caddr x)))
  1801. X(define (cddaar x) (cdr (cdaar x)))
  1802. X(define (cddadr x) (cdr (cdadr x)))
  1803. X(define (cdddar x) (cdr (cddar x)))
  1804. X(define (cddddr x) (cdr (cdddr x)))
  1805. X
  1806. X(define (cons* first . rest)
  1807. X  (let loop ((curr first) (rest rest))
  1808. X    (if (null? rest)
  1809. X    curr
  1810. X    (cons curr (loop (car rest) (cdr rest))))))
  1811. X
  1812. X(define sequence begin)
  1813. X
  1814. X(define -1+ 1-)
  1815. X
  1816. X(define close-input-port close-port)
  1817. X(define close-output-port close-port)
  1818. X
  1819. X(define (remq x y)
  1820. X  (cond ((null? y) y)
  1821. X    ((eq? x (car y)) (remq x (cdr y)))
  1822. X    (else (cons (car y) (remq x (cdr y))))))
  1823. X
  1824. X(define (remv x y)
  1825. X  (cond ((null? y) y)
  1826. X    ((eqv? x (car y)) (remv x (cdr y)))
  1827. X    (else (cons (car y) (remv x (cdr y))))))
  1828. X
  1829. X(define (remove x y)
  1830. X  (cond ((null? y) y)
  1831. X    ((equal? x (car y)) (remove x (cdr y)))
  1832. X    (else (cons (car y) (remove x (cdr y))))))
  1833. X
  1834. X(define (remq! x y)
  1835. X  (cond ((null? y) y)
  1836. X    ((eq? x (car y)) (remq! x (cdr y)))
  1837. X    (else (let loop ((prev y))
  1838. X        (cond ((null? (cdr prev))
  1839. X               y)
  1840. X              ((eq? (cadr prev) x)
  1841. X               (set-cdr! prev (cddr prev))
  1842. X               (loop prev))
  1843. X              (else (loop (cdr prev))))))))
  1844. X
  1845. X(define (remv! x y)
  1846. X  (cond ((null? y) y)
  1847. X    ((eqv? x (car y)) (remv! x (cdr y)))
  1848. X    (else (let loop ((prev y))
  1849. X        (cond ((null? (cdr prev))
  1850. X               y)
  1851. X              ((eqv? (cadr prev) x)
  1852. X               (set-cdr! prev (cddr prev))
  1853. X               (loop prev))
  1854. X              (else (loop (cdr prev))))))))
  1855. X
  1856. X(define (remove! x y)
  1857. X  (cond ((null? y) y)
  1858. X    ((equal? x (car y)) (remove! x (cdr y)))
  1859. X    (else (let loop ((prev y))
  1860. X        (cond ((null? (cdr prev))
  1861. X               y)
  1862. X              ((equal? (cadr prev) x)
  1863. X               (set-cdr! prev (cddr prev))
  1864. X               (loop prev))
  1865. X              (else (loop (cdr prev))))))))
  1866. X
  1867. X(define delq remq)
  1868. X(define delv remv)
  1869. X(define delete remove)
  1870. X(define delq! remq!)
  1871. X(define delv! remv!)
  1872. X(define delete! remove!)
  1873. END_OF_scm/cscheme
  1874. if test 2920 -ne `wc -c <scm/cscheme`; then
  1875.     echo shar: \"scm/cscheme\" unpacked with wrong size!
  1876. fi
  1877. # end of overwriting check
  1878. fi
  1879. if test -f scm/xlib -a "${1}" != "-c" ; then 
  1880.   echo shar: Will not over-write existing file \"scm/xlib\"
  1881. else
  1882. echo shar: Extracting \"scm/xlib\" \(207 characters\)
  1883. sed "s/^X//" >scm/xlib <<'END_OF_scm/xlib'
  1884. X;;; -*-Scheme-*-
  1885. X;;;
  1886. X;;; The Scheme part of the X11 interface
  1887. X
  1888. X(require 'xlib.o)
  1889. X
  1890. X(load 'xlib.core)
  1891. X(load 'xlib.more)
  1892. X
  1893. X(append! load-path (list (string-append top-dir "lib/xlib/examples")))
  1894. X
  1895. X(provide 'xlib)
  1896. END_OF_scm/xlib
  1897. if test 207 -ne `wc -c <scm/xlib`; then
  1898.     echo shar: \"scm/xlib\" unpacked with wrong size!
  1899. fi
  1900. # end of overwriting check
  1901. fi
  1902. if test -f scm/setf -a "${1}" != "-c" ; then 
  1903.   echo shar: Will not over-write existing file \"scm/setf\"
  1904. else
  1905. echo shar: Extracting \"scm/setf\" \(593 characters\)
  1906. sed "s/^X//" >scm/setf <<'END_OF_scm/setf'
  1907. X;;; -*-Scheme-*-
  1908. X;;;
  1909. X;;; defsetf and setf
  1910. X
  1911. X(define defsetf)
  1912. X(define get-setter)
  1913. X
  1914. X(let ((setters ()))
  1915. X
  1916. X  (set! defsetf
  1917. X    (lambda (accessor setter)
  1918. X      (set! setters (cons (cons accessor setter) setters))
  1919. X      #v))
  1920. X
  1921. X  (set! get-setter
  1922. X    (lambda (accessor)
  1923. X      (let ((a (assoc accessor setters)))
  1924. X        (if a
  1925. X        (cdr a)
  1926. X        (error 'get-setter "no setter for ~s" accessor))))))
  1927. X
  1928. X(define-macro (setf var val)
  1929. X  (cond
  1930. X   ((symbol? var) `(set! ,var ,val))
  1931. X   ((pair? var)
  1932. X    (let ((setter (get-setter (eval (car var)))))
  1933. X      `(,setter ,@(cdr var) ,val)))
  1934. X   (else (error 'setf "symbol or form expected"))))
  1935. END_OF_scm/setf
  1936. if test 593 -ne `wc -c <scm/setf`; then
  1937.     echo shar: \"scm/setf\" unpacked with wrong size!
  1938. fi
  1939. # end of overwriting check
  1940. fi
  1941. if test -f scm/gray -a "${1}" != "-c" ; then 
  1942.   echo shar: Will not over-write existing file \"scm/gray\"
  1943. else
  1944. echo shar: Extracting \"scm/gray\" \(72 characters\)
  1945. sed "s/^X//" >scm/gray <<'END_OF_scm/gray'
  1946. X;;; -*-Scheme-*-
  1947. X
  1948. X(define gray-bits "\125\125\252\252\125\125\252\252")
  1949. END_OF_scm/gray
  1950. if test 72 -ne `wc -c <scm/gray`; then
  1951.     echo shar: \"scm/gray\" unpacked with wrong size!
  1952. fi
  1953. # end of overwriting check
  1954. fi
  1955. if test -f scm/xlib.more -a "${1}" != "-c" ; then 
  1956.   echo shar: Will not over-write existing file \"scm/xlib.more\"
  1957. else
  1958. echo shar: Extracting \"scm/xlib.more\" \(2166 characters\)
  1959. sed "s/^X//" >scm/xlib.more <<'END_OF_scm/xlib.more'
  1960. X;;; -*-Scheme-*-
  1961. X;;;
  1962. X;;; X11 interface
  1963. X
  1964. X(require 'xlib.o)
  1965. X
  1966. X(define (translate-text string)
  1967. X  (list->vector (map char->integer (string->list string))))
  1968. X
  1969. X(define (drawable? d)
  1970. X  (or (window? d) (pixmap? d)))
  1971. X
  1972. X(define (clear-window w)
  1973. X  (clear-area w 0 0 0 0 #f))
  1974. X
  1975. X(define (define-cursor w c)
  1976. X  (set-window-cursor! w c))
  1977. X
  1978. X(define (undefine-cursor w)
  1979. X  (set-window-cursor! w 'none))
  1980. X
  1981. X(define (create-font-cursor dpy which)
  1982. X  (let ((font (open-font dpy 'cursor)))
  1983. X    (unwind-protect
  1984. X     (create-glyph-cursor font which font (1+ which)
  1985. X              (make-color 0 0 0) (make-color 1 1 1))
  1986. X     (close-font font))))
  1987. X
  1988. X(define (synchronize d)
  1989. X  (set-after-function! d (lambda (d) (display-wait-output d #f))))
  1990. X
  1991. X(define (font-property font prop)
  1992. X  (let* ((dpy (font-display font))
  1993. X    (atom (intern-atom dpy prop))
  1994. X    (properties (vector->list (font-properties font)))
  1995. X    (result (assq atom properties)))
  1996. X    (if result
  1997. X    (cdr result)
  1998. X    result)))
  1999. X
  2000. X(define-macro (with-server-grabbed dpy . body)
  2001. X  `(dynamic-wind
  2002. X    (lambda () (grab-server ,dpy))
  2003. X    (lambda () ,@body)
  2004. X    (lambda () (ungrab-server ,dpy))))
  2005. X
  2006. X(define (warp-pointer dst dst-x dst-y)
  2007. X  (general-warp-pointer (window-display dst) dst dst-x dst-y 'none 0 0 0 0))
  2008. X
  2009. X(define (warp-pointer-relative dpy x-off y-off)
  2010. X  (general-warp-pointer dpy 'none x-off y-off 'none 0 0 0 0))
  2011. X
  2012. X(define (query-best-cursor dpy w h)
  2013. X  (query-best-size dpy w h 'cursor))
  2014. X
  2015. X(define (query-best-tile dpy w h)
  2016. X  (query-best-size dpy w h 'tile))
  2017. X
  2018. X(define (query-best-stipple dpy w h)
  2019. X  (query-best-size dpy w h 'stipple))
  2020. X
  2021. X;; Until Xlib provides an XGetCommand():
  2022. X
  2023. X(define (wm-command w)
  2024. X  (let* ((dpy (window-display w))
  2025. X     (string (intern-atom dpy 'STRING))
  2026. X     (p (get-property w (intern-atom dpy 'WM_COMMAND) string 0 1000 #f))
  2027. X     (s (caddr p))
  2028. X     (next-null (lambda (i)
  2029. X                      (do ((i i (1+ i)))
  2030. X                      ((char=? (string-ref s i) (integer->char 0)) i)))))
  2031. X    (if (and (eq? (car p) string) (= (cadr p) 8))
  2032. X    (do ((len (string-length s))
  2033. X         (end 0)
  2034. X         (start 0 (1+ end))
  2035. X         (l () (cons (substring s start end) l)))
  2036. X        ((>= start len) (reverse! l))
  2037. X      (set! end (next-null start)))
  2038. X    ())))
  2039. X
  2040. X
  2041. X;;; Describe functions go here:
  2042. END_OF_scm/xlib.more
  2043. if test 2166 -ne `wc -c <scm/xlib.more`; then
  2044.     echo shar: \"scm/xlib.more\" unpacked with wrong size!
  2045. fi
  2046. # end of overwriting check
  2047. fi
  2048. if test -f scm/parse -a "${1}" != "-c" ; then 
  2049.   echo shar: Will not over-write existing file \"scm/parse\"
  2050. else
  2051. echo shar: Extracting \"scm/parse\" \(418 characters\)
  2052. sed "s/^X//" >scm/parse <<'END_OF_scm/parse'
  2053. X;;; -*-Scheme-*-
  2054. X;;;
  2055. X;;; Parse a string into a list of tokens
  2056. X
  2057. X(define (parse s)
  2058. X  (let ((i 0) (j)
  2059. X    (n (string-length s)))
  2060. X    (let loop ((args ()))
  2061. X      (while (and (< i n) (char-whitespace? (string-ref s i)))
  2062. X    (set! i (1+ i)))
  2063. X      (if (>= i n)
  2064. X    (reverse! args)
  2065. X        (set! j i)
  2066. X    (while (and (< i n) (not (char-whitespace? (string-ref s i))))
  2067. X      (set! i (1+ i)))
  2068. X        (loop (cons (substring s j i) args))))))
  2069. END_OF_scm/parse
  2070. if test 418 -ne `wc -c <scm/parse`; then
  2071.     echo shar: \"scm/parse\" unpacked with wrong size!
  2072. fi
  2073. # end of overwriting check
  2074. fi
  2075. if test -f scm/xt -a "${1}" != "-c" ; then 
  2076.   echo shar: Will not over-write existing file \"scm/xt\"
  2077. else
  2078. echo shar: Extracting \"scm/xt\" \(583 characters\)
  2079. sed "s/^X//" >scm/xt <<'END_OF_scm/xt'
  2080. X;;; -*-Scheme-*-
  2081. X;;;
  2082. X;;; The Scheme part of the Xt interface
  2083. X
  2084. X(require 'xt.o)
  2085. X
  2086. X(load 'xlib.core)
  2087. X(load 'xlib.more)
  2088. X
  2089. X(provide 'xlib)
  2090. X(provide 'xt)
  2091. X
  2092. X(define (manage-child w)
  2093. X  (manage-children (list w)))
  2094. X
  2095. X(define (unmanage-child w)
  2096. X  (unmanage-children (list w)))
  2097. X
  2098. X(define (add-callback w name fun)
  2099. X  (add-callbacks w name (list fun)))
  2100. X
  2101. X(define (create-managed-widget . args)
  2102. X  (let ((w (apply create-widget args)))
  2103. X    (manage-child w)
  2104. X    w))
  2105. X
  2106. X(append! load-path (list (string-append top-dir "lib/xt/examples")
  2107. X                         (string-append top-dir "lib/xlib/examples")))
  2108. X
  2109. END_OF_scm/xt
  2110. if test 583 -ne `wc -c <scm/xt`; then
  2111.     echo shar: \"scm/xt\" unpacked with wrong size!
  2112. fi
  2113. # end of overwriting check
  2114. fi
  2115. if test -f scm/expt -a "${1}" != "-c" ; then 
  2116.   echo shar: Will not over-write existing file \"scm/expt\"
  2117. else
  2118. echo shar: Extracting \"scm/expt\" \(225 characters\)
  2119. sed "s/^X//" >scm/expt <<'END_OF_scm/expt'
  2120. X;;; -*-Scheme-*-
  2121. X;;;
  2122. X;;; expt
  2123. X
  2124. X(define (square x) (* x x))
  2125. X
  2126. X(define (expt b n)
  2127. X  (cond ((= n 0) 1)
  2128. X    ((negative? n) (/ 1 (expt b (abs n))))
  2129. X        ((even? n) (square (expt b (/ n 2))))
  2130. X        (else (* b (expt b (- n 1))))))
  2131. END_OF_scm/expt
  2132. if test 225 -ne `wc -c <scm/expt`; then
  2133.     echo shar: \"scm/expt\" unpacked with wrong size!
  2134. fi
  2135. # end of overwriting check
  2136. fi
  2137. if test -f scm/xwidgets -a "${1}" != "-c" ; then 
  2138.   echo shar: Will not over-write existing file \"scm/xwidgets\"
  2139. else
  2140. echo shar: Extracting \"scm/xwidgets\" \(1137 characters\)
  2141. sed "s/^X//" >scm/xwidgets <<'END_OF_scm/xwidgets'
  2142. X;;; -*-Scheme-*-
  2143. X;;;
  2144. X;;; The Scheme part of the X11 widget interface
  2145. X
  2146. X(require 'xt)
  2147. X
  2148. X(define widget-load-path '(xaw xhp))
  2149. X
  2150. X(define widgets ())
  2151. X
  2152. X(define-macro (load-widgets . w)
  2153. X  (let ((s "") (l ()))
  2154. X    (if (null? w)
  2155. X    (error 'load-widgets "no arguments"))
  2156. X    (for-each
  2157. X     (lambda (w)
  2158. X       (if (not (symbol? w))
  2159. X       (error 'load-widgets "argument not a symbol"))
  2160. X       (if (not (memq w widgets))
  2161. X       (set! l (cons w l))))
  2162. X     w)
  2163. X    (if l
  2164. X    (begin
  2165. X      (set! widgets (append widgets l))
  2166. X      (format #t "[Loading ")
  2167. X      (do ((f (cdr l) (cdr f))) ((null? f))
  2168. X        (format #t "~a " (car f))
  2169. X        (set! s (format #f "~a ~a" s (locate-widget (car f)))))
  2170. X      (format #t "~a]~%" (car l))
  2171. X      `(fluid-let ((load-libraries
  2172. X            (format #f "~a -lXw -lXaw -lXmu -lXt -lX11 -lc" ,s)))
  2173. X         (load (locate-widget ',(car l))))))))
  2174. X
  2175. X(define (locate-widget w)
  2176. X  (let loop ((path widget-load-path))
  2177. X    (if (null? path)
  2178. X    (error 'locate-widget "no such widget: ~s" w)
  2179. X    (let ((name (format #f "~alib/~a/~a.o" top-dir (car path) w)))
  2180. X      (if (file-exists? name)
  2181. X          name
  2182. X          (loop (cdr path)))))))
  2183. X
  2184. X(define load-widget load-widgets)
  2185. X
  2186. X(provide 'xwidgets)
  2187. END_OF_scm/xwidgets
  2188. if test 1137 -ne `wc -c <scm/xwidgets`; then
  2189.     echo shar: \"scm/xwidgets\" unpacked with wrong size!
  2190. fi
  2191. # end of overwriting check
  2192. fi
  2193. if test -f tst/gcd -a "${1}" != "-c" ; then 
  2194.   echo shar: Will not over-write existing file \"tst/gcd\"
  2195. else
  2196. echo shar: Extracting \"tst/gcd\" \(70 characters\)
  2197. sed "s/^X//" >tst/gcd <<'END_OF_tst/gcd'
  2198. X(define (g x y)
  2199. X  (if (zero? y)
  2200. X      x
  2201. X      (g y (remainder x y))))
  2202. END_OF_tst/gcd
  2203. if test 70 -ne `wc -c <tst/gcd`; then
  2204.     echo shar: \"tst/gcd\" unpacked with wrong size!
  2205. fi
  2206. # end of overwriting check
  2207. fi
  2208. echo shar: End of archive 7 \(of 14\).
  2209. cp /dev/null ark7isdone
  2210. MISSING=""
  2211. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
  2212.     if test ! -f ark${I}isdone ; then
  2213.     MISSING="${MISSING} ${I}"
  2214.     fi
  2215. done
  2216. if test "${MISSING}" = "" ; then
  2217.     echo You have unpacked all 14 archives.
  2218.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2219. else
  2220.     echo You still need to unpack the following archives:
  2221.     echo "        " ${MISSING}
  2222. fi
  2223. ##  End of shell archive.
  2224. exit 0
  2225.