13 BNF Grammars
The scribble/bnf library provides utilities for typesetting grammars.
See also schemegrammar.
Typesets a grammar table. Each production starts with an element (typically constructed with nonterm) for the non-terminal being defined, and then a list of possibilities (typically constructed with BNF-seq, etc.) to show on separate lines.
pre-content : any/c |
Typesets a non-terminal: italic in angle brackets.
elem : element? |
Typesets a sequence.
pre-content : any/c |
Typesets a group surrounded by curly braces (so the entire group can be repeated, for example).
pre-content : any/c |
Typesets an optional element: in square brackets.
(kleenestar pre-content ) → element? |
pre-content : any/c |
Typesets a 0-or-more repetition.
(kleeneplus pre-content ) → element? |
pre-content : any/c |
Typesets a 1-or-more repetition.
(kleenerange n m pre-content ) → element? |
n : any/c |
m : any/c |
pre-content : any/c |
Typesets a n-to-m repetition. The n and m arguments are converted to a string using (format "~a" n) and (format "~a" m).
elem : element? |
Typesets alternatives for a production’s right-hand side to appear on a single line. The result is normally used as a single possibility in a production list for BNF.
A string to use for omitted productions or content.