second wave of mutilation

pull/111/head
Matthew Butterick 9 years ago
parent 54a25039e5
commit 5bfc461cd0

@ -16,46 +16,46 @@
(syntax-case stx () (syntax-case stx ()
[(_ <expr> (... ...)) [(_ <expr> (... ...))
(let-values ([(meta-hash expr-without-metas) (split-metas (syntax->datum #'(<expr> (... ...))) (setup:define-meta-name))]) (let-values ([(meta-hash expr-without-metas) (split-metas (syntax->datum #'(<expr> (... ...))) (setup:define-meta-name))])
(with-syntax ([<meta-hash> meta-hash] (with-syntax ([META-HASH meta-hash]
[(<expr-without-metas> (... ...)) expr-without-metas] [(EXPR-WITHOUT-METAS (... ...)) expr-without-metas]
[<metas> (format-id #f "~a" (setup:meta-export))] [METAS (format-id #f "~a" (setup:meta-export))]
[<meta-mod> (format-symbol "~a" (setup:meta-export))] [META-MOD (format-symbol "~a" (setup:meta-export))]
[<root> (format-id #f "~a" (setup:main-root-node))] [ROOT (format-id #f "~a" (setup:main-root-node))]
[<newline> (datum->syntax #f (setup:newline))] [NEWLINE (datum->syntax #f (setup:newline))]
[<mode-pagetree> default-mode-pagetree] [MODE-PAGETREE default-mode-pagetree]
[<mode-markup> default-mode-markup] [MODE-MARKUP default-mode-markup]
[<mode-markdown> default-mode-markdown] [MODE-MARKDOWN default-mode-markdown]
[<splicing_tag> (setup:splicing-tag)] [SPLICING-TAG (setup:splicing-tag)]
[<doc> (format-id #f "~a" (setup:main-export))] [DOC (format-id #f "~a" (setup:main-export))]
[<doc-raw> (generate-temporary 'pollen-)]); prevents conflicts with other imported Pollen sources [DOC-RAW (generate-temporary 'pollen-)]); prevents conflicts with other imported Pollen sources
(replace-context #'(<expr> (... ...)) (replace-context #'(<expr> (... ...))
#'(#%module-begin #'(#%module-begin
(module <meta-mod> racket/base (module META-MOD racket/base
(provide <metas>) (provide METAS)
(define <metas> <meta-hash>)) (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.
(require pollen/top pollen/setup pollen/core) (require pollen/top pollen/setup pollen/core)
(require (submod ".." <meta-mod>)) (require (submod ".." META-MOD))
(provide (all-defined-out) #%top (all-from-out (submod ".." <meta-mod>) pollen/core)) (provide (all-defined-out) #%top (all-from-out (submod ".." META-MOD) pollen/core))
<expr-without-metas> (... ...)) EXPR-WITHOUT-METAS (... ...))
(require 'inner) (require 'inner)
(define <doc> (define DOC
(let* ([parser-mode-undefined? (procedure? inner:parser-mode)] ; if undefined, #%top makes it a procedure (let* ([parser-mode-undefined? (procedure? inner:parser-mode)] ; if undefined, #%top makes it a procedure
[parser-mode (if parser-mode-undefined? <parser-mode-in> inner:parser-mode)] [parser-mode (if parser-mode-undefined? <parser-mode-in> inner:parser-mode)]
[proc (case parser-mode [proc (case parser-mode
[(<mode-pagetree>) decode-pagetree] [(MODE-PAGETREE) decode-pagetree]
[(<mode-markup>) (λ(xs) (apply <root> xs))] ; if `root` undefined, it becomes a default tag function [(MODE-MARKUP) (λ(xs) (apply ROOT xs))] ; if `root` undefined, it becomes a default tag function
[(<mode-markdown>) [(MODE-MARKDOWN)
(λ(xs) (apply <root> (map strip-empty-attrs ((dynamic-require 'markdown 'parse-markdown) (apply string-append (map to-string xs))))))] (λ(xs) (apply ROOT (map strip-empty-attrs ((dynamic-require 'markdown 'parse-markdown) (apply string-append (map to-string xs))))))]
[else (λ(xs) (apply string-append (map to-string xs)))])] ; string output for preprocessor [else (λ(xs) (apply string-append (map to-string xs)))])] ; string output for preprocessor
;; drop leading newlines, as they're often the result of `defines` and `requires` ;; drop leading newlines, as they're often the result of `defines` and `requires`
[doc-elements (or (memf (λ(ln) (not (equal? ln <newline>))) <doc-raw>) null)] [doc-elements (or (memf (λ(ln) (not (equal? ln NEWLINE))) DOC-RAW) null)]
[doc-elements-spliced (splice doc-elements '<splicing_tag>)]) [doc-elements-spliced (splice doc-elements 'SPLICING-TAG)])
(proc doc-elements-spliced))) (proc doc-elements-spliced)))
(provide <doc> <metas> (except-out (all-from-out 'inner) <doc-raw> #%top))))))])) (provide DOC METAS (except-out (all-from-out 'inner) DOC-RAW #%top))))))]))
<outer-expr> ...)) <outer-expr> ...))

@ -35,15 +35,14 @@
(define reader-here-path (path-string->here-path path-string)) (define reader-here-path (path-string->here-path path-string))
(define parser-mode (infer-parser-mode reader-mode reader-here-path)) (define parser-mode (infer-parser-mode reader-mode reader-here-path))
(define parsed-syntax (define parsed-syntax
(strip-context
(with-syntax ([HERE-KEY (format-id #f "~a" (setup:here-path-key))] (with-syntax ([HERE-KEY (format-id #f "~a" (setup:here-path-key))]
[HERE-PATH (datum->syntax #f reader-here-path)] [HERE-PATH reader-here-path]
[POLLEN-MOD (format-symbol "~a" (gensym))] ; prevents conflicts with other imported Pollen sources [POLLEN-MOD (format-symbol "~a" (gensym))] ; prevents conflicts with other imported Pollen sources
[PARSER-MODE-VALUE (format-symbol "~a" parser-mode)] [PARSER-MODE-VALUE (format-symbol "~a" parser-mode)]
[DIRECTORY-REQUIRES (datum->syntax #f (require+provide-directory-require-files path-string))] [DIRECTORY-REQUIRES (require+provide-directory-require-files path-string)]
[(SOURCE-LINE ...) source-stx] [(SOURCE-LINE ...) source-stx]
[DOC (format-id #f "~a" (setup:main-export))]) [DOC (format-id #f "~a" (setup:main-export))])
(replace-context
source-stx
#'(module runtime-wrapper racket/base #'(module runtime-wrapper racket/base
(module POLLEN-MOD pollen (module POLLEN-MOD pollen
(define-meta HERE-KEY HERE-PATH) (define-meta HERE-KEY HERE-PATH)

@ -1 +1 @@
1459991298 1460223406

Loading…
Cancel
Save