relocate meta hashmaking

pull/110/head
Matthew Butterick 9 years ago
parent 02cdc44a4f
commit 81f9b51bbc

@ -10,10 +10,9 @@
(define-syntax (pollen-module-begin stx) (define-syntax (pollen-module-begin stx)
(syntax-case stx () (syntax-case stx ()
[(_ EXPR (... ...)) [(_ EXPR (... ...))
(let*-values ([(meta-keys meta-values expr-without-metas) (split-metas (syntax->datum #'(EXPR (... ...))) (world:current-define-meta-name))]) (let-values ([(meta-hash expr-without-metas) (split-metas (syntax->datum #'(EXPR (... ...))) (world:current-define-meta-name))])
(with-syntax ([(EXPR-WITHOUT-METAS (... ...)) (datum->syntax #'(EXPR (... ...)) expr-without-metas)] (with-syntax ([META-HASH (datum->syntax #'(EXPR (... ...)) meta-hash)]
[(KEY (... ...)) (datum->syntax #'(EXPR (... ...)) meta-keys)] [(EXPR-WITHOUT-METAS (... ...)) (datum->syntax #'(EXPR (... ...)) expr-without-metas)]
[(VALUE (... ...)) (datum->syntax #'(EXPR (... ...)) meta-values)]
[METAS (format-id #'(EXPR (... ...)) "~a" (world:current-meta-export))] [METAS (format-id #'(EXPR (... ...)) "~a" (world:current-meta-export))]
[META-MOD (format-symbol "~a" (world:current-meta-export))] [META-MOD (format-symbol "~a" (world:current-meta-export))]
[ROOT (format-id #'(EXPR (... ...)) "~a" (world:current-main-root-node))] [ROOT (format-id #'(EXPR (... ...)) "~a" (world:current-main-root-node))]
@ -27,8 +26,8 @@
(replace-context #'(EXPR (... ...)) (replace-context #'(EXPR (... ...))
#'(#%module-begin #'(#%module-begin
(module META-MOD racket/base (module META-MOD racket/base
(provide (all-defined-out)) (provide METAS)
(define METAS (apply hasheq (append (list 'KEY VALUE) (... ...))))) (define METAS META-HASH))
(module inner pollen/private/doclang-raw (module inner pollen/private/doclang-raw
DOC-RAW ; positional arg for doclang-raw that sets name of export. DOC-RAW ; positional arg for doclang-raw that sets name of export.

@ -17,5 +17,11 @@
(map loop (filter non-meta?/gather x)) (map loop (filter non-meta?/gather x))
x))) x)))
(let ([meta-key cadr][meta-value caddr]) (values (apply hasheq (apply append (map cdr matches))) rest))
(values (map meta-key matches) (map meta-value matches) rest)))
(module+ test
(require rackunit)
(define x '(root (div (define-meta foo "bar") "hi") "zim" "zam"))
(define-values (metas rest) (split-metas x 'define-meta))
(check-equal? metas '#hasheq((foo . "bar")))
(check-equal? rest '(root (div "hi") "zim" "zam")))
Loading…
Cancel
Save