bkyk8rc3zvpnsf5inmcqq4n3k98cv6hj-my-site-hyper-literate-git.test.suzanne.soy-0.0.1

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 6a773e5078443aa6e8adf1211f571a1e883312f3
parent 497a6e15cb622669919e5e9505dfa10c3eb3fc0a
Author: Matthew Flatt <mflatt@racket-lang.org>
Date:   Thu, 26 Apr 2012 16:24:33 -0600

scribble/bnf: add `BNF-seq-lines'

original commit: 563909c3285cd30f076b37619b5623c24888f2c0

Diffstat:
Mcollects/scribble/bnf.rkt | 23+++++++++++++++++++----
Mcollects/scribblings/scribble/bnf.scrbl | 7++++++-
2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/collects/scribble/bnf.rkt b/collects/scribble/bnf.rkt @@ -1,11 +1,14 @@ -(module bnf mzscheme +(module bnf racket (require "struct.rkt" "decode.rkt" + (only-in "core.rkt" + make-style + make-table-columns) mzlib/kw) (provide BNF nonterm - BNF-seq + BNF-seq BNF-seq-lines BNF-alt BNF-alt/close ; single-line alternatives BNF-etc BNF-group @@ -15,11 +18,19 @@ (define equals (make-element 'tt (list spacer "::=" spacer))) (define alt (make-element 'tt (list spacer spacer "|" spacer spacer))) - (define (as-flow i) (make-flow (list (make-paragraph (list i))))) + (define (as-flow i) (make-flow (list (if (block? i) + i + (make-paragraph (list i)))))) + + + (define baseline (make-style #f '(baseline))) (define (BNF . defns) (make-table - #f + (make-style #f + (list + (make-table-columns + (list baseline baseline baseline baseline)))) (apply append (map (lambda (defn) @@ -42,6 +53,10 @@ "" (interleave l spacer))) + (define (BNF-seq-lines . l) + (make-table #f (map (lambda (row) (list (as-flow (apply BNF-seq row)))) + l))) + (define (BNF-alt . l) (interleave l alt)) diff --git a/collects/scribblings/scribble/bnf.scrbl b/collects/scribblings/scribble/bnf.scrbl @@ -43,7 +43,7 @@ produces the output See also @racket[racketgrammar]. -@defproc[(BNF [prod (cons element? (listof element?))] ...) table?]{ +@defproc[(BNF [prod (cons element? (listof (or/c block? element?)))] ...) table?]{ Typesets a grammar table. Each production starts with an element (typically constructed with @racket[nonterm]) for the non-terminal @@ -58,6 +58,11 @@ Typesets a non-terminal: italic in angle brackets.} Typesets a sequence.} +@defproc[(BNF-seq-lines [elems (listof element?)] ...) block?]{ + +Typesets a sequence that is broken into multiple lines, where each +@racket[elems] is one line.} + @defproc[(BNF-group [pre-content any/c] ...) element?]{ Typesets a group surrounded by curly braces (so the entire group can