use configure-runtime submodule

pull/139/head
Matthew Butterick 7 years ago
parent 877d3580dd
commit e41955fe05

@ -1,7 +0,0 @@
#lang racket/base
(provide get-language-info)
(define (get-language-info top-here-path)
(λ(key default)
(case key
[(configure-runtime) `(#(pollen/private/runtime-config configure ,top-here-path))]
[else default])))

@ -34,33 +34,32 @@
(read-inner path-string p))) (read-inner path-string p)))
(define reader-here-path (path-string->here-path path-string)) (define reader-here-path (path-string->here-path path-string))
(define parser-mode-from-reader (infer-parser-mode reader-mode reader-here-path)) (define parser-mode-from-reader (infer-parser-mode reader-mode reader-here-path))
(define parsed-syntax (strip-context
(strip-context (with-syntax* ([HERE-KEY (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] [DIRECTORY-REQUIRES (require+provide-directory-require-files path-string)]
[DIRECTORY-REQUIRES (require+provide-directory-require-files path-string)] [SOURCE-LINES source-stx]
[SOURCE-LINES source-stx] [DOC (setup:main-export)]
[DOC (setup:main-export)] [META-MOD (setup:meta-export)]
[META-MOD (setup:meta-export)] [PARSER-MODE-FROM-READER parser-mode-from-reader]
[PARSER-MODE-FROM-READER parser-mode-from-reader] [POLLEN-MODULE-SYNTAX (let ([mod-stx #'(module POLLEN-MOD-NAME pollen
[POLLEN-MODULE-SYNTAX (let ([mod-stx #'(module POLLEN-MOD-NAME pollen (define-meta HERE-KEY HERE-PATH)
(define-meta HERE-KEY HERE-PATH) (provide (all-defined-out))
(provide (all-defined-out)) DIRECTORY-REQUIRES
DIRECTORY-REQUIRES . SOURCE-LINES)])
. SOURCE-LINES)]) (syntax-property mod-stx 'parser-mode-from-reader parser-mode-from-reader))])
(syntax-property mod-stx 'parser-mode-from-reader parser-mode-from-reader))]) #'(module runtime-wrapper racket/base
#'(module runtime-wrapper racket/base (module configure-runtime racket/base
POLLEN-MODULE-SYNTAX (require pollen/private/runtime-config)
(module META-MOD racket/base (configure HERE-PATH)) ; HERE-PATH acts as "top" runtime config when module is main
(require (submod ".." POLLEN-MOD-NAME META-MOD)) POLLEN-MODULE-SYNTAX
(provide (all-from-out (submod ".." POLLEN-MOD-NAME META-MOD)))) (module META-MOD racket/base
(require (submod pollen/private/runtime-config show) 'POLLEN-MOD-NAME) (require (submod ".." POLLEN-MOD-NAME META-MOD))
(provide (all-from-out 'POLLEN-MOD-NAME)) (provide (all-from-out (submod ".." POLLEN-MOD-NAME META-MOD))))
(show DOC 'PARSER-MODE-FROM-READER HERE-PATH))))) ; HERE-PATH acts as "local" runtime config (require (only-in pollen/private/runtime-config show) 'POLLEN-MOD-NAME)
(syntax-property parsed-syntax (provide (all-from-out 'POLLEN-MOD-NAME))
'module-language (show DOC 'PARSER-MODE-FROM-READER HERE-PATH))))) ; HERE-PATH otherwise acts as "local" runtime config
`#(pollen/private/language-info get-language-info ,reader-here-path))) ; reader-here-path acts as "top" runtime config
(define (custom-get-info in mod line col pos) (define (custom-get-info in mod line col pos)
;; DrRacket caches source file information per session, ;; DrRacket caches source file information per session,

@ -1,10 +1,9 @@
#lang racket/base #lang racket/base
(require pollen/setup scribble/reader) (require pollen/setup scribble/reader)
(provide configure) (provide (all-defined-out))
(module+ show (provide show)) ; `show` submodule requested by module wrapper in "reader-base.rkt"
(define current-top-path (make-parameter #f)) (define current-top-path (make-parameter #f))
(define (show doc parser-mode here-path) (define (show doc parser-mode here-path)
;; we only want the top doc to print in the runtime environment ;; we only want the top doc to print in the runtime environment
;; otherwise if a Pollen source imports others, they will all print their docs in sequence. ;; otherwise if a Pollen source imports others, they will all print their docs in sequence.
@ -18,10 +17,8 @@
((dynamic-require 'racket/string 'string-join) (cdr ((dynamic-require 'racket/string 'string-split) (exn-message exn) ": ")) ": "))))]) ((dynamic-require 'racket/string 'string-join) (cdr ((dynamic-require 'racket/string 'string-split) (exn-message exn) ": ")) ": "))))])
((dynamic-require 'txexpr/base 'validate-txexpr) doc))))))) ((dynamic-require 'txexpr/base 'validate-txexpr) doc)))))))
(define (configure top-here-path) (define (configure top-here-path)
;; puts `show` into the right mode (current-top-path top-here-path) ;; puts `show` into the right mode
(current-top-path top-here-path)
;; wrap REPL interactions with pollen expression support ;; wrap REPL interactions with pollen expression support
(define old-read (current-read-interaction)) (define old-read (current-read-interaction))

@ -1 +1 @@
1484772880 1484775689

Loading…
Cancel
Save