Here's the best I could do at formatting and reading/commenting it, so far:
;; Usage: (get)
;; Parse the entirety of stdin as a sequence of s-expressions. Return
;; that list of expressions.
;;
;; The definition of this function is a little contrived, because in
;; lisp it's simpler to prepend to a list than to append to it, which
;; would be the natural thing to do. So instead, we build the list
;; such that it is backwards, then we call (reverse LIST) on it when
;; we read EOF.
(define (get)
(get1 (quote ()) (read)))
;; Usage: (get CURRENT-BUFFER JUSt-READ-EXPRESSION)
(define (get1 b r)
(if (eof-object? r)
(reverse b)
(get1 (cons r b) (read))))
;; Usage: (put)
;;
;; Read the entirety of stdin as a sequence of characters, perform the
;; global string substitution ")" -> ")..", then return the result as
;; a string.
;;
;; The definition of this function is a little contrived, because in
;; lisp it's simpler to prepend to a list than to append to it, which
;; would be the natural thing to do. So instead, we build the list
;; such that it is backwards, then we call (reverse LIST) on it when
;; we read EOF.
(define (put)
(put1 (quote ()) (read-char)))
;; Usage: (put CURRENT-BUFFER LAST-READ-CHAR)
(define (put1 b r)
(if (eof-object? r)
(list->string (reverse b))
(if (char=? #\) r)
(put1 (cons #\. (cons #\. (cons r b))) (read-char))
(put1 (cons r b) (read-char)))))
;; Usage: (final LIST)
;; ???
(define (final lis)
(if (null? lis)
lis
(final1 (car lis) (cdr lis))))
;; Usage: (final1 FIRST REST)
(define (final1 f r)
(if (and (pair? f) (pair? (cdr f)) (eqv? (quote quote) (car f)))
(cons f (final (cdr r)))
(if (list? f)
(final2 f (gather (count (car r)) (cons (quote ()) (final (cdr r)))))
(if (or (vector? f) (pair? f) (eq? #\) f))
(cons f (final (cdr r)))
(cons f (final r))))))
;; Usage: (final2 f g)
(define (final2 f g)
(cons (append (final f) (car g)) (cdr g)))
;; Usage: (count SYMBOL)
(define (count s)
(- (string-length (symbol->string s)) 2))
;; Usage: (gather c lis)
(define (gather c lis)
(if (= c 0)
(cons (reverse (car lis)) (cdr lis))
(gather (- c 1) (cons (cons (cadr lis) (car lis)) (cddr lis)))))
;; 1. Use (put) to read stdin as a string and perform the ")" -> ").."
;; global string replacement.
;; 2. Feed that resulting string to (get), which parses it in to a
;; sequence of s-expressions.
;; 3. Feed that list of expressions to (final), which does something
;; to it and returns a list.
;; 4. (write) each item that (final) returns.
(for-each write (final (with-input-from-string (put) get)))