;;;; spock-module.scm - read-syntax and programming interface (module spock ( spock-script ) (import scheme chicken) (use matchable ports) (require-library spock-compiler) (reexport spock-compiler) ;; (define ( #!key (minified #t) debug path) (string-append "\n")) ;; (define (spock-script x . options) (let ((state (current-spock-state))) (unless state (set! state (make-spock-state)) (current-spock-state state)) (with-output-to-string (lambda () (display "\n"))))) ;; (define-syntax ( x r c) (let ((%cons (r 'cons)) (%append (r 'append)) (%list->vector (r 'list->vector)) (%spock-script (r 'spock-script))) (define (unq x) (cond ((pair? x) (cond ((and (symbol? (car x)) (= (length x) 2) (eq? ' (strip-syntax (car x)))) (cadr x)) ((and (pair? (car x)) (symbol? (caar x)) (= (length (car x)) 2) (eq? ' (strip-syntax (caar x)))) `(,%append (cadar x) ,(unq (cdr x)))) (else `(,%cons ,(unq (car x)) ,(unq (cdr x)))))) ;XXX could be improved ((vector? x) `(,%list->vector ,(unq (vector->list x)))) (else `',x))) `(,%spock-script ,(unq (cadr x))))) ;; read-syntax (set-sharp-read-syntax! #\` (lambda (port) `( ,(read port)))) (set-sharp-read-syntax! #\^ (lambda (port) (cond ((eqv? (peek-char port) #\@) (read-char port) `( ,(read port))) (else `( ,(read port)))))) )