diff --git a/collects/honu/core/main.rkt b/collects/honu/core/main.rkt index 67c43b90e6..f7aa0405e3 100644 --- a/collects/honu/core/main.rkt +++ b/collects/honu/core/main.rkt @@ -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] diff --git a/collects/honu/core/private/macro2.rkt b/collects/honu/core/private/macro2.rkt index 0e535468e0..20d476ef80 100644 --- a/collects/honu/core/private/macro2.rkt +++ b/collects/honu/core/private/macro2.rkt @@ -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)])))