#------------------------------------------------------------------------
# ABNF
#------------------------------------------------------------------------
#
# The ABNF definition of ABNF as defined by RFC 5234.
#
#------------------------------------------------------------------------
rulelist       =  1*( rule / (*c-wsp c-nl) );
rule           =  rulename defined-as elements c-nl;
rulename       =  ALPHA *(ALPHA / DIGIT / "-");
defined-as     =  *c-wsp ("=" / "=/") *c-wsp;
elements       =  alternation *c-wsp;
c-wsp          =  WSP / (c-nl WSP);
c-nl           =  comment / CRLF;
comment        =  ";" *(WSP / VCHAR) CRLF;
alternation    =  concatenation *(*c-wsp "/" *c-wsp concatenation);
concatenation  =  repetition *(1*c-wsp repetition);
repetition     =  [repeat] element;
repeat         =  (*DIGIT "*" *DIGIT) / 1*DIGIT;
element        =  rulename / group / option / 
                  char-val / num-val / prose-val;
group          =  "(" *c-wsp alternation *c-wsp ")";
option         =  "[" *c-wsp alternation *c-wsp "]";
char-val       =  DQUOTE *(%x20-21 / %x23-7E) DQUOTE;
num-val        =  "%" (bin-val / dec-val / hex-val);
bin-val        =  "b" 1*BIT [ 1*("." 1*BIT) / ("-" 1*BIT) ];
dec-val        =  "d" 1*DIGIT [ 1*("." 1*DIGIT) / ("-" 1*DIGIT) ];
hex-val        =  "x" 1*HEXDIG [ 1*("." 1*HEXDIG) / ("-" 1*HEXDIG) ];
prose-val      =  "<" *(%x20-3D / %x3F-7E) ">";
#------------------------------------------------------------------------
# core rules
#------------------------------------------------------------------------
ALPHA          =  %x41-5A / %x61-7A;
BIT            =  "0" / "1";
CHAR           =  %x01-7F;
CR             =  %x0D;
CRLF           =  (CR LF) / LF;
CTL            =  %x00-1F / %x7F;
DIGIT          =  %x30-39;
DQUOTE         =  %x22;
HEXDIG         =  DIGIT / "A" / "B" / "C" / "D" / "E" / "F";
HTAB           =  %x09;
LF             =  %x0A;
LWSP           =  *(WSP / CRLF WSP);
OCTET          =  %x00-FF;
SP             =  %x20;
VCHAR          =  %x21-7E;
WSP            =  SP / HTAB;
#------------------------------------------------------------------------
# end
#------------------------------------------------------------------------