| 1 | <h2>Full example</h2> |
| 2 | <pre><code>rulelist = 1*( rule / (*c-wsp c-nl) ) |
| 3 | |
| 4 | rule = rulename defined-as elements c-nl |
| 5 | ; continues if next line starts |
| 6 | ; with white space |
| 7 | |
| 8 | rulename = ALPHA *(ALPHA / DIGIT / "-") |
| 9 | |
| 10 | defined-as = *c-wsp ("=" / "=/") *c-wsp |
| 11 | ; basic rules definition and |
| 12 | ; incremental alternatives |
| 13 | |
| 14 | elements = alternation *c-wsp |
| 15 | |
| 16 | c-wsp = WSP / (c-nl WSP) |
| 17 | |
| 18 | c-nl = comment / CRLF |
| 19 | ; comment or newline |
| 20 | |
| 21 | comment = ";" *(WSP / VCHAR) CRLF |
| 22 | |
| 23 | alternation = concatenation |
| 24 | *(*c-wsp "/" *c-wsp concatenation) |
| 25 | |
| 26 | concatenation = repetition *(1*c-wsp repetition) |
| 27 | |
| 28 | repetition = [repeat] element |
| 29 | |
| 30 | repeat = 1*DIGIT / (*DIGIT "*" *DIGIT) |
| 31 | |
| 32 | element = rulename / group / option / |
| 33 | char-val / num-val / prose-val |
| 34 | |
| 35 | group = "(" *c-wsp alternation *c-wsp ")" |
| 36 | |
| 37 | option = "[" *c-wsp alternation *c-wsp "]" |
| 38 | |
| 39 | char-val = DQUOTE *(%x20-21 / %x23-7E) DQUOTE |
| 40 | ; quoted string of SP and VCHAR |
| 41 | ; without DQUOTE |
| 42 | |
| 43 | num-val = "%" (bin-val / dec-val / hex-val) |
| 44 | |
| 45 | bin-val = "b" 1*BIT |
| 46 | [ 1*("." 1*BIT) / ("-" 1*BIT) ] |
| 47 | ; series of concatenated bit values |
| 48 | ; or single ONEOF range |
| 49 | |
| 50 | dec-val = "d" 1*DIGIT |
| 51 | [ 1*("." 1*DIGIT) / ("-" 1*DIGIT) ] |
| 52 | |
| 53 | hex-val = "x" 1*HEXDIG |
| 54 | [ 1*("." 1*HEXDIG) / ("-" 1*HEXDIG) ] |
| 55 | |
| 56 | prose-val = "<" *(%x20-3D / %x3F-7E) ">" |
| 57 | ; bracketed string of SP and VCHAR |
| 58 | ; without angles |
| 59 | ; prose description, to be used as |
| 60 | ; last resort</code></pre> |