Merge remote-tracking branch 'origin/stable-2.0'
[bpt/guile.git] / module / language / scheme / spec.scm
CommitLineData
c7228382
KN
1;;; Guile Scheme specification
2
60273407 3;; Copyright (C) 2001, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
c7228382 4
53befeb7
NJ
5;;;; This library is free software; you can redistribute it and/or
6;;;; modify it under the terms of the GNU Lesser General Public
7;;;; License as published by the Free Software Foundation; either
8;;;; version 3 of the License, or (at your option) any later version.
9;;;;
10;;;; This library is distributed in the hope that it will be useful,
11;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13;;;; Lesser General Public License for more details.
14;;;;
15;;;; You should have received a copy of the GNU Lesser General Public
16;;;; License along with this library; if not, write to the Free Software
17;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
c7228382
KN
18
19;;; Code:
20
21(define-module (language scheme spec)
f65e2b1e 22 #:use-module (system base compile)
1a1a10d3 23 #:use-module (system base language)
b81d329e
AW
24 #:use-module (language scheme compile-tree-il)
25 #:use-module (language scheme decompile-tree-il)
1a1a10d3 26 #:export (scheme))
c7228382 27
c7228382
KN
28;;;
29;;; Language definition
30;;;
31
32(define-language scheme
246ea9e1 33 #:title "Scheme"
4b2afc62
AW
34 #:reader (lambda (port env)
35 ;; Use the binding of current-reader from the environment.
36 ;; FIXME: Handle `read-options' as well?
f95f82f8 37 ((or (and=> (and=> (module-variable env 'current-reader)
4b2afc62
AW
38 variable-ref)
39 fluid-ref)
40 read)
41 port))
f65e2b1e 42
80af1168 43 #:compilers `((tree-il . ,compile-tree-il))
b81d329e 44 #:decompilers `((tree-il . ,decompile-tree-il))
0570c3f1 45 #:evaluator (lambda (x module) (primitive-eval x))
1a1a10d3 46 #:printer write
f95f82f8
AW
47 #:make-default-environment
48 (lambda ()
49 ;; Ideally we'd duplicate the whole module hierarchy so that `set!',
50 ;; `fluid-set!', etc. don't have any effect in the current environment.
51 (let ((m (make-fresh-user-module)))
52 ;; Provide a separate `current-reader' fluid so that
53 ;; compile-time changes to `current-reader' are
54 ;; limited to the current compilation unit.
55 (module-define! m 'current-reader (make-fluid))
60273407
LC
56
57 ;; Default to `simple-format', as is the case until
58 ;; (ice-9 format) is loaded. This allows
59 ;; compile-time warnings to be emitted when using
60 ;; unsupported options.
61 (module-set! m 'format simple-format)
62
f95f82f8 63 m)))