set props and a little better code for syntax in scribble file

svn: r11952
This commit is contained in:
Eli Barzilay 2008-10-06 17:24:16 +00:00
parent dd20d88776
commit 499fc08d0d

View File

@ -1,6 +1,6 @@
#lang scribble/doc #lang scribble/doc
@(require "common.ss") @(require "common.ss")
@(require scheme/runtime-path (for-syntax scheme/port scheme/base)) @(require scheme/runtime-path (for-syntax scheme/port scheme/base scheme/path))
@(define-runtime-path cn "../chat-noir/chat-noir.ss") @(define-runtime-path cn "../chat-noir/chat-noir.ss")
@gametitle["Chat Noir" "chat-noir" "Puzzle Game"] @gametitle["Chat Noir" "chat-noir" "Puzzle Game"]
@ -15,45 +15,42 @@ The game was inspired by this one the one at
@link["http://www.gamedesign.jp/flash/chatnoir/chatnoir.html"]{Game Design} @link["http://www.gamedesign.jp/flash/chatnoir/chatnoir.html"]{Game Design}
and has essentailly the same rules. and has essentailly the same rules.
This game is written in the This game is written in the
@link["http://www.htdp.org/"]{How to Design Programs} @link["http://www.htdp.org/"]{How to Design Programs}
Intermediate language. It is a model solution to the final project for Intermediate language. It is a model solution to the final project for
the introductory programming course at the University of Chicago in the introductory programming course at the University of Chicago in
the fall of 2008, as below. the fall of 2008, as below.
@(define-syntax (m stx) @(define-syntax (m stx)
(syntax-case stx () (call-with-input-file
[(_) (build-path (path-only (syntax-source stx))
(call-with-input-file (build-path (current-load-relative-directory) 'up "chat-noir" "chat-noir.ss")
'up (lambda (port)
"chat-noir" (port-count-lines! port)
"chat-noir.ss") #`(schemeblock
(lambda (port) #,@
(port-count-lines! port) (let loop ()
#`(schemeblock (let* ([p (peeking-input-port port)]
#,@ [l (read-line p)])
(let loop () (cond
(let* ([p (peeking-input-port port)] [(eof-object? l) '()]
[l (read-line p)]) [(regexp-match #rx"^[ \t]*$" l)
(cond (read-line port)
[(eof-object? l) '()] (loop)]
[(regexp-match #rx"^[ \t]*$" l) [(regexp-match #rx"^ *;+" l)
(read-line port) =>
(loop)] (lambda (m)
[(regexp-match #rx"^ *;+" l) (let-values ([(line col pos) (port-next-location port)])
=> (read-line port)
(lambda (m) (let-values ([(line2 col2 pos2) (port-next-location port)])
(let-values ([(line col pos) (port-next-location port)]) (cons (datum->syntax
(read-line port) #f
(let-values ([(line2 col2 pos2) (port-next-location port)]) `(code:comment ,(regexp-replace* #rx" " l "\u00a0"))
(cons (datum->syntax (list "chat-noir.ss" line col pos (- pos2 pos)))
#f (loop)))))]
`(code:comment ,(regexp-replace* #rx" " l "\u00a0")) [else
(list "chat-noir.ss" line col pos (- pos2 pos))) (cons (read-syntax "chat-noir.ss" port)
(loop)))))] (loop))])))))
[else #:mode 'text))
(cons (read-syntax "chat-noir.ss" port)
(loop))])))))
#:mode 'text)]))
@m[] @m[]