home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / 6001 / nodefs.scm < prev    next >
Text File  |  1999-01-02  |  2KB  |  78 lines

  1. #| -*-Scheme-*-
  2.  
  3. $Id: nodefs.scm,v 1.11 1999/01/02 06:06:43 cph Exp $
  4.  
  5. Copyright (c) 1991-1999 Massachusetts Institute of Technology
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. |#
  21.  
  22. ;;;; SCode rewriting for 6.001
  23. ;;; package: (student scode-rewriting)
  24.  
  25. (declare (usual-integrations))
  26.  
  27. (define (initialize-package!)
  28.   (set! hook/repl-eval student/repl-eval)
  29.   unspecific)
  30.  
  31. (define (student/repl-eval repl s-expression environment syntax-table)
  32.   (repl-scode-eval
  33.    repl
  34.    (rewrite-scode (syntax s-expression syntax-table)
  35.           (and repl
  36.                (let ((port (cmdl/port repl)))
  37.              (let ((operation
  38.                 (port/operation
  39.                  port
  40.                  'CURRENT-EXPRESSION-CONTEXT)))
  41.                (and operation
  42.                 (operation port s-expression))))))
  43.    environment))
  44.  
  45. (define (rewrite-scode expression context)
  46.   (let ((expression
  47.      (if (open-block? expression)
  48.          (open-block-components expression unscan-defines)
  49.          expression)))
  50.     (if (eq? context 'REPL-BUFFER)
  51.     (make-sequence
  52.      (map (lambda (expression)
  53.         (if (definition? expression)
  54.             (let ((name (definition-name expression))
  55.               (value (definition-value expression)))
  56.               (make-sequence
  57.                (list expression
  58.                  (make-combination
  59.                   write-definition-value
  60.                   (cons name
  61.                     (if (unassigned-reference-trap? value)
  62.                     '()
  63.                     (list (make-variable name))))))))
  64.             expression))
  65.           (sequence-actions expression)))
  66.     expression)))
  67.  
  68. (define (write-definition-value name #!optional value)
  69.   (with-string-output-port
  70.    (lambda (port)
  71.      (write name port)
  72.      (if (not (default-object? value))
  73.      (begin
  74.        (write-string " --> " port)
  75.        (fluid-let ((*unparser-list-depth-limit* 2)
  76.                (*unparser-list-breadth-limit* 10)
  77.                (*unparser-string-length-limit* 30))
  78.          (write value port)))))))