|
1 |
| -(define (pk . args) |
2 |
| - (car (reverse args))) |
3 |
| - |
4 | 1 | (define (json-null? obj)
|
5 | 2 | (eq? obj 'null))
|
6 | 3 |
|
|
27 | 24 | (raise (make-json-error "Unexpected character."))))
|
28 | 25 |
|
29 | 26 | (define (port->generator port)
|
30 |
| - (define (%read-error? x) |
31 |
| - ;; TODO: move to a helper library |
32 |
| - (and (error-object? x) (memq (exception-kind x) '(user read read-incomplete)) #t)) |
33 |
| - |
34 |
| - (define offset 0) |
35 |
| - |
36 | 27 | (lambda ()
|
37 | 28 | (guard (ex ((%read-error? ex) (raise (make-json-error "Read error!"))))
|
38 |
| - (pk 'read-char (read-char port))))) |
| 29 | + (read-char port)))) |
39 | 30 |
|
40 | 31 | (define (gcons head generator)
|
41 | 32 | ;; returns a generator that will yield, HEAD the first time, and
|
|
163 | 154 | (else
|
164 | 155 | (loop (generator) (cons char out)))))))
|
165 | 156 |
|
166 |
| - (define (valid-number? string) |
167 |
| - ;; TODO: move to a helper library |
168 |
| - ;; based on https://stackoverflow.com/a/13340826/140837 |
169 |
| - (regexp-matches '(seq |
170 |
| - (? #\-) |
171 |
| - (or #\0 (seq (- numeric #\0) |
172 |
| - (* numeric))) |
173 |
| - (? (seq #\. (+ numeric))) |
174 |
| - (? (seq (or #\e #\E) |
175 |
| - (? (or #\- #\+)) |
176 |
| - (+ numeric)))) |
177 |
| - string)) |
178 |
| - |
179 | 157 | (define (maybe-read-number generator)
|
180 | 158 | ;; accumulate chars until a control char or whitespace is reached,
|
181 | 159 | ;; validate that it is JSON number, then intrepret it as Scheme
|
|
307 | 285 | (call-with-values continuation
|
308 | 286 | (lambda (event new-continuation)
|
309 | 287 | (set! continuation new-continuation)
|
310 |
| - (pk 'event event))))))) |
| 288 | + event)))))) |
311 | 289 |
|
312 | 290 | ;; gist
|
313 | 291 |
|
|
366 | 344 | (lambda ()
|
367 | 345 | (let loop ((seed seed))
|
368 | 346 | (let ((event (events)))
|
369 |
| - (pk 'ruse-event event) |
370 | 347 | (if (eof-object? event)
|
371 | 348 | (begin (k seed) #f)
|
372 | 349 | (case (car event)
|
|
420 | 397 | (let loop ((plist plist)
|
421 | 398 | (out '()))
|
422 | 399 | (if (null? plist)
|
423 |
| - out ;; TODO: maybe use reverse |
| 400 | + out |
424 | 401 | (loop (cddr plist) (cons (cons (string->symbol (cadr plist)) (car plist)) out)))))
|
425 | 402 |
|
426 | 403 | (define (object-end plist seed)
|
|
0 commit comments