Georges Dupéron 2017-01-01 21:49:51 +01:00
parent 7e1f74afce
commit 72142d5374
2 changed files with 28 additions and 0 deletions

View File

@ -21,6 +21,7 @@
hygienic-reader-extension/extend-reader
"scribble-enhanced.rkt"
phc-toolkit/stx
"unhygienic/hygienic-reader-extension--extend-reader--unhygienic.rkt"
(for-meta -10 racket/base)
(for-meta -9 racket/base)
(for-meta -8 racket/base)

View File

@ -0,0 +1,27 @@
#lang racket
;; Copied and adjusted from
;; https://github.com/AlexKnauth/hygienic-reader-extension
;; /blob/master/hygienic-reader-extension/extend-reader.rkt
(provide extend-reader-unhygienic)
;; extend-reader : (-> (-> A ... Any)
;; (-> Readtable #:outer-scope (-> Syntax Syntax) Readtable)
;; (-> A ... Any))
(define (extend-reader-unhygienic proc extend-readtable #:hygiene? [hygiene? #t])
(lambda args
(define orig-readtable (current-readtable))
(define outer-scope (make-syntax-introducer/use-site))
(parameterize ([current-readtable (extend-readtable orig-readtable #:outer-scope outer-scope)])
(define stx (apply proc args))
(if (and (syntax? stx) hygiene?)
(outer-scope stx)
stx))))
;; make-syntax-introducer/use-site : (-> (-> Syntax Syntax))
(define (make-syntax-introducer/use-site)
(cond [(procedure-arity-includes? make-syntax-introducer 1)
(make-syntax-introducer #t)]
[else
(make-syntax-introducer)]))