Grammar Documentation
Grammar Reference
Generated May 6, 2026 · 21 rules · ABNF · Generated by DevDiagrams

rulelist

entry point
rulelist — The top-level rule. An ABNF grammar consists of one or more
rules or blank lines (comment/newline combinations).
rulelist = 1 * ( rule / ( * c-wsp c-nl ) )
rule c-wsp c-nl

rule

rule — A single rule definition. Consists of a rule name, the defined-as
operator, the rule elements, and a terminating newline. A rule may
continue on the next line if that line begins with whitespace.
rule = rulename defined-as elements c-nl
rulename defined-as elements c-nl

rulename

continues if next line starts
with white space
rulename — The name of a rule. Must begin with a letter and may contain
letters, digits, and hyphens.
rulename = ALPHA * ( ALPHA / DIGIT / "-" )
ALPHA ALPHA DIGIT "-"
ALPHADIGIT

defined-as

defined-as — The operator that separates a rule name from its definition.
"=" defines a new rule. "=/" incrementally adds alternatives to an
existing rule. Optional whitespace is allowed on either side.
defined-as = * c-wsp ( "=" / "=/" ) * c-wsp
c-wsp "=" "=/" c-wsp

elements

basic rules definition and
incremental alternatives
elements — The body of a rule definition, consisting of an alternation
followed by optional whitespace.
elements = alternation * c-wsp
alternation c-wsp

c-wsp

c-wsp — Comment or whitespace. Either a plain whitespace character or
a newline followed by whitespace (enabling rule continuation across lines).
c-wsp = WSP / ( c-nl WSP )
WSP c-nl WSP
WSPc-nl

c-nl

c-nl — Comment or newline. Either a semicolon comment or a bare CRLF.
Used as optional padding and as the rule terminator.
c-nl = comment / CRLF
comment CRLF

comment

comment or newline
comment — A line comment beginning with a semicolon and ending with CRLF.
May contain any printable characters and spaces.
comment = ";" * ( WSP / VCHAR ) CRLF
";" WSP VCHAR CRLF
WSPVCHARCRLF

alternation

alternation — A choice between two or more concatenations, separated by
the "/" operator. Optional whitespace is permitted around the operator.
alternation = concatenation * ( * c-wsp "/" * c-wsp concatenation )
concatenation c-wsp "/" c-wsp concatenation

concatenation

concatenation — A sequence of one or more repetitions. Elements in a
concatenation must be separated by at least one whitespace character.
concatenation = repetition * ( 1 * c-wsp repetition )
repetition c-wsp repetition

repetition

repetition — An optional repeat count followed by an element. If no
repeat count is given, the element occurs exactly once.
repetition = [ repeat ] element
repeat element

repeat

repeat — Specifies how many times an element may occur. Supports exact
counts, minimum counts, maximum counts, and ranges.
repeat = 1 * DIGIT / ( * DIGIT "*" * DIGIT )
DIGIT DIGIT "*" DIGIT
DIGIT

element

element — A single grammar element. May be a rule name reference, a
grouped alternation, an optional group, a character value, a numeric
value, or a prose description.
element = rulename / group / option / char-val / num-val / prose-val
rulename group option char-val num-val prose-val

group

group — A grouped alternation enclosed in parentheses. Used to control
precedence and grouping of alternatives.
group = "(" * c-wsp alternation * c-wsp ")"
"(" c-wsp alternation c-wsp ")"

option

option — An optional grouped alternation enclosed in square brackets.
Equivalent to the grouped alternation occurring zero or one times.
option = "[" * c-wsp alternation * c-wsp "]"
"[" c-wsp alternation c-wsp "]"

char-val

char-val — A quoted string literal. May be case-sensitive (prefixed with
%s) or case-insensitive (prefixed with %i or no prefix). Contains any
printable characters except double-quote.
char-val = DQUOTE * ( %x20-21 / %x23-7E ) DQUOTE
DQUOTE %x20-21 %x23-7E DQUOTE
DQUOTE

num-val

quoted string of SP and VCHAR
without DQUOTE
num-val — A numeric character value. May be binary (%b), decimal (%d),
or hexadecimal (%x). Supports single values, ranges, and concatenations.
num-val = "%" ( bin-val / dec-val / hex-val )
"%" bin-val dec-val hex-val

bin-val

bin-val — A binary numeric value. Consists of the "b" prefix followed by
binary digits. Optionally followed by a range or concatenation of values.
bin-val = "b" 1 * BIT [ 1 * ( "." 1 * BIT ) / ( "-" 1 * BIT ) ]
"b" BIT "." BIT "-" BIT
BIT

dec-val

series of concatenated bit values
or single ONEOF range
dec-val — A decimal numeric value. Consists of the "d" prefix followed by
decimal digits. Optionally followed by a range or concatenation of values.
dec-val = "d" 1 * DIGIT [ 1 * ( "." 1 * DIGIT ) / ( "-" 1 * DIGIT ) ]
"d" DIGIT "." DIGIT "-" DIGIT
DIGIT

hex-val

hex-val — A hexadecimal numeric value. Consists of the "x" prefix followed
by hexadecimal digits. Optionally followed by a range or concatenation.
hex-val = "x" 1 * HEXDIG [ 1 * ( "." 1 * HEXDIG ) / ( "-" 1 * HEXDIG ) ]
"x" HEXDIG "." HEXDIG "-" HEXDIG
HEXDIG

prose-val

prose-val — A prose description enclosed in angle brackets. Used as a
last resort when a construct cannot be formally expressed in ABNF.
May contain any printable characters except angle brackets.
prose-val = "<" * ( %x20-3D / %x3F-7E ) ">"
"<" %x20-3D %x3F-7E ">"