; In ABNF comments start with a single semicolon.

; An ABNF rule can contain multiple sub-rules.
rule = WSP subrule2 DIGIT

; We can also use optional angle brackets around a rule name.
<oh-look-ma-angle-brackets> = "[]"; To specify a sequence of characters we use
                                  ; double quotes.
rule = <angle-brackets>

; By default characters between double quotes are case-insensitive. This means
; "abc", "ABC" and "abc" describe the same sequence of characters. To
; explicitly specify a case-sensitive string use the prefix `%s`.
case-sensitive        = %s"Case Sensitive"
case-insensitive      = %i"Case Insensitive"
also-case-insensitive =   "case insensitive"

; We can also specify characters directly using their ASCII/Unicode value.
CR = %d13
CR = %x0D
space = %b100000

; We can combine characters using the concatenation operator `.`.
ABNF = %d65.66.78.70
; This rule describes the exact same sequence of characters as the rule above.
ABNF = %d65 %d66 %d78 %d70
hex = %xa.b
binary = %b100000.10

; We separate alternatives by a forward slash.
rule = alternative1 / alternative2 / "Alternative"

; We specify incremental alternative via `=/`.
rule = alternative1
rule =/ alternative2 / "Alternative"

; We can specify a range of values using a dash sign.
binary-range  = %b00-11
decimal-range = %d30-39
hex-range     = %x30-af

; We group rules using parentheses.
grouped = (         Turbo         /
                    Staat         /
            ([American] Football) ) Husum

; To repeat rules we use the form <min>*<max>element or <number>element, where
;
; - <min> specifies the minimum number of repetitions,
; - <max> specifies the maximum number of repetitions, and
; - <number> specifies the exact number of repetitions
;
; required.
year = 12(month) / *(%x00-0B)
month = 28*31days / 2419200*2678400second / 1month
zero-or-one-day = *1day

; We can use square brackets to make rules optional.
zero-or-one-day = [day]
float = [digits ["."[digits]]]

; -- Invalid Rules -------------------------------------------------------------

<missing-angle-bracket  = "Missing `>`"
illegal$characters_     = "Rule names can only contain certain characters"

incorrect-binary-digits  = %b3h012901.012xf.56
  %b0123456789abcdefg-0123456789abcdefg

incorrect-decimal-digits = %d3h012901.012xf.56
  %d0123456789abcdefg-0123456789abcdefg

incorrect-hex-digits     = %x3h012901.012xf.56
  %x0123456789abcdefg-0123456789abcdefg

variable-repetition-without-element = 12 twelve 1*2 three

wrong-definition-operator /= "`=` or `=/` would be correct"

definition-in-right-side = "Uh" = "Huh" /= "Her"
