(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)))))))