Created
June 5, 2017 01:17
-
-
Save carld/103a458a745b1d4a5a63ae4475b1482e to your computer and use it in GitHub Desktop.
Example of let-syntax local macro
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-syntax section | |
(syntax-rules () | |
[(_ type (instruction ...) ... ) | |
(let-syntax ([b (syntax-rules () | |
[(_ i) (printf "~s~%" 'i )] | |
[(_ i op1) (printf "~s ~s~%" 'i 'op1)] | |
[(_ i op1 op2) (printf "~s ~s, ~s~%" 'i 'op1 'op2)])]) | |
(begin | |
(printf "~s ~s~%" 'section 'type) | |
(b instruction ...) ... | |
))])) | |
(section .text | |
(hello) | |
(world) | |
(push 1)) | |
; section .text | |
; hello | |
; world | |
; push 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment