Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #lang racket/base
- (require
- racket/base
- racket/include
- racket/require-syntax
- (for-syntax racket/base)
- (for-syntax racket/list)
- (for-syntax racket/match)
- (for-syntax racket/path)
- (for-syntax syntax/stx))
- (define-syntax (_#%module-begin stx)
- (if (eq? 'module-begin (syntax-local-context))
- (syntax-case stx ()
- [(_#%module-begin . forms)
- (let ([expanded-code (local-expand #'(#%plain-module-begin . forms)
- 'module-begin '())])
- (with-syntax ([(body ...) (map maybe-muted (cdr (stx->list expanded-code)))])
- (syntax/loc stx (#%module-begin
- body ...
- ))))])
- (raise-syntax-error #f "allowed only around a module body" stx)))
- (define-for-syntax (maybe-muted stx)
- (syntax-case stx ()
- ;; [(module . x) stx]
- [form #'(mute form)]))
- (define-syntax (mute stx)
- (syntax-case stx ()
- [(_ form)
- #'form]))
- (provide
- (for-syntax (all-from-out racket/base))
- (except-out (all-from-out racket/base)
- #%module-begin)
- (rename-out [_#%module-begin #%module-begin]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement