From bc13980309deace7a9c0dfcbd8155010102da471 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 6 Apr 2008 20:59:28 +0000 Subject: [PATCH] use some #lang lines svn: r9173 original commit: 1a5cb7ed64be900f5f5073c5dc7429aaf232a656 --- collects/scribble/doc/lang/reader.ss | 7 +- collects/scribble/doc/main.ss | 11 ++- collects/scribble/doc/reader.ss | 36 ++++----- collects/scribble/doclang.ss | 115 +++++++++++++-------------- 4 files changed, 82 insertions(+), 87 deletions(-) diff --git a/collects/scribble/doc/lang/reader.ss b/collects/scribble/doc/lang/reader.ss index a9255efd..7fb45817 100644 --- a/collects/scribble/doc/lang/reader.ss +++ b/collects/scribble/doc/lang/reader.ss @@ -1,4 +1,3 @@ -(module reader mzscheme - (require (prefix doc: scribble/doc/reader)) - (provide (rename doc:read read) - (rename doc:read-syntax read-syntax))) +#lang scheme/base +(require (prefix-in doc: scribble/doc/reader)) +(provide (rename-out [doc:read read] [doc:read-syntax read-syntax])) diff --git a/collects/scribble/doc/main.ss b/collects/scribble/doc/main.ss index 6dd33c88..57a38aa7 100644 --- a/collects/scribble/doc/main.ss +++ b/collects/scribble/doc/main.ss @@ -1,6 +1,5 @@ -(module main scheme/base - (define-syntax-rule (out) - (begin (require scribble/doclang) - (provide (all-from-out scribble/doclang)))) - (out)) - +#lang scheme/base +(define-syntax-rule (out) + (begin (require scribble/doclang) + (provide (all-from-out scribble/doclang)))) +(out) diff --git a/collects/scribble/doc/reader.ss b/collects/scribble/doc/reader.ss index e3667508..26113a90 100644 --- a/collects/scribble/doc/reader.ss +++ b/collects/scribble/doc/reader.ss @@ -1,24 +1,22 @@ +#lang scheme/base -(module reader scheme/base - (require (prefix-in scribble: "../reader.ss")) +(require (prefix-in scribble: "../reader.ss")) - (provide (rename-out [*read read]) - (rename-out [*read-syntax read-syntax])) +(provide (rename-out [*read read]) + (rename-out [*read-syntax read-syntax])) - (define (*read [inp (current-input-port)]) - (wrap inp (scribble:read-inside inp))) +(define (*read [inp (current-input-port)]) + (wrap inp (scribble:read-inside inp))) - (define (*read-syntax [src #f] [port (current-input-port)]) - (wrap port (scribble:read-syntax-inside src port))) +(define (*read-syntax [src #f] [port (current-input-port)]) + (wrap port (scribble:read-syntax-inside src port))) - (define (wrap port body) - (let* ([p-name (object-name port)] - [name (if (path? p-name) - (let-values ([(base name dir?) (split-path p-name)]) - (string->symbol (path->string (path-replace-suffix name #"")))) - 'page)] - [id 'doc]) - `(module ,name scribble/doclang - (#%module-begin - ,id () - . ,body))))) +(define (wrap port body) + (let* ([p-name (object-name port)] + [name (if (path? p-name) + (let-values ([(base name dir?) (split-path p-name)]) + (string->symbol (path->string (path-replace-suffix name #"")))) + 'page)] + [id 'doc]) + `(module ,name scribble/doclang + (#%module-begin ,id () . ,body)))) diff --git a/collects/scribble/doclang.ss b/collects/scribble/doclang.ss index 7f269115..331c7b8f 100644 --- a/collects/scribble/doclang.ss +++ b/collects/scribble/doclang.ss @@ -1,63 +1,62 @@ +#lang scheme/base -(module doclang scheme/base - (require "struct.ss" - "decode.ss" - (for-syntax scheme/base - syntax/kerncase)) +(require "struct.ss" + "decode.ss" + (for-syntax scheme/base + syntax/kerncase)) - (provide (except-out (all-from-out scheme/base) #%module-begin) - (rename-out [*module-begin #%module-begin])) +(provide (except-out (all-from-out scheme/base) #%module-begin) + (rename-out [*module-begin #%module-begin])) - ;; Module wrapper ---------------------------------------- +;; Module wrapper ---------------------------------------- - (define-syntax (*module-begin stx) - (syntax-case stx () - [(_ id exprs . body) - #'(#%module-begin - (doc-begin id exprs . body))])) +(define-syntax (*module-begin stx) + (syntax-case stx () + [(_ id exprs . body) + #'(#%module-begin + (doc-begin id exprs . body))])) - (define-syntax (doc-begin stx) - (syntax-case stx () - [(_ m-id (expr ...)) - #`(begin - (define m-id (decode (list . #,(reverse (syntax->list #'(expr ...)))))) - (provide m-id))] - [(_ m-id exprs . body) - ;; `body' probably starts with lots of string constants; - ;; it's slow to trampoline on every string, so do them - ;; in a batch here: - (let loop ([body #'body] - [accum null]) - (syntax-case body () - [(s . rest) - (string? (syntax-e #'s)) - (loop #'rest (cons #'s accum))] - [() - (with-syntax ([(accum ...) accum]) - #`(doc-begin m-id (accum ... . exprs)))] - [(body1 . body) - (with-syntax ([exprs (append accum #'exprs)]) - (let ([expanded (local-expand #'body1 - 'module - (append - (kernel-form-identifier-list) - (syntax->list #'(provide - require - #%provide - #%require))))]) - (syntax-case expanded (begin) - [(begin body1 ...) - #`(doc-begin m-id exprs body1 ... . body)] - [(id . rest) - (and (identifier? #'id) - (ormap (lambda (kw) (free-identifier=? #'id kw)) - (syntax->list #'(require - provide - define-values - define-syntaxes - define-for-syntaxes - #%require - #%provide)))) - #`(begin #,expanded (doc-begin m-id exprs . body))] - [_else - #`(doc-begin m-id (#,expanded . exprs) . body)])))]))]))) +(define-syntax (doc-begin stx) + (syntax-case stx () + [(_ m-id (expr ...)) + #`(begin + (define m-id (decode (list . #,(reverse (syntax->list #'(expr ...)))))) + (provide m-id))] + [(_ m-id exprs . body) + ;; `body' probably starts with lots of string constants; it's + ;; slow to trampoline on every string, so do them in a batch + ;; here: + (let loop ([body #'body] + [accum null]) + (syntax-case body () + [(s . rest) + (string? (syntax-e #'s)) + (loop #'rest (cons #'s accum))] + [() + (with-syntax ([(accum ...) accum]) + #`(doc-begin m-id (accum ... . exprs)))] + [(body1 . body) + (with-syntax ([exprs (append accum #'exprs)]) + (let ([expanded (local-expand + #'body1 'module + (append (kernel-form-identifier-list) + (syntax->list #'(provide + require + #%provide + #%require))))]) + (syntax-case expanded (begin) + [(begin body1 ...) + #`(doc-begin m-id exprs body1 ... . body)] + [(id . rest) + (and (identifier? #'id) + (ormap (lambda (kw) (free-identifier=? #'id kw)) + (syntax->list #'(require + provide + define-values + define-syntaxes + define-for-syntaxes + #%require + #%provide)))) + #`(begin #,expanded (doc-begin m-id exprs . body))] + [_else + #`(doc-begin m-id (#,expanded . exprs) . body)])))]))]))