Created
May 23, 2019 18:03
-
-
Save marnix/55361d56e67692ab32696abc80229f1d 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 | |
(require racket/include | |
syntax/parse/define | |
(for-syntax racket/syntax | |
racket/port | |
syntax/modread)) | |
(define-simple-macro (require/sweet-exp-racket path) | |
#:with modname (generate-temporary #'path) | |
(begin | |
(include/reader path (sweet-exp-racket-reader 'modname)) | |
(require 'modname))) | |
(begin-for-syntax | |
;; Symbol -> [Any InputPort -> Syntax] | |
(define ((sweet-exp-racket-reader modname) src input) | |
(cond | |
[(port-closed? input) eof] | |
[else | |
(define stx | |
(with-module-reading-parameterization | |
(lambda () | |
(read-syntax src | |
(input-port-append #t | |
(open-input-string "#lang sweet-exp racket\n") | |
input))))) | |
(close-input-port input) | |
(syntax-parse stx | |
[(module _ l . b) | |
#`(module #,modname l . b)])]))) | |
(require/sweet-exp-racket "./b.rkt") |
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
; on purpose we don't set #lang sweet-exp racket | |
{2 + 3} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment