|
|
@ -2,6 +2,7 @@
|
|
|
|
(require racket/list)
|
|
|
|
(require racket/list)
|
|
|
|
(require (planet mb/pollen/tools) (planet mb/pollen/main-helper))
|
|
|
|
(require (planet mb/pollen/tools) (planet mb/pollen/main-helper))
|
|
|
|
(require (only-in (planet mb/pollen/pmap) pmap-decode))
|
|
|
|
(require (only-in (planet mb/pollen/pmap) pmap-decode))
|
|
|
|
|
|
|
|
(require (only-in (planet mb/pollen/predicates) pmap?))
|
|
|
|
(require (only-in (planet mb/pollen/pollen-file-tools) has-ext?))
|
|
|
|
(require (only-in (planet mb/pollen/pollen-file-tools) has-ext?))
|
|
|
|
(require (only-in (planet mb/pollen/world) POLLEN_MAP_EXT))
|
|
|
|
(require (only-in (planet mb/pollen/world) POLLEN_MAP_EXT))
|
|
|
|
(provide (except-out (all-from-out racket/base) #%module-begin)
|
|
|
|
(provide (except-out (all-from-out racket/base) #%module-begin)
|
|
|
@ -10,30 +11,35 @@
|
|
|
|
(define-syntax-rule (module-begin expr ...)
|
|
|
|
(define-syntax-rule (module-begin expr ...)
|
|
|
|
(#%module-begin
|
|
|
|
(#%module-begin
|
|
|
|
|
|
|
|
|
|
|
|
; this is here only so that dynamic-rerequire of a pollen module
|
|
|
|
;; this is here only so that dynamic-rerequire of a pollen module
|
|
|
|
; transitively reloads the extras also.
|
|
|
|
;; transitively reloads the extras also.
|
|
|
|
; if this isn't here, then dynamic-rerequire can't see them
|
|
|
|
;; if this isn't here, then dynamic-rerequire can't see them
|
|
|
|
; and thus they are not tracked for changes.
|
|
|
|
;; and thus they are not tracked for changes.
|
|
|
|
(require-extras)
|
|
|
|
(require-extras)
|
|
|
|
|
|
|
|
|
|
|
|
; We want our module language to support require & provide
|
|
|
|
;; We want our module language to support require & provide
|
|
|
|
; which are only supported at the module level, so ...
|
|
|
|
;; which are only supported at the module level, so ...
|
|
|
|
; create a submodule to contain the input
|
|
|
|
;; create a submodule to contain the input
|
|
|
|
; and export as needed
|
|
|
|
;; and export as needed
|
|
|
|
|
|
|
|
|
|
|
|
; doclang2_raw is a clone of scribble/doclang2 with decode disabled
|
|
|
|
;; doclang2_raw is a clone of scribble/doclang2 with decode disabled
|
|
|
|
; helpful because it collects & exports content via 'doc
|
|
|
|
;; helpful because it collects & exports content via 'doc
|
|
|
|
(module pollen-inner (planet mb/pollen/lang/doclang2_raw)
|
|
|
|
(module pollen-inner (planet mb/pollen/lang/doclang2_raw)
|
|
|
|
; use same requires as top of main.rkt
|
|
|
|
;; use same requires as top of main.rkt
|
|
|
|
; (can't import them from surrounding module due to submodule rules)
|
|
|
|
;; (can't import them from surrounding module due to submodule rules)
|
|
|
|
(require (planet mb/pollen/tools) (planet mb/pollen/main-helper))
|
|
|
|
(require (planet mb/pollen/tools) (planet mb/pollen/main-helper))
|
|
|
|
|
|
|
|
(require (only-in (planet mb/pollen/pmap) pmap-subtopic))
|
|
|
|
(require-extras #:provide #t) ; brings in the project require files
|
|
|
|
(require-extras #:provide #t) ; brings in the project require files
|
|
|
|
|
|
|
|
|
|
|
|
; #%top binding catches ids that aren't defined
|
|
|
|
;; #%top binding catches ids that aren't defined
|
|
|
|
; here, convert them to basic xexpr
|
|
|
|
;; here, convert them to basic xexpr
|
|
|
|
; #%top is a syntax transformer that returns a function
|
|
|
|
;; #%top is a syntax transformer that returns a function
|
|
|
|
; λ x captures all the args (vs. λ(x), which only catches one)
|
|
|
|
;; λ x captures all the args (vs. λ(x), which only catches one)
|
|
|
|
; and id is not spliced because it's syntax, not a true variable
|
|
|
|
;; and id is not spliced because it's syntax, not a true variable
|
|
|
|
|
|
|
|
;; WARNING! This is convenient for writing pollen documents
|
|
|
|
|
|
|
|
;; (which is why it works this way)
|
|
|
|
|
|
|
|
;; but it makes debugging tricky, because an undefined (symbol item ...)
|
|
|
|
|
|
|
|
;; is just treated as a valid tagged-xexpr, not an undefined function.
|
|
|
|
(define-syntax-rule (#%top . id)
|
|
|
|
(define-syntax-rule (#%top . id)
|
|
|
|
(λ x `(id ,@x)))
|
|
|
|
(λ x `(id ,@x)))
|
|
|
|
|
|
|
|
|
|
|
@ -48,25 +54,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
;; prepare the elements, and append inner-here as meta.
|
|
|
|
;; prepare the elements, and append inner-here as meta.
|
|
|
|
(define all-elements (append
|
|
|
|
(define all-elements (append
|
|
|
|
|
|
|
|
;; append inner-here as meta
|
|
|
|
|
|
|
|
;; put it first so it can be overridden by custom meta later on
|
|
|
|
|
|
|
|
(list `(meta "here" ,inner-here))
|
|
|
|
(cond
|
|
|
|
(cond
|
|
|
|
;; doc is probably a list, but might be a single string
|
|
|
|
;; doc is probably a list, but might be a single string
|
|
|
|
[(string? doc) (list doc)]
|
|
|
|
[(string? doc) (list doc)]
|
|
|
|
[(tagged-xexpr? doc) (list doc)] ; if it's a single nx, just leave it
|
|
|
|
[(tagged-xexpr? doc) (list doc)] ; if it's a single nx, just leave it
|
|
|
|
[(list? doc) doc]) ; if it's nx content, splice it in
|
|
|
|
[(list? doc) doc]))) ; if it's nx content, splice it in
|
|
|
|
(list `(meta "here" ,inner-here)))) ; append inner-here as meta
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; split out the metas now (in raw form)
|
|
|
|
;; split out the metas now (in raw form)
|
|
|
|
(define-values (main-raw metas-raw)
|
|
|
|
(define-values (metas-raw main-raw)
|
|
|
|
(extract-tag-from-xexpr 'meta (make-tagged-xexpr 'irrelevant-tag empty all-elements)))
|
|
|
|
(split-tag-from-xexpr 'meta (make-tagged-xexpr 'irrelevant-tag empty all-elements)))
|
|
|
|
|
|
|
|
|
|
|
|
(define metas (make-meta-hash metas-raw))
|
|
|
|
(define metas (make-meta-hash metas-raw))
|
|
|
|
|
|
|
|
|
|
|
|
;; Policy: here in the core lang, do as little to main as possible.
|
|
|
|
;; Policy: here in the core lang, do as little to main as possible.
|
|
|
|
;; The point is just to set it up for further processing.
|
|
|
|
;; The point is just to set it up for further processing.
|
|
|
|
;; One of the annoyances of Scribble is its insistence on decoding.
|
|
|
|
;; Unlike Scribble, which insists on decoding,
|
|
|
|
;; Better just to pass through the minimally processed data.
|
|
|
|
;; Pollen just passes through the minimally processed data.
|
|
|
|
;; one exception: if file extension marks it as pmap, send it to the pmap decoder instead.
|
|
|
|
;; one exception: if file extension marks it as pmap, send it to the pmap decoder instead.
|
|
|
|
(define main (apply (if ((->path (get metas "here")) . has-ext? . POLLEN_MAP_EXT)
|
|
|
|
(define source-is-pmap?
|
|
|
|
|
|
|
|
;; this tests inner-here (which is always the file name)
|
|
|
|
|
|
|
|
;; rather than (get metas 'here) which might have been overridden.
|
|
|
|
|
|
|
|
;; Because if it's overridden to something other than *.pmap,
|
|
|
|
|
|
|
|
;; pmap processing will fail.
|
|
|
|
|
|
|
|
;; This defeats rule that pmap file suffix triggers pmap decoding.
|
|
|
|
|
|
|
|
((->path inner-here) . has-ext? . POLLEN_MAP_EXT))
|
|
|
|
|
|
|
|
(define main (apply (if source-is-pmap?
|
|
|
|
pmap-decode
|
|
|
|
pmap-decode
|
|
|
|
;; most files will go this way.
|
|
|
|
;; most files will go this way.
|
|
|
|
;; Root is treated as a function.
|
|
|
|
;; Root is treated as a function.
|
|
|
@ -80,11 +96,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
(module+ main
|
|
|
|
(module+ main
|
|
|
|
(displayln ";-------------------------")
|
|
|
|
(displayln ";-------------------------")
|
|
|
|
(displayln "; pollen decoded 'main")
|
|
|
|
(displayln (string-append "; pollen decoded 'main" (if source-is-pmap? " (as pmap)" "")))
|
|
|
|
(displayln ";-------------------------")
|
|
|
|
(displayln ";-------------------------")
|
|
|
|
main
|
|
|
|
main
|
|
|
|
(displayln "")
|
|
|
|
(displayln "")
|
|
|
|
(displayln (format "(tagged-xexpr? main) ~a" (tagged-xexpr? main)))
|
|
|
|
|
|
|
|
|
|
|
|
(if source-is-pmap?
|
|
|
|
|
|
|
|
(displayln (format "(pmap? main) ~a" (pmap? main)))
|
|
|
|
|
|
|
|
(displayln (format "(tagged-xexpr? main) ~a" (tagged-xexpr? main))))
|
|
|
|
(displayln "")
|
|
|
|
(displayln "")
|
|
|
|
(displayln ";-------------------------")
|
|
|
|
(displayln ";-------------------------")
|
|
|
|
(displayln "; pollen 'metas")
|
|
|
|
(displayln "; pollen 'metas")
|
|
|
|