2001-04-05 02:04:26 +00:00
|
|
|
|
;;; Guile R5RS
|
2001-04-01 05:33:45 +00:00
|
|
|
|
|
|
|
|
|
|
;; Copyright (C) 2001 Free Software Foundation, Inc.
|
|
|
|
|
|
|
2001-04-05 02:04:26 +00:00
|
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
2001-04-01 05:33:45 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
;; the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
|
;; any later version.
|
|
|
|
|
|
;;
|
2001-04-05 02:04:26 +00:00
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
2001-04-01 05:33:45 +00:00
|
|
|
|
;; 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
|
2001-04-05 02:04:26 +00:00
|
|
|
|
;; along with this program; see the file COPYING. If not, write to
|
2001-04-01 05:33:45 +00:00
|
|
|
|
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
|
|
;; Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
2001-04-05 02:04:26 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
2001-04-01 05:33:45 +00:00
|
|
|
|
(define-module (language r5rs spec)
|
|
|
|
|
|
:use-module (system base language)
|
|
|
|
|
|
:use-module (language r5rs expand)
|
|
|
|
|
|
:use-module (language r5rs translate)
|
|
|
|
|
|
:export (r5rs))
|
|
|
|
|
|
|
2001-04-05 02:04:26 +00:00
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
|
;;; Translator
|
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
|
|
(define (translate x) (if (pair? x) (translate-pair x) x))
|
|
|
|
|
|
|
|
|
|
|
|
(define (translate-pair x)
|
2001-04-06 09:11:32 +00:00
|
|
|
|
(let ((head (car x)) (rest (cdr x)))
|
|
|
|
|
|
(case head
|
|
|
|
|
|
((quote) (cons '@quote rest))
|
2001-04-05 02:04:26 +00:00
|
|
|
|
((define set! if and or begin)
|
2001-04-06 09:11:32 +00:00
|
|
|
|
(cons (symbol-append '@ head) (map translate rest)))
|
2001-04-05 02:04:26 +00:00
|
|
|
|
((let let* letrec)
|
2001-04-06 09:11:32 +00:00
|
|
|
|
(cons* (symbol-append '@ head)
|
|
|
|
|
|
(map (lambda (b) (cons (car b) (map translate (cdr b))))
|
|
|
|
|
|
(car rest))
|
|
|
|
|
|
(map translate (cdr rest))))
|
2001-04-05 02:04:26 +00:00
|
|
|
|
((lambda)
|
2001-04-06 09:11:32 +00:00
|
|
|
|
(cons* '@lambda (car rest) (map translate (cdr rest))))
|
2001-04-05 02:04:26 +00:00
|
|
|
|
(else
|
2001-04-06 09:11:32 +00:00
|
|
|
|
(cons (translate head) (map translate rest))))))
|
2001-04-05 02:04:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
|
;;; Language definition
|
|
|
|
|
|
;;;
|
|
|
|
|
|
|
2001-04-01 05:33:45 +00:00
|
|
|
|
(define-language r5rs
|
|
|
|
|
|
:title "Standard Scheme (R5RS + syntax-case)"
|
|
|
|
|
|
:version "0.3"
|
|
|
|
|
|
:reader read
|
|
|
|
|
|
:expander expand
|
|
|
|
|
|
:translator translate
|
|
|
|
|
|
:printer write
|
2001-04-04 20:14:34 +00:00
|
|
|
|
;; :environment (global-ref 'Language::R5RS::core)
|
2001-04-01 05:33:45 +00:00
|
|
|
|
)
|