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 >
Wrap
Text File
|
1999-01-02
|
2KB
|
78 lines
#| -*-Scheme-*-
$Id: nodefs.scm,v 1.11 1999/01/02 06:06:43 cph Exp $
Copyright (c) 1991-1999 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|#
;;;; SCode rewriting for 6.001
;;; package: (student scode-rewriting)
(declare (usual-integrations))
(define (initialize-package!)
(set! hook/repl-eval student/repl-eval)
unspecific)
(define (student/repl-eval repl s-expression environment syntax-table)
(repl-scode-eval
repl
(rewrite-scode (syntax s-expression syntax-table)
(and repl
(let ((port (cmdl/port repl)))
(let ((operation
(port/operation
port
'CURRENT-EXPRESSION-CONTEXT)))
(and operation
(operation port s-expression))))))
environment))
(define (rewrite-scode expression context)
(let ((expression
(if (open-block? expression)
(open-block-components expression unscan-defines)
expression)))
(if (eq? context 'REPL-BUFFER)
(make-sequence
(map (lambda (expression)
(if (definition? expression)
(let ((name (definition-name expression))
(value (definition-value expression)))
(make-sequence
(list expression
(make-combination
write-definition-value
(cons name
(if (unassigned-reference-trap? value)
'()
(list (make-variable name))))))))
expression))
(sequence-actions expression)))
expression)))
(define (write-definition-value name #!optional value)
(with-string-output-port
(lambda (port)
(write name port)
(if (not (default-object? value))
(begin
(write-string " --> " port)
(fluid-let ((*unparser-list-depth-limit* 2)
(*unparser-list-breadth-limit* 10)
(*unparser-string-length-limit* 30))
(write value port)))))))