-
Notifications
You must be signed in to change notification settings - Fork 3
/
syntaxcommon.scm
42 lines (32 loc) · 1.3 KB
/
syntaxcommon.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
;;;============================================================================
;;; File: "syntaxcommon.scm"
;;; Copyright (c) 2000-2014 by Marc Feeley, All Rights Reserved.
;;;============================================================================
(define (syn#pvar-id pvar)
(let ((sym (car pvar)))
(string->symbol (string-append "##~" (symbol->string sym)))))
;;;----------------------------------------------------------------------------
(define (datum->syntax src datum)
(##sourcify datum src))
(define (syntax->datum src)
(##desourcify src))
(define (syntax->list src)
(cond ((##source? src)
(let ((code (##source-code src)))
(if (or (null? code) (pair? code))
(##map (lambda (x) (##sourcify x src))
code)
(error "list expected"))))
(else
(error "source object expected"))))
(define (syntax->vector src)
(cond ((##source? src)
(let ((code (##source-code src)))
(if (vector? code)
(list->vector
(##map (lambda (x) (##sourcify x src))
(vector->list code)))
(error "vector expected"))))
(else
(error "source object expected"))))
;;;============================================================================