Generate random messages based on their BNF definition.
Generate 10 random postal addresses:
$ go build .
$ ./bnfuzzer -file ./examples/postal.bnf -entry postal-address -count 10
We 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.
; comment
For some reason I also added C-style comments. Maybe I should remove them so to not create even more confusion between BNF dialects...
// comment
fu = %x61 ; a
bar = %x62 ; b
mumble = fu bar fu
fubar = fu / bar
or
fubar = fu | bar
The rule
ruleset = alt1 / alt2
ruleset =/ alt3
ruleset =/ alt4 / alt5
is equivalent to
ruleset = alt1 / alt2 / alt3 / alt4 / alt5
Maybe to maintain the consistency with supporting mixed up syntax, we should allow to use =|
along with =/
...
OCTAL = %x30-37
is 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) d
n*nRule
nRule
[Rule]