source: project/release/3/nemo/trunk/nemo-macros.scm @ 11870

Last change on this file since 11870 was 11870, checked in by Ivan Raikov, 12 years ago

Added stx-macros and some initial xml templates in nemo.scm.

File size: 2.1 KB
Line 
1;;
2;; NeuroML macros
3;;
4;; Copyright 2008 Ivan Raikov and the Okinawa Institute of Science and Technology
5;;
6;; This program is free software: you can redistribute it and/or
7;; modify it under the terms of the GNU General Public License as
8;; published by the Free Software Foundation, either version 3 of the
9;; License, or (at your option) any later version.
10;;
11;; This program is distributed in the hope that it will be useful, but
12;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14;; General Public License for more details.
15;;
16;; A full copy of the GPL license can be found at
17;; <http://www.gnu.org/licenses/>.
18;;
19
20
21(require-extension srfi-1)
22(require-extension nemo-core)
23(require-extension environments)
24
25
26(define-macro (nemo-begin sys . body)
27  `(begin
28     (if (not (environment? ,sys)) (nemo:error 'nemo-begin "system argument must be an environment"))
29     (let ((nemo (match (environment-ref ,sys (nemo-intern 'nemocore))
30                           (($ nemo:quantity 'DISPATCH value)  value))))
31       ,@body)))
32
33
34(define-macro (nemo-model name declarations . body)
35  `(begin
36     (let* ((nemo   (make-nemo-core))
37            (,name     ((nemo 'system) ',name)))
38       (eval-nemo-system-decls nemo ',name ,name (list ,@(map (lambda (x) (list 'quasiquote x)) declarations)))
39       ,@body)))
40                   
41
42(define-macro (nemo-constructor name declarations)
43  `(begin
44     (let* ((nemo   (make-nemo-core))
45            (,name     ((nemo 'system) ',name)))
46       (eval-nemo-system-decls nemo ',name ,name (list ,@(map (lambda (x) (list 'quasiquote x)) declarations)))
47       (list ,name nemo))))
48                   
49
50(define-macro (nemo-transform sys declarations)
51  `(begin
52     (if (not (environment? ,sys)) (nemo:error 'nemo-transform "system argument must be an environment"))
53     (let* ((nemo  (match (environment-ref ,sys (nemo-intern 'dispatch))
54                             (($ nemo:quantity 'DISPATCH value)  value)))
55            (sys1 (nemo:env-copy ,sys))
56            (name ((nemo 'sysname) sys1)))
57     (eval-nemo-system-decls nemo name sys1 (list ,@(map (lambda (x) (list 'quasiquote x)) declarations)))
58     sys1)))
Note: See TracBrowser for help on using the repository browser.