2. Rule Definition
2.1. Rule Naming
The name of a rule is simply the name itself, that is, a sequence of characters, beginning with an alphabetic character, and followed by a combination of alphabetics, digits, and hyphens (dashes).
Rule names are case insensitive.
The names <rulename>, <Rulename>, <RULENAME>, and <rUlENamE> all refer to the same rule.
Unlike original BNF, angle brackets ("<", ">") are not required. However, angle brackets may be used around a rule name whenever their presence facilitates in discerning the use of a rule name. This is typically restricted to rule name references in free-form prose, or to distinguish partial rules that combine into a string not separated by white space, such as shown in the discussion about repetition, below.
2.2. Rule Form
A rule is defined by the following sequence:
name = elements crlf
where <name> is the name of the rule, <elements> is one or more rule names or terminal specifications, and <crlf> is the end-of-line indicator (carriage return followed by line feed).
The equal sign (=) separates the name from the definition of the rule. The elements form a sequence of one or more rule names and/or value definitions, combined according to the various operators defined in this document, such as alternative and repetition.
For visual ease, rule definitions are left aligned. When a rule requires multiple lines, the continuation lines are indented. The left alignment and indentation are relative to the first lines of the ABNF rules and need not match the left margin of the document.
2.3. Terminal Values
Rules resolve into a string of terminal values, sometimes called characters. In ABNF, a character is merely a non-negative integer. In certain contexts, a specific mapping (encoding) of values into a character set (such as ASCII) will be specified.
Terminals are specified by one or more numeric characters, with the base interpretation of those characters indicated explicitly:
b = binary
d = decimal
x = hexadecimal
Hence:
CR = %d13 ; carriage return in decimal
CR = %x0D ; carriage return in hexadecimal
Literal text strings are specified directly enclosed in quotation marks.
These strings are case insensitive and the character set is US-ASCII.
Hence:
command = "command string"
is equivalent to:
command = "Command" / "COMMAND" / "command"
and so on.
Concatenated Values
A concatenated string of such values is specified compactly, using a period (".") to indicate a separation of characters within that value:
CRLF = %d13.10 ; carriage return line feed sequence
Value Ranges
A range of values can be specified using a hyphen ("-"):
DIGIT = %x30-39 ; 0-9
ALPHA = %x41-5A / %x61-7A ; A-Z / a-z
2.4. External Encodings
External representations of terminal value characters will vary according to constraints in the storage or transmission environment. Hence, the same ABNF-based grammar may have multiple external encodings, such as one for a 7-bit US-ASCII environment, another for a binary octet environment, and still a different one when 16-bit Unicode is used. Encoding details are beyond the scope of ABNF, although Appendix B provides definitions for a 7-bit US-ASCII environment as has been common to much of the Internet.
By separating external encoding from the syntax, it is intended that alternate encoding environments can be used for the same syntax.
Note: ABNF strings are case sensitive, while literal text strings are case insensitive. This is important for certain types of URI specifications where scheme names are case insensitive but path components are case sensitive.