benign renamings

pull/111/head
Matthew Butterick 9 years ago
parent b94354ee63
commit c060b8958b

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

@ -36,13 +36,13 @@
(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 (strip-context
(with-syntax ([HERE-KEY (format-id #f "~a" (setup:here-path-key))] (with-syntax ([HERE-KEY (setup:here-path-key)]
[HERE-PATH reader-here-path] [HERE-PATH reader-here-path]
[POLLEN-MOD-NAME 'pollen-module] [POLLEN-MOD-NAME 'pollen-module]
[PARSER-MODE-VALUE (format-symbol "~a" parser-mode)] [PARSER-MODE-VALUE parser-mode]
[DIRECTORY-REQUIRES (require+provide-directory-require-files path-string)] [DIRECTORY-REQUIRES (require+provide-directory-require-files path-string)]
[(SOURCE-LINE ...) source-stx] [SOURCE-LINES source-stx]
[DOC (format-id #f "~a" (setup:main-export))]) [DOC (setup:main-export)])
#'(module runtime-wrapper racket/base #'(module runtime-wrapper racket/base
(module POLLEN-MOD-NAME pollen (module POLLEN-MOD-NAME pollen
(define-meta HERE-KEY HERE-PATH) (define-meta HERE-KEY HERE-PATH)
@ -50,7 +50,7 @@
(provide (except-out (all-defined-out) parser-mode) (provide (except-out (all-defined-out) parser-mode)
(prefix-out inner: parser-mode)) ; avoids conflicts with importing modules (prefix-out inner: parser-mode)) ; avoids conflicts with importing modules
DIRECTORY-REQUIRES DIRECTORY-REQUIRES
SOURCE-LINE ...) . SOURCE-LINES)
(require (submod pollen/private/runtime-config show) 'POLLEN-MOD-NAME) (require (submod pollen/private/runtime-config show) 'POLLEN-MOD-NAME)
(provide (all-from-out 'POLLEN-MOD-NAME)) (provide (all-from-out 'POLLEN-MOD-NAME))
(show DOC inner:parser-mode HERE-PATH))))) ; HERE-PATH acts as "local" runtime config (show DOC inner:parser-mode HERE-PATH))))) ; HERE-PATH acts as "local" runtime config
@ -76,9 +76,9 @@
[(color-lexer) [(color-lexer)
(define my-make-scribble-inside-lexer (define my-make-scribble-inside-lexer
(dynamic-require 'syntax-color/scribble-lexer 'make-scribble-inside-lexer (λ () #f))) (dynamic-require 'syntax-color/scribble-lexer 'make-scribble-inside-lexer (λ () #f)))
(cond [my-make-scribble-inside-lexer (if my-make-scribble-inside-lexer
(my-make-scribble-inside-lexer #:command-char my-command-char)] (my-make-scribble-inside-lexer #:command-char my-command-char)
[else default])] default)]
[(drracket:toolbar-buttons) [(drracket:toolbar-buttons)
(define my-make-drracket-buttons (dynamic-require 'pollen/private/drracket-buttons 'make-drracket-buttons)) (define my-make-drracket-buttons (dynamic-require 'pollen/private/drracket-buttons 'make-drracket-buttons))
(my-make-drracket-buttons my-command-char)])] (my-make-drracket-buttons my-command-char)])]
@ -86,7 +86,7 @@
(define-syntax-rule (reader-module-begin mode expr-to-ignore ...) (define-syntax-rule (reader-module-begin mode expr-to-ignore ...)
(#%module-begin (#%module-begin
(define cgi custom-get-info) ; stash hygienic references to local funcs with new identifiers (define cgi custom-get-info) ; stash hygienic references to local funcs with macro-introduced identifiers
(define cr custom-read) (define cr custom-read) ; so they can be provided out
(define (crs ps p) (custom-read-syntax #:reader-mode mode ps p)) (define (crs ps p) (custom-read-syntax #:reader-mode mode ps p))
(provide (rename-out [cr read][crs read-syntax][cgi get-info])))) (provide (rename-out [cr read][crs read-syntax][cgi get-info]))))

@ -1 +1 @@
1462154178 1462218309

Loading…
Cancel
Save