add example to scribble/bnf docs
This commit is contained in:
parent
2dfd340031
commit
33e3dac94e
|
@ -1,6 +1,7 @@
|
||||||
#lang scribble/doc
|
#lang scribble/doc
|
||||||
@(require scribble/manual
|
@(require scribble/manual
|
||||||
"utils.ss"
|
"utils.ss"
|
||||||
|
scribble/bnf
|
||||||
(for-label scribble/bnf))
|
(for-label scribble/bnf))
|
||||||
|
|
||||||
@title[#:tag "bnf"]{BNF Grammars}
|
@title[#:tag "bnf"]{BNF Grammars}
|
||||||
|
@ -8,6 +9,40 @@
|
||||||
@defmodule[scribble/bnf]{The @racket[scribble/bnf] library
|
@defmodule[scribble/bnf]{The @racket[scribble/bnf] library
|
||||||
provides utilities for typesetting grammars.}
|
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].
|
See also @racket[racketgrammar].
|
||||||
|
|
||||||
@defproc[(BNF [prod (cons element? (listof element?))] ...) table?]{
|
@defproc[(BNF [prod (cons element? (listof element?))] ...) table?]{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user