Generate random messages based on their BNF (Backus-Naur Form) grammar definitions.
Usage: bnferris [OPTIONS] --file <FILE> --entry <ENTRY>
Options:
-f, --file <FILE> Path to the BNF grammar file
-e, --entry <ENTRY> The symbol name to start generating from. Use '!' to list all available symbols
-c, --count <COUNT> How many messages to generate [default: 1]
--verify Verify that all the symbols are defined
--unused Verify that all the symbols are used
--dump Dump the text representation of the entry symbol
-h, --help Print help
-V, --version Print version
Generate 10 random postal addresses:
$ cargo run -- -f ./examples/postal.bnf -e postal-address -c 10
This implementation supports both BNF and ABNF syntaxes, allowing for flexible grammar definitions. You can mix and match syntax elements from both formats in the same file.
; BNF-style comment
// C-style comment
rule = definition
name = part1 part2 part3
choice = one / two ; ABNF style
choice = one | two ; BNF style
rule = alt1 / alt2
rule =/ alt3
rule =/ alt4 / alt5
Equivalent to rule = alt1 / alt2 / alt3 / alt4 / alt5
Multiple equivalent syntaxes:
digit = %x30-39 ; Hex range
digit = "0" ... "9" ; Character range
digit = "\x30" ... "\x39" ; Escaped hex range
group = item1 (item2 / item3) item4
n*mitem ; Repeat item from n to m times
nitem ; Exactly n repetitions
*item ; Zero or more repetitions
[optional] ; Zero or one occurrence