-
-
Save DrMundo0/3a67bc5ccbd25c956490 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
| #lang racket ; Requires Racket >= 5.1.1 | |
| (provide (rename-out (objective-r-read read) | |
| (objective-r-read-syntax read-syntax))) | |
| (require syntax/stx) | |
| (define (rewrite-method-calls stx) | |
| (if (stx-list? stx) | |
| (let ((stx* (stx-map rewrite-method-calls stx))) | |
| (if (eq? (syntax-property stx 'paren-shape) #\[) | |
| (match (stx->list stx*) | |
| ((list obj msg args ...) | |
| #`(send #,obj '#,msg #,@args))) | |
| stx*)) | |
| stx)) | |
| (define (objective-r-read . args) | |
| (let ((stx (apply objective-r-read-syntax #f args))) | |
| (if (eof-object? stx) stx (syntax->datum stx)))) | |
| (define (objective-r-read-syntax . args) | |
| ; TODO: Do something with the rest of the arguments | |
| (rewrite-method-calls (read-syntax (first args) (second args)))) | |
| ; Example: | |
| (objective-r-read (open-input-string "[[document get-element-by-id stuff] remove]")) | |
| ; => (send (send document 'get-element-by-id stuff) 'remove) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment