Skip to content

Instantly share code, notes, and snippets.

@carld
Created June 5, 2017 01:17
Show Gist options
  • Save carld/103a458a745b1d4a5a63ae4475b1482e to your computer and use it in GitHub Desktop.
Save carld/103a458a745b1d4a5a63ae4475b1482e to your computer and use it in GitHub Desktop.
Example of let-syntax local macro
(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