some more reformatting etc, at all levels (and the schememodname went away, again -- will get it back soon with the lifting of requires)

svn: r13649

original commit: 8f0edfd6d592cc8bfb9d72aca8629224dfa3b0d3
This commit is contained in:
Eli Barzilay 2009-02-16 02:53:01 +00:00
parent 8e9347bc09
commit b4f877bd45

View File

@ -11,19 +11,19 @@
(define (mapping-get mapping id) (define (mapping-get mapping id)
(free-identifier-mapping-get mapping id (lambda () '()))) (free-identifier-mapping-get mapping id (lambda () '())))
;; maps a block identifier to its collected expressions ;; maps a block identifier to its collected expressions
(define code-blocks (make-free-identifier-mapping)) (define chunks (make-free-identifier-mapping))
;; maps a block identifier to all identifiers that are used to define it ;; maps a block identifier to all identifiers that are used to define it
(define block-groups (make-free-identifier-mapping)) (define block-groups (make-free-identifier-mapping))
(define (get-block id) (define (get-block id)
(map syntax-local-introduce (mapping-get code-blocks id))) (map syntax-local-introduce (mapping-get chunks id)))
(define (add-to-block! id exprs) (define (add-to-block! id exprs)
(unless main-id (set! main-id id)) (unless main-id (set! main-id id))
(free-identifier-mapping-put! (free-identifier-mapping-put!
block-groups id block-groups id
(cons (syntax-local-introduce id) (mapping-get block-groups id))) (cons (syntax-local-introduce id) (mapping-get block-groups id)))
(free-identifier-mapping-put! (free-identifier-mapping-put!
code-blocks id chunks id
`(,@(mapping-get code-blocks id) ,@(map syntax-local-introduce exprs))))) `(,@(mapping-get chunks id) ,@(map syntax-local-introduce exprs)))))
(define-syntax (chunk stx) (define-syntax (chunk stx)
(syntax-case stx () (syntax-case stx ()
@ -35,7 +35,7 @@
#f "chunk names must begin and end with angle brackets, <...>" #f "chunk names must begin and end with angle brackets, <...>"
stx #'name)] stx #'name)]
[else (add-to-block! #'name (syntax->list #'(expr ...))) [else (add-to-block! #'name (syntax->list #'(expr ...)))
#`(void)])])) #'(void)])]))
(define-syntax (tangle stx) (define-syntax (tangle stx)
(define block-mentions '()) (define block-mentions '())
@ -67,7 +67,8 @@
(define-syntax (module-begin stx) (define-syntax (module-begin stx)
(syntax-case stx () (syntax-case stx ()
[(module-begin expr ...) [(module-begin expr ...)
(let ([body-code (with-syntax
([(body-code ...)
(let loop ([exprs (syntax->list #'(expr ...))]) (let loop ([exprs (syntax->list #'(expr ...))])
(cond (cond
[(null? exprs) null] [(null? exprs) null]
@ -93,8 +94,6 @@
#%provide))) #%provide)))
(cons expanded (loop (cdr exprs)))] (cons expanded (loop (cdr exprs)))]
[else (loop (cdr exprs))]))]))]) [else (loop (cdr exprs))]))]))])
(with-syntax ([(body-code ...) body-code])
#'(#%module-begin #'(#%module-begin
body-code ... body-code ...
(tangle))))])) (tangle)))]))