[honu] add syntax form that is not parsed by enforest so it can contain normal racket code
This commit is contained in:
parent
fb42f390c9
commit
3de9b1da74
|
@ -36,6 +36,7 @@
|
|||
[honu-while while]
|
||||
[honu-macro macro]
|
||||
[honu-phase phase]
|
||||
[honu-racket racket]
|
||||
[honu-primitive-macro primitive_macro]
|
||||
[honu-pattern pattern]
|
||||
[racket:read-line readLine]
|
||||
|
|
|
@ -465,3 +465,30 @@
|
|||
(define out
|
||||
(phase1:racket-syntax (begin-for-syntax (parse-stuff body ...))))
|
||||
(values out #'rest #t)])))
|
||||
|
||||
;; not sure this is useful but it lets you write racket syntax expressions
|
||||
;; from inside honu. the main issue is all the bindings available
|
||||
;; are honu bindings so things like (+ 1 x) wont work.
|
||||
(provide honu-racket)
|
||||
(define-honu-syntax honu-racket
|
||||
(lambda (code)
|
||||
(define (remove-cruft stx)
|
||||
(syntax-parse stx #:literal-sets (cruft)
|
||||
[(#%parens inside ...)
|
||||
(remove-cruft #'(inside ...))]
|
||||
[(#%braces inside ...)
|
||||
(remove-cruft #'(inside ...))]
|
||||
[(#%brackets inside ...)
|
||||
(remove-cruft #'(inside ...))]
|
||||
[(head rest ...)
|
||||
(with-syntax ([head* (remove-cruft #'head)]
|
||||
[(rest* ...) (remove-cruft #'(rest ...))])
|
||||
#'(head* rest* ...))]
|
||||
[x #'x]))
|
||||
|
||||
(syntax-parse code #:literal-sets (cruft)
|
||||
[(_ (#%parens stx ...) . rest)
|
||||
(define out
|
||||
(with-syntax ([(stx* ...) (remove-cruft #'(stx ...))])
|
||||
(phase1:racket-syntax (phase0:racket-syntax (stx* ...)))))
|
||||
(values out #'rest #t)])))
|
||||
|
|
Loading…
Reference in New Issue
Block a user