1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-24 12:20:20 +02:00

language-readers receive environment as an arg

* module/language/assembly/spec.scm:
* module/language/brainfuck/spec.scm:
* module/language/bytecode/spec.scm:
* module/language/ecmascript/spec.scm:
* module/language/glil/spec.scm:
* module/language/scheme/spec.scm:
* module/language/tree-il/spec.scm: Language-readers now take two
  arguments: the port and the environment. This should allow for
  compile-environment-specific reader behavior.

* module/system/base/compile.scm (read-and-compile):
* module/system/repl/common.scm (repl-read): Pass the environment to the
  language-reader.

* module/system/repl/repl.scm (meta-reader, prompting-meta-read):
* module/system/repl/command.scm (define-meta-command): Use the second
  argument to repl-reader, so we avoid frobbing current-reader.
This commit is contained in:
Andy Wingo 2009-10-16 13:39:24 +02:00
parent a58b7fbb7e
commit 4b2afc6258
11 changed files with 47 additions and 44 deletions

View file

@ -38,19 +38,18 @@
(define-language scheme
#:title "Guile Scheme"
#:version "0.5"
#:reader (lambda args
;; Read using the compilation environment's current reader.
;; Don't use the current module's `current-reader' because
;; it might be set, e.g., to the REPL's reader, so we'd
;; enter an infinite recursion.
;; FIXME: Handle `read-options' as well.
(let* ((mod (current-compilation-environment))
(cr (and (module? mod)
(module-ref mod 'current-reader)))
(read (if (and cr (fluid-ref cr))
(fluid-ref cr)
read)))
(apply read args)))
#:reader (lambda (port env)
;; Use the binding of current-reader from the environment.
;; FIXME: Handle `read-options' as well?
((or (and=> (and=> (module-variable
(cond ((pair? env) (car env))
(env)
(else (current-module)))
'current-reader)
variable-ref)
fluid-ref)
read)
port))
#:compilers `((tree-il . ,compile-tree-il))
#:decompilers `((tree-il . ,decompile-tree-il))