s-exp module reader

svn: r7787
This commit is contained in:
Matthew Flatt 2007-11-20 17:08:20 +00:00
parent 65496a2b8e
commit 34a5cdf8ed
3 changed files with 32 additions and 0 deletions

3
collects/s-exp/info.ss Normal file
View File

@ -0,0 +1,3 @@
(module info setup/infotab
(define name "S-expression Module"))

View File

@ -0,0 +1,3 @@
(module info setup/infotab
(define name "S-expression Module reader"))

View File

@ -0,0 +1,26 @@
(module reader scheme/base
(provide (rename-out [*read read]
[*read-syntax read-syntax]))
(define (*read in)
(wrap in read))
(define (*read-syntax src in)
(wrap in (lambda (in)
(read-syntax src in))))
(define (wrap port read)
(let ([body
(let loop ([a null])
(let ([v (read port)])
(if (eof-object? v)
(reverse a)
(loop (cons v a)))))])
(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 . ,body)))))