Generate random messages based on their BNF definition.
Generate 10 random postal addresses:
$ go build .
$ ./bnfuzzer -file ./examples/postal.bnf -entry postal-address -count 10We are trying to support BNF and ABNF syntaxes simultenously, by allowing to use different syntactical elements for the same constructions. For example you can use / and | for Rule Alternatives and even mix them up in the same file. Both of them are interpreted as aliternatives.
Maybe with some limitations we can enable support for EBNF as well, but it's a bit difficult because EBNF uses ; to indicate the end of the rule definition, but ABNF and BNF use it for comments.
The descriptions below are stolen from wikipedia.
; commentFor some reason I also added C-style comments. Maybe I should remove them so to not create even more confusion between BNF dialects...
// commentfu = %x61 ; a
bar = %x62 ; b
mumble = fu bar fufubar = fu / baror
fubar = fu | barThe rule
ruleset = alt1 / alt2
ruleset =/ alt3
ruleset =/ alt4 / alt5is equivalent to
ruleset = alt1 / alt2 / alt3 / alt4 / alt5Maybe to maintain the consistency with supporting mixed up syntax, we should allow to use =| along with =/...
OCTAL = %x30-37is equivalent to
OCTAL = "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7"and also can be written as
OCTAL = "0" ... "9"or
OCTAL = "\x30" ... "\x37"group = a (b / c) dn*nRulenRule[Rule]