Created
February 10, 2011 00:35
-
-
Save danking/819682 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (define read-js | |
| (lambda (ch port src line col pos) | |
| (datum->syntax | |
| #f | |
| (->js (read port)) | |
| (let-values ([(l c p) (port-next-location port)]) | |
| (list src line col pos (and pos (- p pos))))))) | |
| (define js-readtable | |
| (make-readtable #f #f 'non-terminating-macro read-js)) | |
| (define (test x) | |
| (parameterize ([current-readtable js-readtable]) | |
| (read (open-input-string x)))) | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| > > > > (test "(js:lambda (x y) (js:+ x y))") | |
| UNKNOWN::15: read: unexpected `)' | |
| === context === | |
| stdin::8017: read-js | |
| stdin::8017: read-js | |
| stdin::8017: read-js | |
| stdin::8017: read-js | |
| stdin::8017: read-js | |
| stdin::8017: read-js | |
| stdin::8017: read-js | |
| stdin::8017: read-js | |
| stdin::8017: read-js | |
| stdin::8017: read-js | |
| stdin::8017: read-js | |
| /usr/local/lib/racket/collects/racket/private/misc.rkt:74:7 | |
| > (test "'(1 2 3)") | |
| UNKNOWN::7: read: unexpected `)' | |
| === context === | |
| stdin::8017: read-js | |
| stdin::8017: read-js | |
| stdin::8017: read-js | |
| /usr/local/lib/racket/collects/racket/private/misc.rkt:74:7 | |
| > (test "1") | |
| #<eof> | |
| > (test "1 2") | |
| #<eof> | |
| > (test "(1 2)") | |
| UNKNOWN::4: read: unexpected `)' | |
| === context === | |
| stdin::8017: read-js | |
| stdin::8017: read-js | |
| /usr/local/lib/racket/collects/racket/private/misc.rkt:74:7 | |
| > (test "'(1 2)") | |
| UNKNOWN::5: read: unexpected `)' | |
| === context === | |
| stdin::8017: read-js | |
| stdin::8017: read-js | |
| /usr/local/lib/racket/collects/racket/private/misc.rkt:74:7 | |
| > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment