3 ;;; Mes --- Maxwell Equations of Software
4 ;;; Copyright © 2016 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
6 ;;; This file is part of Mes.
8 ;;; Mes is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
13 ;;; Mes is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
23 ;;; syntax.mes is loaded after scm.mes. It provides the R5RS hygienic
24 ;;; macros define-syntax, syntax-rules and define-syntax-rule.
25 ;;; syntax-rules is adapted from scheme48-1.1/scheme/alt/syntax.scm
28 (mes-use-module (mes scm))
29 (include-from-path "mes/syntax.scm")
31 (define (syntax-error message thing)
32 (display "syntax-error:" (current-error-port))
33 (display message (current-error-port))
34 (display ":" (current-error-port))
35 (display thing (current-error-port))
36 (newline (current-error-port)))
38 (define (silent-syntax-error message thing)
41 (define-macro (define-syntax-rule id-pattern . template)
42 `(define-syntax ,(car id-pattern)
44 ((,(car id-pattern) . ,(cdr id-pattern)) ,@template))))
46 (define-macro (let-syntax bindings . rest)
48 ,@(map (lambda (binding)
49 `(define-macro (,(car binding) . args)
50 (,(cadr binding) (cons ',(car binding) args)