4.7 BNF Grammars
For example,
@(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
| ‹expr› | ::= | ‹id› |
|
| | | ( ‹expr›+ ) |
|
| | | ( lambda ( ‹id›* ) ‹expr› ) |
|
| | | ‹val› |
| ‹val› | ::= | ‹number› | ‹primop› |
| ‹id› | ::= | any name except for lambda |
See also racketgrammar.
procedure
(BNF-seq-lines elems ...) → block?
elems : (listof element?)
procedure
(kleenestar pre-content ...) → element?
pre-content : any/c
procedure
(kleeneplus pre-content ...) → element?
pre-content : any/c
procedure
(kleenerange n m pre-content ...) → element?
n : any/c m : any/c pre-content : any/c