source: project/release/4/string-utils/tags/1.4.0/string-interpolation-syntax.scm @ 34661

Last change on this file since 34661 was 34661, checked in by kon, 13 months ago

rel 1.4

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