source: project/release/5/string-utils/trunk/string-interpolation-syntax.scm @ 37679

Last change on this file since 37679 was 37679, checked in by Kon Lovett, 5 months ago

fix string-interpolation (per #<#TAG)

File size: 876 bytes
Line 
1;;;; string-interpolation-syntax.scm  -*- Scheme -*-
2;;;; Kon Lovett, Jul '18
3;;;; Kon Lovett, Sep '17
4
5(module string-interpolation-syntax
6
7(;export
8  set-sharp-string-interpolation-syntax)
9
10(import scheme
11  (chicken base)
12  (chicken syntax)
13  (chicken read-syntax)
14  (chicken type)
15  (chicken port))
16
17;;;
18
19;(string --> string)
20(: set-sharp-string-interpolation-syntax ((or boolean procedure) -> void))
21;
22(define (set-sharp-string-interpolation-syntax proc)
23  (set-sharp-read-syntax! #\"
24    (and
25      proc
26      (let (
27        (proc (if (procedure? proc) proc identity)) )
28        (lambda (rest-port)
29          (call-with-input-string "\""
30            (lambda (head-port)
31              (let* (
32                (port (make-concatenated-port head-port rest-port))
33                (str (read port)) )
34                (proc str) ) ) ) ) ) ) ) )
35
36) ;string-interpolation-syntax
Note: See TracBrowser for help on using the repository browser.