From 4820a0d00743b8b5eaad27a2d9a13048b2e37448 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 15 Feb 2009 18:44:52 +0000 Subject: [PATCH 1/4] remove svn:executable svn: r13610 --- collects/games/chat-noir/chat-noir-literate.ss | 0 collects/games/chat-noir/literate-lang.ss | 0 collects/games/chat-noir/literate-reader.ss | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 collects/games/chat-noir/chat-noir-literate.ss mode change 100755 => 100644 collects/games/chat-noir/literate-lang.ss mode change 100755 => 100644 collects/games/chat-noir/literate-reader.ss diff --git a/collects/games/chat-noir/chat-noir-literate.ss b/collects/games/chat-noir/chat-noir-literate.ss old mode 100755 new mode 100644 diff --git a/collects/games/chat-noir/literate-lang.ss b/collects/games/chat-noir/literate-lang.ss old mode 100755 new mode 100644 diff --git a/collects/games/chat-noir/literate-reader.ss b/collects/games/chat-noir/literate-reader.ss old mode 100755 new mode 100644 From ea51547caee781b249baab9d0442f352afa73932 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 15 Feb 2009 20:26:21 +0000 Subject: [PATCH 2/4] Fix typo found by offby1 svn: r13611 --- collects/net/scribblings/uri-codec.scrbl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collects/net/scribblings/uri-codec.scrbl b/collects/net/scribblings/uri-codec.scrbl index 22e30fc6eb..824dd3804a 100644 --- a/collects/net/scribblings/uri-codec.scrbl +++ b/collects/net/scribblings/uri-codec.scrbl @@ -98,7 +98,7 @@ Encode a string using the @tt{application/x-www-form-urlencoded} encoding rules. The result string contains no non-ASCII characters.} -@defproc[(form-urlencoded-deecode [str string?]) string?]{ +@defproc[(form-urlencoded-decode [str string?]) string?]{ Decode a string encoded using the @tt{application/x-www-form-urlencoded} encoding rules.} From e99c3dc3d9bbf1c0ac66f6f4d57079f1f0cfd16e Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sun, 15 Feb 2009 20:57:25 +0000 Subject: [PATCH 3/4] split things up so that there are two modes for running the file. See the README svn: r13613 --- collects/games/chat-noir/README | 16 ++++ collects/games/chat-noir/chat-noir-doc.ss | 75 +++++++++++++++++++ .../games/chat-noir/chat-noir-literate.ss | 1 + collects/games/chat-noir/literate-lang.ss | 55 +++++++++----- 4 files changed, 128 insertions(+), 19 deletions(-) create mode 100644 collects/games/chat-noir/README create mode 100644 collects/games/chat-noir/chat-noir-doc.ss diff --git a/collects/games/chat-noir/README b/collects/games/chat-noir/README new file mode 100644 index 0000000000..4f3d3f474f --- /dev/null +++ b/collects/games/chat-noir/README @@ -0,0 +1,16 @@ +These are the files for the literate version of Chat Noir. The files +not mentioned are actually in use for Chat Noir that you get via PLT +Games. + + - chat-noir-literate.ss: the actual file containing the literate + description of the chat noir game, as well as the game itself, in + the chunks. + + - chat-noir-doc.ss: the wrapper file that you run via scribble to get + the rendered output. + + - literate-lang.ss: the language for running literate programs + (contains the tangler) + + - literate-reader.ss: the reader used for chat-noir-literate.ss to + put it into the literate-lang.ss. diff --git a/collects/games/chat-noir/chat-noir-doc.ss b/collects/games/chat-noir/chat-noir-doc.ss new file mode 100644 index 0000000000..d7981e0f5c --- /dev/null +++ b/collects/games/chat-noir/chat-noir-doc.ss @@ -0,0 +1,75 @@ +#lang scribble/doc + +@(require (for-syntax scheme/base + syntax/boundmap + scheme/list + (prefix-in scr: scribble/reader) + compiler/cm-accomplice)) + +@(require scribble/manual + scribble/struct + scribble/basic + scribble/decode) + +@(define :make-splice make-splice) + +@(define-syntax (chunk stx) + (syntax-case stx () + [(_ name expr ...) + (begin + (unless (identifier? #'name) + (raise-syntax-error #f "expected a chunk name" stx #'name)) + (unless (regexp-match #rx"^<.*>$" (symbol->string (syntax-e #'name))) + (raise-syntax-error #f "chunk names must begin and end with angle brackets, <...>" + stx + #'name)) + #`(:make-splice + (list + (italic #,(format "~a = " (syntax-e #'name))) + (schemeblock expr ...))))])) + +@;{the two lines below seem like they shoudl work, but they loop forever; probably the read-syntax-inside vs read-syntax difference. If they did work, then all of the stuff below could go away} +@;(require scheme/include) +@;(include/reader "chat-noir-literate.ss" scr:read-syntax-inside) + +@(define-syntax (content-elsewhere stx) + (syntax-case stx () + [(_ fn) + (string? (syntax-e #'fn)) + (let ([fn (syntax-e #'fn)]) + (register-external-file (path->complete-path fn)) + (call-with-input-file fn + (λ (port) + (port-count-lines! port) + (let ([reader-line (read-line port)]) + (unless (regexp-match #rx"^#reader" reader-line) + (raise-syntax-error #f (format "expected a #reader line, found ~s" reader-line) stx)) + (let* ([content (scr:read-syntax-inside fn port)] + [w/context (give-lexical-content stx content)]) + #`(begin #,@w/context))))))])) + +@;{ stolen from include.ss. Should probably be refactored to just have one of these.} +@(define-for-syntax (give-lexical-content ctx content) + (let loop ([content content]) + (cond + [(pair? content) + (cons (loop (car content)) + (loop (cdr content)))] + [(null? content) null] + [else + (let ([v (syntax-e content)]) + (datum->syntax + ctx + (cond + [(pair? v) + (loop v)] + [(vector? v) + (list->vector (loop (vector->list v)))] + [(box? v) + (box (loop (unbox v)))] + [else + v]) + content + content))]))) + +@content-elsewhere["chat-noir-literate.ss"] diff --git a/collects/games/chat-noir/chat-noir-literate.ss b/collects/games/chat-noir/chat-noir-literate.ss index 2d3e051e73..58c9687cf6 100644 --- a/collects/games/chat-noir/chat-noir-literate.ss +++ b/collects/games/chat-noir/chat-noir-literate.ss @@ -1,5 +1,6 @@ #reader "literate-reader.ss" +@(require scheme/local scheme/list scheme/bool scheme/math) @title{Chat Noir} diff --git a/collects/games/chat-noir/literate-lang.ss b/collects/games/chat-noir/literate-lang.ss index 0c6aa80992..93358715d0 100644 --- a/collects/games/chat-noir/literate-lang.ss +++ b/collects/games/chat-noir/literate-lang.ss @@ -7,7 +7,10 @@ scribble/manual) chunk) -(require (for-syntax scheme/base syntax/boundmap scheme/list) +(require (for-syntax scheme/base + syntax/boundmap + scheme/list + syntax/kerncase) scribble/manual scribble/struct scribble/basic @@ -45,10 +48,7 @@ stx #'name)) (add-to-block! #'name (syntax->list #'(expr ...))) - #`(:make-splice - (list - (italic #,(format "~a = " (syntax-e #'name))) - (schemeblock expr ...))))])) + #`(void))])) (define-syntax (tangle stx) (define block-mentions '()) @@ -80,17 +80,34 @@ (define-syntax (module-begin stx) (syntax-case stx () [(module-begin expr ...) - (with-syntax ([doc (datum->syntax stx 'doc stx)] - ;; this forces expansion so `chunk' can appear anywhere, if - ;; it's allowed only at the toplevel, then there's no need - ;; for it - [(expr ...) - (map (lambda (expr) (local-expand expr 'module '())) - (syntax->list #'(expr ...)))]) - ;; define doc as the binding that has all the scribbled documentation - #'(#%module-begin - (define doc '()) - (provide doc) - (set! doc (cons expr doc)) ... - (tangle) - (set! doc (decode (reverse doc)))))])) + (let ([body-code + (let loop ([exprs (syntax->list #'(expr ...))]) + (cond + [(null? exprs) null] + [else + (let ([expanded + (local-expand (car exprs) + 'module + (append (kernel-form-identifier-list) + (syntax->list #'(provide + require + #%provide + #%require))))]) + (syntax-case expanded (begin) + [(begin rest ...) + (append (loop (syntax->list #'(rest ...))) + (loop (cdr exprs)))] + [(id . rest) + (ormap (lambda (kw) (free-identifier=? #'id kw)) + (syntax->list #'(require + provide + chunk + #%require + #%provide))) + (cons expanded (loop (cdr exprs)))] + [else (loop (cdr exprs))]))]))]) + + (with-syntax ([(body-code ...) body-code]) + #'(#%module-begin + body-code ... + (tangle))))])) From 965110bc551acfdcfac53262903aed13c71826b5 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sun, 15 Feb 2009 21:05:03 +0000 Subject: [PATCH 4/4] svn: r13614 --- collects/games/chat-noir/README | 15 +++++++++ collects/games/chat-noir/chat-noir-doc.ss | 33 ++++++++++--------- .../games/chat-noir/chat-noir-literate.ss | 12 +++++-- 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/collects/games/chat-noir/README b/collects/games/chat-noir/README index 4f3d3f474f..dcaeb42182 100644 --- a/collects/games/chat-noir/README +++ b/collects/games/chat-noir/README @@ -14,3 +14,18 @@ Games. - literate-reader.ss: the reader used for chat-noir-literate.ss to put it into the literate-lang.ss. + +Problems: + + - the code is not hyperlinked in the scribble output-- this is due to + the confusion about how the requires should work in the two modes. + + - The char-noir-doc.ss file contains code that should move into + scribble proper; ideally that file should just be (something like): + + #lang scribble/doc + @include-literate["chat-noir-literate.ss"] + + and it should be built when setup-plt runs on this collection to + build the documentation, ie, this file should eventually be merged + together with ../scribblings/chat-noir.scrbl. diff --git a/collects/games/chat-noir/chat-noir-doc.ss b/collects/games/chat-noir/chat-noir-doc.ss index d7981e0f5c..f3692c937b 100644 --- a/collects/games/chat-noir/chat-noir-doc.ss +++ b/collects/games/chat-noir/chat-noir-doc.ss @@ -32,22 +32,6 @@ @;(require scheme/include) @;(include/reader "chat-noir-literate.ss" scr:read-syntax-inside) -@(define-syntax (content-elsewhere stx) - (syntax-case stx () - [(_ fn) - (string? (syntax-e #'fn)) - (let ([fn (syntax-e #'fn)]) - (register-external-file (path->complete-path fn)) - (call-with-input-file fn - (λ (port) - (port-count-lines! port) - (let ([reader-line (read-line port)]) - (unless (regexp-match #rx"^#reader" reader-line) - (raise-syntax-error #f (format "expected a #reader line, found ~s" reader-line) stx)) - (let* ([content (scr:read-syntax-inside fn port)] - [w/context (give-lexical-content stx content)]) - #`(begin #,@w/context))))))])) - @;{ stolen from include.ss. Should probably be refactored to just have one of these.} @(define-for-syntax (give-lexical-content ctx content) (let loop ([content content]) @@ -72,4 +56,21 @@ content content))]))) +@(define-syntax (content-elsewhere stx) + (syntax-case stx () + [(_ fn) + (string? (syntax-e #'fn)) + (let ([fn (syntax-e #'fn)]) + (register-external-file (path->complete-path fn)) + (call-with-input-file fn + (λ (port) + (port-count-lines! port) + (let ([reader-line (read-line port)]) + (unless (regexp-match #rx"^#reader" reader-line) + (raise-syntax-error #f (format "expected a #reader line, found ~s" reader-line) stx)) + (let* ([content (scr:read-syntax-inside fn port)] + [w/context (give-lexical-content stx content)]) + #`(begin #,@w/context))))))])) + + @content-elsewhere["chat-noir-literate.ss"] diff --git a/collects/games/chat-noir/chat-noir-literate.ss b/collects/games/chat-noir/chat-noir-literate.ss index 58c9687cf6..6f8d69fc9d 100644 --- a/collects/games/chat-noir/chat-noir-literate.ss +++ b/collects/games/chat-noir/chat-noir-literate.ss @@ -25,7 +25,7 @@ The main data structure for Chat Noir is @tt{world}. It consists of a structure with six fields: @itemize{ @item{ -a @scheme[board],} +a @scheme[board], which is represented as a list of @tt{cell}s, one for each circle on the game. } @item{ a @scheme[posn] for the cat,} @item{the state of the game (@scheme[state] below), which can be one of @@ -42,6 +42,13 @@ mouse is not in the window),} key has been pushed down.} } +A @tt{cell} is a structure with two fields: + +@chunk[ + (define-struct cell (p blocked?) #:transparent)] + +The first field contains a @scheme[posn] struct. + @verbatim[#<<--- ;; a cell is ;; (make-cell (make-posn int[0-board-size] @@ -50,8 +57,7 @@ key has been pushed down.} --- ] -@chunk[ - (define-struct cell (p blocked?) #:transparent)] + @section{Init Junk}