Add #lang afl/unhygienic …

This commit is contained in:
Georges Dupéron 2016-12-18 20:21:48 +01:00
parent 50cc9ca667
commit 8f19de52e9
4 changed files with 62 additions and 0 deletions

View File

@ -4,6 +4,7 @@
afl-read
afl-read-syntax
wrap-reader
wrap-reader-unhygienic
use-afl-readtable
current-arg-string
(rename-out
@ -57,6 +58,19 @@
(define (wrap-reader p)
(extend-reader p make-afl-readtable))
(require syntax/strip-context)
(define ((wrap-reader-unhygienic p) . p-args)
(strip-context
(apply (extend-reader p
(λ ([orig-rt (current-readtable)]
#:outer-scope outer-scope
#:arg-str [arg-str (current-arg-string)])
(make-afl-readtable orig-rt
#:outer-scope (λ (stx [mode 'flip]) stx)
#:arg-str arg-str))
#:hygiene? #f)
p-args)))
(define (make-afl-readtable [orig-rt (current-readtable)]
#:outer-scope outer-scope
#:arg-str [arg-str (current-arg-string)])

View File

@ -0,0 +1,21 @@
#lang racket/base
(provide get-language-info)
(require racket/match)
(define (get-language-info data)
(define other-get-info
(match data
[(vector mod sym data2)
((dynamic-require mod sym) data2)]
[_ (lambda (key default) default)]))
(lambda (key default)
(case key
[(configure-runtime)
(define config-vec '#[afl/lang/runtime-config configure #f])
(define other-config (other-get-info key default))
(cond [(list? other-config) (cons config-vec other-config)]
[else (list config-vec)])]
[else (other-get-info key default)])))

View File

@ -0,0 +1,18 @@
#lang lang-extension
#:lang-extension afl make-afl-lang-reader
#:lang-reader afl-lang
(require lang-reader/lang-reader
(only-in "../../reader.rkt" wrap-reader-unhygienic))
(define (make-afl-lang-reader lang-reader)
(define/lang-reader [-read -read-syntax -get-info] lang-reader)
(make-lang-reader
(wrap-reader-unhygienic -read)
(let ([read-syntax (wrap-reader-unhygienic -read-syntax)])
(lambda args
(define stx (apply read-syntax args))
(define old-prop (syntax-property stx 'module-language))
(define new-prop `#(afl/lang/language-info get-language-info ,old-prop))
(syntax-property stx 'module-language new-prop)))
-get-info))

View File

@ -0,0 +1,9 @@
#lang racket/base
(provide configure)
(require (only-in afl/reader use-afl-readtable))
(define (configure data)
(use-afl-readtable))