|
122 | 122 | ;; build-ht : stx -> hash-table |
123 | 123 | ;; the resulting hash-table maps from the each sub-object's to its syntax. |
124 | 124 | (define (syntax-object->datum/ht stx) |
125 | | - (let ([ht (make-hasheq)]) |
126 | | - (values (let loop ([stx stx]) |
127 | | - (let ([obj (syntax-e stx)]) |
128 | | - (cond |
129 | | - [(list? obj) |
130 | | - (let ([res (map loop obj)]) |
131 | | - (hash-set! ht res stx) |
132 | | - res)] |
133 | | - [(pair? obj) |
134 | | - (let ([res (cons (loop (car obj)) |
135 | | - (loop (cdr obj)))]) |
136 | | - (hash-set! ht res stx) |
137 | | - res)] |
138 | | - [(vector? obj) |
139 | | - (let ([res (list->vector (map loop (vector->list obj)))]) |
140 | | - (hash-set! ht res stx) |
141 | | - res)] |
142 | | - [else |
143 | | - (let ([res (syntax->datum stx)]) |
144 | | - (hash-set! ht res stx) |
145 | | - res)]))) |
146 | | - ht))) |
| 125 | + (define ht (make-hasheq)) |
| 126 | + (values (let loop ([stx stx]) |
| 127 | + (let ([obj (syntax-e stx)]) |
| 128 | + (cond |
| 129 | + [(list? obj) |
| 130 | + (let ([res (map loop obj)]) |
| 131 | + (hash-set! ht res stx) |
| 132 | + res)] |
| 133 | + [(pair? obj) |
| 134 | + (let ([res (cons (loop (car obj)) (loop (cdr obj)))]) |
| 135 | + (hash-set! ht res stx) |
| 136 | + res)] |
| 137 | + [(vector? obj) |
| 138 | + (let ([res (list->vector (map loop (vector->list obj)))]) |
| 139 | + (hash-set! ht res stx) |
| 140 | + res)] |
| 141 | + [else |
| 142 | + (let ([res (syntax->datum stx)]) |
| 143 | + (hash-set! ht res stx) |
| 144 | + res)]))) |
| 145 | + ht)) |
147 | 146 |
|
148 | 147 | ;; make-text-port : text -> port |
149 | 148 | ;; builds a port from a text object. |
150 | 149 | (define (make-text-port text) |
151 | | - (let-values ([(in out) (make-pipe)]) |
152 | | - (thread |
153 | | - (λ () |
154 | | - (let loop () |
155 | | - (let ([c (read-char in)]) |
156 | | - (unless (eof-object? c) |
157 | | - (send text insert (string c) |
158 | | - (send text last-position) |
159 | | - (send text last-position)) |
160 | | - (loop)))))) |
161 | | - out)) |
| 150 | + (define-values (in out) (make-pipe)) |
| 151 | + (thread (λ () |
| 152 | + (let loop () |
| 153 | + (let ([c (read-char in)]) |
| 154 | + (unless (eof-object? c) |
| 155 | + (send text insert (string c) (send text last-position) (send text last-position)) |
| 156 | + (loop)))))) |
| 157 | + out) |
0 commit comments