From db46a175b5202730f5338eb5669fff1334da2662 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Wed, 10 Feb 2016 11:07:18 -0800 Subject: [PATCH] experiment --- pollen/main.rkt | 10 ++++------ pollen/markdown.rkt | 10 ++++------ pollen/markup.rkt | 10 ++++------ pollen/pre.rkt | 10 ++++------ pollen/private/main-base.rkt | 19 ++++++++++++++----- pollen/ptree.rkt | 10 ++++------ 6 files changed, 34 insertions(+), 35 deletions(-) diff --git a/pollen/main.rkt b/pollen/main.rkt index b6ab87e..f8fca88 100644 --- a/pollen/main.rkt +++ b/pollen/main.rkt @@ -1,7 +1,5 @@ -#lang racket/base -(require "private/main-base.rkt") +(module main "private/main-base.rkt" + default-mode-preproc -(define+provide-module-begin-in-mode default-mode-preproc) ; because default mode in submodule is preproc - -(module reader "private/reader-base.rkt" - default-mode-auto) \ No newline at end of file + (module reader "private/reader-base.rkt" + default-mode-auto)) diff --git a/pollen/markdown.rkt b/pollen/markdown.rkt index 3321656..acbec9e 100644 --- a/pollen/markdown.rkt +++ b/pollen/markdown.rkt @@ -1,7 +1,5 @@ -#lang racket/base -(require "private/main-base.rkt") +(module markdown "private/main-base.rkt" + default-mode-markdown -(define+provide-module-begin-in-mode default-mode-markdown) - -(module reader "private/reader-base.rkt" - default-mode-markdown) + (module reader "private/reader-base.rkt" + default-mode-markdown)) diff --git a/pollen/markup.rkt b/pollen/markup.rkt index f7974fe..4d9f4ea 100644 --- a/pollen/markup.rkt +++ b/pollen/markup.rkt @@ -1,7 +1,5 @@ -#lang racket/base -(require "private/main-base.rkt") +(module markup "private/main-base.rkt" + default-mode-markup -(define+provide-module-begin-in-mode default-mode-markup) - -(module reader "private/reader-base.rkt" - default-mode-markup) + (module reader "private/reader-base.rkt" + default-mode-markup)) diff --git a/pollen/pre.rkt b/pollen/pre.rkt index 4f92f1b..42710f4 100644 --- a/pollen/pre.rkt +++ b/pollen/pre.rkt @@ -1,7 +1,5 @@ -#lang racket/base -(require "private/main-base.rkt") +(module pre "private/main-base.rkt" + default-mode-preproc -(define+provide-module-begin-in-mode default-mode-preproc) - -(module reader "private/reader-base.rkt" - default-mode-preproc) + (module reader "private/reader-base.rkt" + default-mode-preproc)) diff --git a/pollen/private/main-base.rkt b/pollen/private/main-base.rkt index 152eead..2912ae2 100644 --- a/pollen/private/main-base.rkt +++ b/pollen/private/main-base.rkt @@ -1,10 +1,14 @@ #lang racket/base (require (for-syntax racket/base syntax/strip-context racket/syntax "../setup.rkt" "split-metas.rkt") - "to-string.rkt" "../pagetree.rkt" "splice.rkt" "../setup.rkt" ) ; need world here to resolve PARSER-MODE-ARG -(provide (all-defined-out)) + "to-string.rkt" "../pagetree.rkt" "splice.rkt" "../setup.rkt") +(require "../setup.rkt") +(provide (except-out (all-from-out racket/base) #%module-begin) + (all-from-out "../setup.rkt") + (rename-out [dialect-module-begin #%module-begin])) -(define-syntax-rule (define+provide-module-begin-in-mode PARSER-MODE-ARG) +(define-syntax-rule (make-pollen-module-begin PARSER-MODE-IN) (begin + (require racket/base) (provide (except-out (all-from-out racket/base) #%module-begin) (rename-out [pollen-module-begin #%module-begin])) (define-syntax (pollen-module-begin stx) @@ -40,7 +44,7 @@ (define DOC (let* ([parser-mode-undefined? (procedure? inner:parser-mode)] ; if undefined, #%top makes it a procedure - [parser-mode (if parser-mode-undefined? PARSER-MODE-ARG inner:parser-mode)] + [parser-mode (if parser-mode-undefined? PARSER-MODE-IN inner:parser-mode)] [proc (cond [(eq? parser-mode 'MODE-PAGETREE) decode-pagetree] [(eq? parser-mode 'MODE-MARKUP) (λ(xs) (apply ROOT xs))] ; if `root` undefined, it becomes a default tag function @@ -52,4 +56,9 @@ [doc-elements-spliced (splice doc-elements 'SPLICING_TAG)]) (proc doc-elements-spliced))) - (provide DOC METAS (except-out (all-from-out 'inner) DOC-RAW #%top))))))])))) ; hide internal exports \ No newline at end of file + (provide DOC METAS (except-out (all-from-out 'inner) DOC-RAW #%top))))))])))) + +(define-syntax-rule (dialect-module-begin MODE EXPR ...) + (#%module-begin + (make-pollen-module-begin MODE) + EXPR ...)) \ No newline at end of file diff --git a/pollen/ptree.rkt b/pollen/ptree.rkt index 14665b5..88cc0af 100644 --- a/pollen/ptree.rkt +++ b/pollen/ptree.rkt @@ -1,7 +1,5 @@ -#lang racket/base -(require "private/main-base.rkt") +(module ptree "private/main-base.rkt" + default-mode-pagetree -(define+provide-module-begin-in-mode default-mode-pagetree) - -(module reader "private/reader-base.rkt" - default-mode-pagetree) + (module reader "private/reader-base.rkt" + default-mode-pagetree))