Last active
September 26, 2019 07:33
-
-
Save niyarin/87752d24508f63cf8a6eb33a2f43d9ae to your computer and use it in GitHub Desktop.
cps macro example
This file contains 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-syntax %ore-reverse | |
(syntax-rules (syntax-lambda) | |
((_ "INTERNAL" (syntax-lambda (c-arg) c-body) (robj ...) ()) | |
(let-syntax ((cont-syntax | |
(syntax-rules () | |
((_ c-arg) c-body)))) | |
(cont-syntax | |
(robj ...)))) | |
((_ "INTERNAL" continuation (robj ...) (obj1 obj2 ...)) | |
(%ore-reverse "INTERNAL" continuation (obj1 robj ...) (obj2 ...))) | |
((_ continuation (obj ... )) | |
(%ore-reverse "INTERNAL" continuation () (obj ... ))))) | |
(define-syntax %ore-quote | |
(syntax-rules (syntax-lambda) | |
((_ (syntax-lambda (c-arg) c-body) (1 ls1 ls2)) | |
(let-syntax ((cont-syntax | |
(syntax-rules () | |
((_ c-arg) c-body)))) | |
(cont-syntax | |
(%ore-reverse | |
(syntax-lambda (it) | |
(quote (1 it ls2))) | |
ls1)))) | |
((_ (syntax-lambda (c-arg) c-body)(2 ls1 ls2)) | |
(let-syntax ((cont-syntax | |
(syntax-rules () | |
((_ c-arg) c-body)))) | |
(cont-syntax | |
(%ore-reverse | |
(syntax-lambda (it) | |
(quote (2 ls1 it))) | |
ls2)))))) | |
(define-syntax ore-quote | |
(syntax-rules () | |
((_ (num ls1 ls2)) | |
(%ore-quote | |
(syntax-lambda (it) it) | |
(num ls1 ls2))))) | |
(display | |
(ore-quote | |
(2 (1 2 3 4 5) (6 7 8 9)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment