(use extras data-structures) (define (read-until c in) (read-token (lambda (x) (not (eq? c x))) in)) (define (read-string/eval in) (let loop ((s '())) (let* ((s (cons (read-until #\( in) s)) (e (read in))) (if (eof-object? e) (reverse-string-append s) (loop (cons (->string (eval e)) s)))))) ;; (call-with-input-string "foo = (+ 1 2 3)\nbar = (* (+ 2 3) 5)" read-string/eval) ;; => ;; "foo = 6\nbar = 25"