From 33e3dac94eaa7cf66be90090d2ff0684950fcd6a Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 29 Jul 2010 06:56:05 -0500 Subject: [PATCH] add example to scribble/bnf docs --- collects/scribblings/scribble/bnf.scrbl | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/collects/scribblings/scribble/bnf.scrbl b/collects/scribblings/scribble/bnf.scrbl index 4650997995..84aa60d8cc 100644 --- a/collects/scribblings/scribble/bnf.scrbl +++ b/collects/scribblings/scribble/bnf.scrbl @@ -1,6 +1,7 @@ #lang scribble/doc @(require scribble/manual "utils.ss" + scribble/bnf (for-label scribble/bnf)) @title[#:tag "bnf"]{BNF Grammars} @@ -8,6 +9,40 @@ @defmodule[scribble/bnf]{The @racket[scribble/bnf] library provides utilities for typesetting grammars.} +For example, + +@verbatim[#:indent 2]|{ +@(let ([open @litchar{(}] + [close @litchar{)}]) + @BNF[(list @nonterm{expr} + @nonterm{id} + @BNF-seq[open @kleeneplus[@nonterm{expr}] close] + @BNF-seq[open @litchar{lambda} + open @kleenestar[@nonterm{id}] close + @nonterm{expr} close] + @nonterm{val}) + (list @nonterm{val} + @BNF-alt[@nonterm{number} @nonterm{primop}]) + (list @nonterm{id} + @elem{any name except for @litchar{lambda}})]) +}| + +produces the output + +@(let ([open @litchar{(}] + [close @litchar{)}]) + @BNF[(list @nonterm{expr} + @nonterm{id} + @BNF-seq[open @kleeneplus[@nonterm{expr}] close] + @BNF-seq[open @litchar{lambda} + open @kleenestar[@nonterm{id}] close + @nonterm{expr} close] + @nonterm{val}) + (list @nonterm{val} + @BNF-alt[@nonterm{number} @nonterm{primop}]) + (list @nonterm{id} + @elem{any name except for @litchar{lambda}})]) + See also @racket[racketgrammar]. @defproc[(BNF [prod (cons element? (listof element?))] ...) table?]{