Commit | Line | Data |
---|---|---|
c7228382 KN |
1 | ;;; Guile Scheme specification |
2 | ||
80af1168 | 3 | ;; Copyright (C) 2001, 2009 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 KN |
27 | |
28 | ;;; | |
29 | ;;; Reader | |
30 | ;;; | |
31 | ||
32 | (read-enable 'positions) | |
33 | ||
c7228382 KN |
34 | ;;; |
35 | ;;; Language definition | |
36 | ;;; | |
37 | ||
38 | (define-language scheme | |
1a1a10d3 AW |
39 | #:title "Guile Scheme" |
40 | #:version "0.5" | |
4b2afc62 AW |
41 | #:reader (lambda (port env) |
42 | ;; Use the binding of current-reader from the environment. | |
43 | ;; FIXME: Handle `read-options' as well? | |
f95f82f8 | 44 | ((or (and=> (and=> (module-variable env 'current-reader) |
4b2afc62 AW |
45 | variable-ref) |
46 | fluid-ref) | |
47 | read) | |
48 | port)) | |
f65e2b1e | 49 | |
80af1168 | 50 | #:compilers `((tree-il . ,compile-tree-il)) |
b81d329e | 51 | #:decompilers `((tree-il . ,decompile-tree-il)) |
0570c3f1 | 52 | #:evaluator (lambda (x module) (primitive-eval x)) |
1a1a10d3 | 53 | #:printer write |
f95f82f8 AW |
54 | #:make-default-environment |
55 | (lambda () | |
56 | ;; Ideally we'd duplicate the whole module hierarchy so that `set!', | |
57 | ;; `fluid-set!', etc. don't have any effect in the current environment. | |
58 | (let ((m (make-fresh-user-module))) | |
59 | ;; Provide a separate `current-reader' fluid so that | |
60 | ;; compile-time changes to `current-reader' are | |
61 | ;; limited to the current compilation unit. | |
62 | (module-define! m 'current-reader (make-fluid)) | |
63 | m))) |