blob: 782d74d46c8881fe9b5543d282531b5c77d0f7be (
plain) (
blame)
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
43
44
|
(define-library (config-generation sexp)
(export ;sexps->string
scm->string)
(import (scheme base)
(scheme write)
(srfi 1) ;list
;; (srfi 41) ;Streams
;; (ice-9 pretty-print)
;; (ice-9 ports)
)
(begin
;; (define-syntax sexps->string
;; (syntax-rules ()
;; ((_ sexp)
;; (with-output-to-string
;; (lambda ()
;; (pretty-print 'sexp))))
;; ((_ sexp sexps ...)
;; (string-append (sexps->string sexp) (sexps->string sexps ...)))))
;; (define (repeat-string s n)
;; (string-join (stream->list (stream-take n (stream-constant s))) ""))
;; (define-syntax sexps->yaml-tree
;; (syntax-rules (indentation list)
;; ((_ indentation i (key value ...))
;; (string-append
;; (repeat-string "\t" i)
;; (symbol->string 'key) ":\t" (sexps->yaml-tree indentation (+ i 1) value ...)))
;; ((_ indentation i value)
;; (cond
;; ((symbol? 'value) (symbol->string 'value))
;; (else value)))
;; ((_ expression ...)
;; (sexps->yaml-tree indentation 0))))
(define (scm->string scm)
(if (null? scm)
""
(string-append
(let ((out (open-output-string)))
(write (first scm) out)
(get-output-string out))
"\n"
(scm->string (drop scm 1)))))))
|