; adjacent characters are turned into a string (def coalesce-chars (lst) ((afn (lst a) (if (no lst) (rev a) (let (chars rest) (span [is (type _) 'char] lst) (if chars (self rest (cons (coerce chars 'string) a)) (self cdr.lst (cons car.lst a)))))) lst '())) (def slurp-template-field (port (o accum)) (let c (readc port) (if (no c) (err "missing closing »") (is c #\») (list (read (string (rev accum)))) (slurp-template-field port (cons c accum))))) (def slurp-template (port (o accum)) (let c (readc port) (if (no c) (err "missing closing ‡") (is c #\«) (slurp-template port (cons (slurp-template-field port) accum)) (is c #\‡) `(template-literal ,@(coalesce-chars (rev accum))) (slurp-template port (cons c accum))))) (ac-scheme (begin (define (parse-template ch port src line col pos) (_slurp-template port)) (current-readtable (make-readtable (current-readtable) #\‡ 'non-terminating-macro parse-template)) )) (mac template-literal lst `(fn (lookup) (string ,@(map (fn (item) (if (isa item 'string) item `(lookup ',(car item)))) lst))))