;;;; string-interpolation-syntax.scm -*- Scheme -*- ;;;; Kon Lovett, Jul '18 ;;;; Kon Lovett, Sep '17 (module string-interpolation-syntax (;export set-sharp-string-interpolation-syntax) (import scheme (chicken base) (chicken syntax) (chicken read-syntax) (chicken type) (chicken port)) ;;; (: set-sharp-string-interpolation-syntax ((or boolean procedure) -> void)) ; (define (set-sharp-string-interpolation-syntax proc) (set-sharp-read-syntax! #\" (and proc (let ( (proc (if (procedure? proc) proc identity)) ) (lambda (rest-port) (call-with-input-string "\"" (lambda (head-port) (let* ( ;forms [(") (body...")] so read as "...body..." (port (make-concatenated-port head-port rest-port)) (str (read port)) ) (proc str) ) ) ) ) ) ) ) ) ) ;string-interpolation-syntax