summaryrefslogtreecommitdiff
path: root/config-generation/sexp.sld
diff options
context:
space:
mode:
Diffstat (limited to 'config-generation/sexp.sld')
-rw-r--r--config-generation/sexp.sld44
1 files changed, 44 insertions, 0 deletions
diff --git a/config-generation/sexp.sld b/config-generation/sexp.sld
new file mode 100644
index 0000000..782d74d
--- /dev/null
+++ b/config-generation/sexp.sld
@@ -0,0 +1,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)))))))