rfc2234.txt | rfc4234.txt | |||
---|---|---|---|---|
Network Working Group D. Crocker, Ed. | Network Working Group D. Crocker, Ed. | |||
Request for Comments: 2234 Internet Mail Consortium | Request for Comments: 4234 Brandenburg InternetWorking | |||
Category: Standards Track P. Overell | Obsoletes: 2234 P. Overell | |||
Demon Internet Ltd. | Category: Standards Track THUS plc. | |||
November 1997 | October 2005 | |||
Augmented BNF for Syntax Specifications: ABNF | Augmented BNF for Syntax Specifications: ABNF | |||
Status of this Memo | Status of This Memo | |||
This document specifies an Internet standards track protocol for the | This document specifies an Internet standards track protocol for the | |||
Internet community, and requests discussion and suggestions for | Internet community, and requests discussion and suggestions for | |||
improvements. Please refer to the current edition of the "Internet | improvements. Please refer to the current edition of the "Internet | |||
Official Protocol Standards" (STD 1) for the standardization state | Official Protocol Standards" (STD 1) for the standardization state | |||
and status of this protocol. Distribution of this memo is unlimited. | and status of this protocol. Distribution of this memo is unlimited. | |||
Copyright Notice | Copyright Notice | |||
Copyright (C) The Internet Society (1997). All Rights Reserved. | Copyright (C) The Internet Society (2005). | |||
TABLE OF CONTENTS | Abstract | |||
1. INTRODUCTION .................................................. 2 | Internet technical specifications often need to define a formal | |||
syntax. Over the years, a modified version of Backus-Naur Form | ||||
2. RULE DEFINITION ............................................... 2 | (BNF), called Augmented BNF (ABNF), has been popular among many | |||
2.1 RULE NAMING .................................................. 2 | Internet specifications. The current specification documents ABNF. | |||
2.2 RULE FORM .................................................... 3 | It balances compactness and simplicity, with reasonable | |||
2.3 TERMINAL VALUES .............................................. 3 | representational power. The differences between standard BNF and | |||
2.4 EXTERNAL ENCODINGS ........................................... 5 | ABNF involve naming rules, repetition, alternatives, order- | |||
independence, and value ranges. This specification also supplies | ||||
3. OPERATORS ..................................................... 5 | additional rule definitions and encoding for a core lexical analyzer | |||
3.1 CONCATENATION RULE1 RULE2 ............................. 5 | of the type common to several Internet specifications. | |||
3.2 ALTERNATIVES RULE1 / RULE2 ................................... 6 | ||||
3.3 INCREMENTAL ALTERNATIVES RULE1 =/ RULE2 .................... 6 | Table of Contents | |||
3.4 VALUE RANGE ALTERNATIVES %C##-## ........................... 7 | ||||
3.5 SEQUENCE GROUP (RULE1 RULE2) ................................. 7 | 1. INTRODUCTION ....................................................2 | |||
3.6 VARIABLE REPETITION *RULE .................................... 8 | 2. RULE DEFINITION .................................................3 | |||
3.7 SPECIFIC REPETITION NRULE .................................... 8 | 2.1. Rule Naming ................................................3 | |||
3.8 OPTIONAL SEQUENCE [RULE] ..................................... 8 | 2.2. Rule Form ..................................................3 | |||
3.9 ; COMMENT .................................................... 8 | 2.3. Terminal Values ............................................4 | |||
3.10 OPERATOR PRECEDENCE ......................................... 9 | 2.4. External Encodings .........................................5 | |||
3. OPERATORS .......................................................6 | ||||
4. ABNF DEFINITION OF ABNF ....................................... 9 | 3.1. Concatenation: Rule1 Rule2 ................................6 | |||
3.2. Alternatives: Rule1 / Rule2 ...............................6 | ||||
5. SECURITY CONSIDERATIONS ....................................... 10 | 3.3. Incremental Alternatives: Rule1 =/ Rule2 ...................7 | |||
6. APPENDIX A - CORE ............................................. 11 | 3.4. Value Range Alternatives: %c##-## .........................7 | |||
6.1 CORE RULES ................................................... 11 | 3.5. Sequence Group: (Rule1 Rule2) .............................8 | |||
6.2 COMMON ENCODING .............................................. 12 | 3.6. Variable Repetition: *Rule ................................8 | |||
3.7. Specific Repetition: nRule ................................9 | ||||
7. ACKNOWLEDGMENTS ............................................... 12 | 3.8. Optional Sequence: [RULE] .................................9 | |||
3.9. Comment: ; Comment ........................................9 | ||||
8. REFERENCES .................................................... 13 | 3.10. Operator Precedence .......................................9 | |||
4. ABNF DEFINITION OF ABNF ........................................10 | ||||
9. CONTACT ....................................................... 13 | 5. SECURITY CONSIDERATIONS ........................................11 | |||
6. References .....................................................11 | ||||
10. FULL COPYRIGHT STATEMENT ..................................... 14 | 6.1. Normative References ......................................11 | |||
6.2. Informative References ....................................11 | ||||
Appendix A. ACKNOWLEDGEMENTS .....................................13 | ||||
Appendix B. APPENDIX - CORE ABNF OF ABNF .........................13 | ||||
B.1. Core Rules ...............................................13 | ||||
B.2. Common Encoding ..........................................14 | ||||
1. INTRODUCTION | 1. INTRODUCTION | |||
Internet technical specifications often need to define a format | Internet technical specifications often need to define a formal | |||
syntax and are free to employ whatever notation their authors deem | syntax and are free to employ whatever notation their authors deem | |||
useful. Over the years, a modified version of Backus-Naur Form | useful. Over the years, a modified version of Backus-Naur Form | |||
(BNF), called Augmented BNF (ABNF), has been popular among many | (BNF), called Augmented BNF (ABNF), has been popular among many | |||
Internet specifications. It balances compactness and simplicity, | Internet specifications. It balances compactness and simplicity, | |||
with reasonable representational power. In the early days of the | with reasonable representational power. In the early days of the | |||
Arpanet, each specification contained its own definition of ABNF. | Arpanet, each specification contained its own definition of ABNF. | |||
This included the email specifications, RFC733 and then RFC822 which | This included the email specifications, [RFC733] and then [RFC822], | |||
have come to be the common citations for defining ABNF. The current | which came to be the common citations for defining ABNF. The current | |||
document separates out that definition, to permit selective | document separates those definitions to permit selective reference. | |||
reference. Predictably, it also provides some modifications and | Predictably, it also provides some modifications and enhancements. | |||
enhancements. | ||||
The differences between standard BNF and ABNF involve naming rules, | The differences between standard BNF and ABNF involve naming rules, | |||
repetition, alternatives, order-independence, and value ranges. | repetition, alternatives, order-independence, and value ranges. | |||
Appendix A (Core) supplies rule definitions and encoding for a core | Appendix B supplies rule definitions and encoding for a core lexical | |||
lexical analyzer of the type common to several Internet | analyzer of the type common to several Internet specifications. It | |||
specifications. It is provided as a convenience and is otherwise | is provided as a convenience and is otherwise separate from the meta | |||
separate from the meta language defined in the body of this document, | language defined in the body of this document, and separate from its | |||
and separate from its formal status. | formal status. | |||
2. RULE DEFINITION | Changes since [RFC2234]: | |||
2.1 Rule Naming | In Section 3.7, the phrase: "That is, exactly <N> occurrences of | |||
<element>." was corrected to: "That is, exactly <n> occurrences of | ||||
<element>." | ||||
Some continuation comment lines needed to be corrected to begin | ||||
with comment character (";"). | ||||
2. RULE DEFINITION | ||||
2.1. Rule Naming | ||||
The name of a rule is simply the name itself; that is, a sequence of | The name of a rule is simply the name itself; that is, a sequence of | |||
characters, beginning with an alphabetic character, and followed by | characters, beginning with an alphabetic character, and followed by a | |||
a combination of alphabetics, digits and hyphens (dashes). | combination of alphabetics, digits, and hyphens (dashes). | |||
NOTE: | ||||
NOTE: Rule names are case-insensitive | Rule names are case-insensitive | |||
The names <rulename>, <Rulename>, <RULENAME> and <rUlENamE> all refer | The names <rulename>, <Rulename>, <RULENAME>, and <rUlENamE> all | |||
to the same rule. | refer to the same rule. | |||
Unlike original BNF, angle brackets ("<", ">") are not required. | Unlike original BNF, angle brackets ("<", ">") are not required. | |||
However, angle brackets may be used around a rule name whenever their | However, angle brackets may be used around a rule name whenever their | |||
presence will facilitate discerning the use of a rule name. This is | presence facilitates in discerning the use of a rule name. This is | |||
typically restricted to rule name references in free-form prose, or | typically restricted to rule name references in free-form prose, or | |||
to distinguish partial rules that combine into a string not separated | to distinguish partial rules that combine into a string not separated | |||
by white space, such as shown in the discussion about repetition, | by white space, such as shown in the discussion about repetition, | |||
below. | below. | |||
2.2 Rule Form | 2.2. Rule Form | |||
A rule is defined by the following sequence: | A rule is defined by the following sequence: | |||
name = elements crlf | name = elements crlf | |||
where <name> is the name of the rule, <elements> is one or more rule | 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 | names or terminal specifications, and <crlf> is the end-of-line | |||
indicator, carriage return followed by line feed. The equal sign | indicator (carriage return followed by line feed). The equal sign | |||
separates the name from the definition of the rule. The elements | separates the name from the definition of the rule. The elements | |||
form a sequence of one or more rule names and/or value definitions, | form a sequence of one or more rule names and/or value definitions, | |||
combined according to the various operators, defined in this | combined according to the various operators defined in this document, | |||
document, such as alternative and repetition. | such as alternative and repetition. | |||
For visual ease, rule definitions are left aligned. When a rule | For visual ease, rule definitions are left aligned. When a rule | |||
requires multiple lines, the continuation lines are indented. The | requires multiple lines, the continuation lines are indented. The | |||
left alignment and indentation are relative to the first lines of 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. | ABNF rules and need not match the left margin of the document. | |||
2.3 Terminal Values | 2.3. Terminal Values | |||
Rules resolve into a string of terminal values, sometimes called | Rules resolve into a string of terminal values, sometimes called | |||
characters. In ABNF a character is merely a non-negative integer. | characters. In ABNF, a character is merely a non-negative integer. | |||
In certain contexts a specific mapping (encoding) of values into a | In certain contexts, a specific mapping (encoding) of values into a | |||
character set (such as ASCII) will be specified. | character set (such as ASCII) will be specified. | |||
Terminals are specified by one or more numeric characters with the | Terminals are specified by one or more numeric characters, with the | |||
base interpretation of those characters indicated explicitly. The | base interpretation of those characters indicated explicitly. The | |||
following bases are currently defined: | following bases are currently defined: | |||
b = binary | b = binary | |||
d = decimal | d = decimal | |||
x = hexadecimal | x = hexadecimal | |||
Hence: | Hence: | |||
CR = %d13 | CR = %d13 | |||
CR = %x0D | CR = %x0D | |||
respectively specify the decimal and hexadecimal representation of | respectively specify the decimal and hexadecimal representation of | |||
[US-ASCII] for carriage return. | [US-ASCII] for carriage return. | |||
A concatenated string of such values is specified compactly, using a | A concatenated string of such values is specified compactly, using a | |||
period (".") to indicate separation of characters within that value. | period (".") to indicate a separation of characters within that | |||
Hence: | value. Hence: | |||
CRLF = %d13.10 | CRLF = %d13.10 | |||
ABNF permits specifying literal text string directly, enclosed in | ABNF permits the specification of literal text strings directly, | |||
quotation-marks. Hence: | enclosed in quotation-marks. Hence: | |||
command = "command string" | command = "command string" | |||
Literal text strings are interpreted as a concatenated set of | Literal text strings are interpreted as a concatenated set of | |||
printable characters. | printable characters. | |||
NOTE: ABNF strings are case-insensitive and | NOTE: | |||
the character set for these strings is us-ascii. | ||||
ABNF strings are case-insensitive and the character set for these | ||||
strings is us-ascii. | ||||
Hence: | Hence: | |||
rulename = "abc" | rulename = "abc" | |||
and: | and: | |||
rulename = "aBc" | rulename = "aBc" | |||
will match "abc", "Abc", "aBc", "abC", "ABc", "aBC", "AbC" and "ABC". | will match "abc", "Abc", "aBc", "abC", "ABc", "aBC", "AbC", and | |||
"ABC". | ||||
To specify a rule which IS case SENSITIVE, | To specify a rule that IS case SENSITIVE, specify the characters | |||
specify the characters individually. | individually. | |||
For example: | For example: | |||
rulename = %d97 %d98 %d99 | rulename = %d97 %d98 %d99 | |||
or | or | |||
rulename = %d97.98.99 | rulename = %d97.98.99 | |||
will match only the string which comprises only lowercased | will match only the string that comprises only the lowercased | |||
characters, abc. | characters, abc. | |||
2.4 External Encodings | 2.4. External Encodings | |||
External representations of terminal value characters will vary | External representations of terminal value characters will vary | |||
according to constraints in the storage or transmission environment. | according to constraints in the storage or transmission environment. | |||
Hence, the same ABNF-based grammar may have multiple external | Hence, the same ABNF-based grammar may have multiple external | |||
encodings, such as one for a 7-bit US-ASCII environment, another for | 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 | a binary octet environment, and still a different one when 16-bit | |||
Unicode is used. Encoding details are beyond the scope of ABNF, | Unicode is used. Encoding details are beyond the scope of ABNF, | |||
although Appendix A (Core) provides definitions for a 7-bit US-ASCII | although Appendix A (Core) provides definitions for a 7-bit US-ASCII | |||
environment as has been common to much of the Internet. | environment as has been common to much of the Internet. | |||
By separating external encoding from the syntax, it is intended that | By separating external encoding from the syntax, it is intended that | |||
alternate encoding environments can be used for the same syntax. | alternate encoding environments can be used for the same syntax. | |||
3. OPERATORS | 3. OPERATORS | |||
3.1 Concatenation Rule1 Rule2 | 3.1. Concatenation: Rule1 Rule2 | |||
A rule can define a simple, ordered string of values -- i.e., a | A rule can define a simple, ordered string of values (i.e., a | |||
concatenation of contiguous characters -- by listing a sequence of | concatenation of contiguous characters) by listing a sequence of rule | |||
rule names. For example: | names. For example: | |||
foo = %x61 ; a | foo = %x61 ; a | |||
bar = %x62 ; b | bar = %x62 ; b | |||
mumble = foo bar foo | mumble = foo bar foo | |||
So that the rule <mumble> matches the lowercase string "aba". | So that the rule <mumble> matches the lowercase string "aba". | |||
LINEAR WHITE SPACE: Concatenation is at the core of the ABNF | LINEAR WHITE SPACE: Concatenation is at the core of the ABNF parsing | |||
parsing model. A string of contiguous characters (values) is | model. A string of contiguous characters (values) is parsed | |||
parsed according to the rules defined in ABNF. For Internet | according to the rules defined in ABNF. For Internet specifications, | |||
specifications, there is some history of permitting linear white | there is some history of permitting linear white space (space and | |||
space (space and horizontal tab) to be freelyPand | horizontal tab) to be freely and implicitly interspersed around major | |||
implicitlyPinterspersed around major constructs, such as | constructs, such as delimiting special characters or atomic strings. | |||
delimiting special characters or atomic strings. | ||||
NOTE: This specification for ABNF does not | NOTE: | |||
provide for implicit specification of linear white | ||||
space. | ||||
Any grammar which wishes to permit linear white space around | This specification for ABNF does not provide for implicit | |||
specification of linear white space. | ||||
Any grammar that wishes to permit linear white space around | ||||
delimiters or string segments must specify it explicitly. It is | delimiters or string segments must specify it explicitly. It is | |||
often useful to provide for such white space in "core" rules that are | often useful to provide for such white space in "core" rules that are | |||
then used variously among higher-level rules. The "core" rules might | then used variously among higher-level rules. The "core" rules might | |||
be formed into a lexical analyzer or simply be part of the main | be formed into a lexical analyzer or simply be part of the main | |||
ruleset. | ruleset. | |||
3.2 Alternatives Rule1 / Rule2 | 3.2. Alternatives: Rule1 / Rule2 | |||
Elements separated by forward slash ("/") are alternatives. | Elements separated by a forward slash ("/") are alternatives. | |||
Therefore, | Therefore, | |||
foo / bar | foo / bar | |||
will accept <foo> or <bar>. | will accept <foo> or <bar>. | |||
NOTE: A quoted string containing alphabetic | NOTE: | |||
characters is special form for specifying alternative | ||||
characters and is interpreted as a non-terminal | A quoted string containing alphabetic characters is a special form | |||
representing the set of combinatorial strings with the | for specifying alternative characters and is interpreted as a | |||
contained characters, in the specified order but with | non-terminal representing the set of combinatorial strings with | |||
any mixture of upper and lower case.. | the contained characters, in the specified order but with any | |||
mixture of upper and lower case. | ||||
3.3 Incremental Alternatives Rule1 =/ Rule2 | 3.3. Incremental Alternatives: Rule1 =/ Rule2 | |||
It is sometimes convenient to specify a list of alternatives in | It is sometimes convenient to specify a list of alternatives in | |||
fragments. That is, an initial rule may match one or more | fragments. That is, an initial rule may match one or more | |||
alternatives, with later rule definitions adding to the set of | alternatives, with later rule definitions adding to the set of | |||
alternatives. This is particularly useful for otherwise- independent | alternatives. This is particularly useful for otherwise, independent | |||
specifications which derive from the same parent rule set, such as | specifications that derive from the same parent rule set, such as | |||
often occurs with parameter lists. ABNF permits this incremental | often occurs with parameter lists. ABNF permits this incremental | |||
definition through the construct: | definition through the construct: | |||
oldrule =/ additional-alternatives | oldrule =/ additional-alternatives | |||
So that the rule set | So that the rule set | |||
ruleset = alt1 / alt2 | ruleset = alt1 / alt2 | |||
ruleset =/ alt3 | ruleset =/ alt3 | |||
ruleset =/ alt4 / alt5 | ruleset =/ alt4 / alt5 | |||
is the same as specifying | is the same as specifying | |||
ruleset = alt1 / alt2 / alt3 / alt4 / alt5 | ruleset = alt1 / alt2 / alt3 / alt4 / alt5 | |||
3.4 Value Range Alternatives %c##-## | 3.4. Value Range Alternatives: %c##-## | |||
A range of alternative numeric values can be specified compactly, | A range of alternative numeric values can be specified compactly, | |||
using dash ("-") to indicate the range of alternative values. Hence: | using dash ("-") to indicate the range of alternative values. Hence: | |||
DIGIT = %x30-39 | DIGIT = %x30-39 | |||
is equivalent to: | is equivalent to: | |||
DIGIT = "0" / "1" / "2" / "3" / "4" / "5" / "6" / | DIGIT = "0" / "1" / "2" / "3" / "4" / "5" / "6" / | |||
"7" / "8" / "9" | "7" / "8" / "9" | |||
Concatenated numeric values and numeric value ranges can not be | Concatenated numeric values and numeric value ranges cannot be | |||
specified in the same string. A numeric value may use the dotted | specified in the same string. A numeric value may use the dotted | |||
notation for concatenation or it may use the dash notation to specify | notation for concatenation or it may use the dash notation to specify | |||
one value range. Hence, to specify one printable character, between | one value range. Hence, to specify one printable character between | |||
end of line sequences, the specification could be: | end of line sequences, the specification could be: | |||
char-line = %x0D.0A %x20-7E %x0D.0A | char-line = %x0D.0A %x20-7E %x0D.0A | |||
3.5 Sequence Group (Rule1 Rule2) | 3.5. Sequence Group: (Rule1 Rule2) | |||
Elements enclosed in parentheses are treated as a single element, | Elements enclosed in parentheses are treated as a single element, | |||
whose contents are STRICTLY ORDERED. Thus, | whose contents are STRICTLY ORDERED. Thus, | |||
elem (foo / bar) blat | elem (foo / bar) blat | |||
which matches (elem foo blat) or (elem bar blat). | matches (elem foo blat) or (elem bar blat), and | |||
elem foo / bar blat | elem foo / bar blat | |||
matches (elem foo) or (bar blat). | matches (elem foo) or (bar blat). | |||
NOTE: It is strongly advised to use grouping | NOTE: | |||
notation, rather than to rely on proper reading of | ||||
"bare" alternations, when alternatives consist of | ||||
multiple rule names or literals. | ||||
Hence it is recommended that instead of the above form, the form: | It is strongly advised that grouping notation be used, rather than | |||
relying on the proper reading of "bare" alternations, when | ||||
alternatives consist of multiple rule names or literals. | ||||
Hence, it is recommended that the following form be used: | ||||
(elem foo) / (bar blat) | (elem foo) / (bar blat) | |||
be used. It will avoid misinterpretation by casual readers. | It will avoid misinterpretation by casual readers. | |||
The sequence group notation is also used within free text to set off | The sequence group notation is also used within free text to set off | |||
an element sequence from the prose. | an element sequence from the prose. | |||
3.6 Variable Repetition *Rule | 3.6. Variable Repetition: *Rule | |||
The operator "*" preceding an element indicates repetition. The full | The operator "*" preceding an element indicates repetition. The full | |||
form is: | form is: | |||
<a>*<b>element | <a>*<b>element | |||
where <a> and <b> are optional decimal values, indicating at least | where <a> and <b> are optional decimal values, indicating at least | |||
<a> and at most <b> occurrences of element. | <a> and at most <b> occurrences of the element. | |||
Default values are 0 and infinity so that *<element> allows any | Default values are 0 and infinity so that *<element> allows any | |||
number, including zero; 1*<element> requires at least one; | number, including zero; 1*<element> requires at least one; | |||
3*3<element> allows exactly 3 and 1*2<element> allows one or two. | 3*3<element> allows exactly 3 and 1*2<element> allows one or two. | |||
3.7 Specific Repetition nRule | 3.7. Specific Repetition: nRule | |||
A rule of the form: | A rule of the form: | |||
<n>element | <n>element | |||
is equivalent to | is equivalent to | |||
<n>*<n>element | <n>*<n>element | |||
That is, exactly <N> occurrences of <element>. Thus 2DIGIT is a | That is, exactly <n> occurrences of <element>. Thus, 2DIGIT is a 2- | |||
2-digit number, and 3ALPHA is a string of three alphabetic | digit number, and 3ALPHA is a string of three alphabetic characters. | |||
characters. | ||||
3.8 Optional Sequence [RULE] | 3.8. Optional Sequence: [RULE] | |||
Square brackets enclose an optional element sequence: | Square brackets enclose an optional element sequence: | |||
[foo bar] | [foo bar] | |||
is equivalent to | is equivalent to | |||
*1(foo bar). | *1(foo bar). | |||
3.9 ; Comment | 3.9. Comment: ; Comment | |||
A semi-colon starts a comment that continues to the end of line. | A semi-colon starts a comment that continues to the end of line. | |||
This is a simple way of including useful notes in parallel with the | This is a simple way of including useful notes in parallel with the | |||
specifications. | specifications. | |||
3.10 Operator Precedence | 3.10. Operator Precedence | |||
The various mechanisms described above have the following precedence, | The various mechanisms described above have the following precedence, | |||
from highest (binding tightest) at the top, to lowest and loosest at | from highest (binding tightest) at the top, to lowest (loosest) at | |||
the bottom: | the bottom: | |||
Strings, Names formation | Strings, Names formation | |||
Comment | ||||
Value range | Comment | |||
Repetition | ||||
Grouping, Optional | Value range | |||
Concatenation | ||||
Alternative | Repetition | |||
Grouping, Optional | ||||
Concatenation | ||||
Alternative | ||||
Use of the alternative operator, freely mixed with concatenations, | ||||
can be confusing. | ||||
Use of the alternative operator, freely mixed with concatenations can | Again, it is recommended that the grouping operator be used to | |||
be confusing. | make explicit concatenation groups. | |||
Again, it is recommended that the grouping operator be used to | 4. ABNF DEFINITION OF ABNF | |||
make explicit concatenation groups. | ||||
4. ABNF DEFINITION OF ABNF | NOTES: | |||
This syntax uses the rules provided in Appendix A (Core). | 1. This syntax requires a formatting of rules that is relatively | |||
strict. Hence, the version of a ruleset included in a | ||||
specification might need preprocessing to ensure that it can be | ||||
interpreted by an ABNF parser. | ||||
rulelist = 1*( rule / (*c-wsp c-nl) ) | 2. This syntax uses the rules provided in Appendix B (Core). | |||
rule = rulename defined-as elements c-nl | rulelist = 1*( rule / (*c-wsp c-nl) ) | |||
; continues if next line starts | ||||
; with white space | ||||
rulename = ALPHA *(ALPHA / DIGIT / "-") | rule = rulename defined-as elements c-nl | |||
; continues if next line starts | ||||
; with white space | ||||
defined-as = *c-wsp ("=" / "=/") *c-wsp | rulename = ALPHA *(ALPHA / DIGIT / "-") | |||
; basic rules definition and | ||||
; incremental alternatives | ||||
elements = alternation *c-wsp | defined-as = *c-wsp ("=" / "=/") *c-wsp | |||
; basic rules definition and | ||||
; incremental alternatives | ||||
c-wsp = WSP / (c-nl WSP) | elements = alternation *c-wsp | |||
c-nl = comment / CRLF | c-wsp = WSP / (c-nl WSP) | |||
; comment or newline | ||||
comment = ";" *(WSP / VCHAR) CRLF | c-nl = comment / CRLF | |||
; comment or newline | ||||
alternation = concatenation | comment = ";" *(WSP / VCHAR) CRLF | |||
*(*c-wsp "/" *c-wsp concatenation) | ||||
concatenation = repetition *(1*c-wsp repetition) | alternation = concatenation | |||
*(*c-wsp "/" *c-wsp concatenation) | ||||
repetition = [repeat] element | concatenation = repetition *(1*c-wsp repetition) | |||
repeat = 1*DIGIT / (*DIGIT "*" *DIGIT) | repetition = [repeat] element | |||
element = rulename / group / option / | repeat = 1*DIGIT / (*DIGIT "*" *DIGIT) | |||
char-val / num-val / prose-val | element = rulename / group / option / | |||
char-val / num-val / prose-val | ||||
group = "(" *c-wsp alternation *c-wsp ")" | group = "(" *c-wsp alternation *c-wsp ")" | |||
option = "[" *c-wsp alternation *c-wsp "]" | option = "[" *c-wsp alternation *c-wsp "]" | |||
char-val = DQUOTE *(%x20-21 / %x23-7E) DQUOTE | char-val = DQUOTE *(%x20-21 / %x23-7E) DQUOTE | |||
; quoted string of SP and VCHAR | ; quoted string of SP and VCHAR | |||
without DQUOTE | ; without DQUOTE | |||
num-val = "%" (bin-val / dec-val / hex-val) | num-val = "%" (bin-val / dec-val / hex-val) | |||
bin-val = "b" 1*BIT | bin-val = "b" 1*BIT | |||
[ 1*("." 1*BIT) / ("-" 1*BIT) ] | [ 1*("." 1*BIT) / ("-" 1*BIT) ] | |||
; series of concatenated bit values | ; series of concatenated bit values | |||
; or single ONEOF range | ; or single ONEOF range | |||
dec-val = "d" 1*DIGIT | dec-val = "d" 1*DIGIT | |||
[ 1*("." 1*DIGIT) / ("-" 1*DIGIT) ] | [ 1*("." 1*DIGIT) / ("-" 1*DIGIT) ] | |||
hex-val = "x" 1*HEXDIG | hex-val = "x" 1*HEXDIG | |||
[ 1*("." 1*HEXDIG) / ("-" 1*HEXDIG) ] | [ 1*("." 1*HEXDIG) / ("-" 1*HEXDIG) ] | |||
prose-val = "<" *(%x20-3D / %x3F-7E) ">" | prose-val = "<" *(%x20-3D / %x3F-7E) ">" | |||
; bracketed string of SP and VCHAR | ; bracketed string of SP and VCHAR | |||
without angles | ; without angles | |||
; prose description, to be used as | ; prose description, to be used as | |||
last resort | ; last resort | |||
5. SECURITY CONSIDERATIONS | 5. SECURITY CONSIDERATIONS | |||
Security is truly believed to be irrelevant to this document. | Security is truly believed to be irrelevant to this document. | |||
6. APPENDIX A - CORE | 6. References | |||
6.1. Normative References | ||||
[US-ASCII] American National Standards Institute, "Coded Character | ||||
Set -- 7-bit American Standard Code for Information | ||||
Interchange", ANSI X3.4, 1986. | ||||
6.2. Informative References | ||||
[RFC2234] Crocker, D. and P. Overell, "Augmented BNF for Syntax | ||||
Specifications: ABNF", RFC 2234, November 1997. | ||||
[RFC733] Crocker, D., Vittal, J., Pogran, K., and D. Henderson, | ||||
"Standard for the format of ARPA network text messages", | ||||
RFC 733, November 1977. | ||||
[RFC822] Crocker, D., "Standard for the format of ARPA Internet | ||||
text messages", STD 11, RFC 822, August 1982. | ||||
Appendix A. ACKNOWLEDGEMENTS | ||||
The syntax for ABNF was originally specified in RFC 733. Ken L. | ||||
Harrenstien, of SRI International, was responsible for re-coding the | ||||
BNF into an augmented BNF that makes the representation smaller and | ||||
easier to understand. | ||||
This recent project began as a simple effort to cull out the portion | ||||
of RFC 822 that has been repeatedly cited by non-email specification | ||||
writers, namely the description of augmented BNF. Rather than simply | ||||
and blindly converting the existing text into a separate document, | ||||
the working group chose to give careful consideration to the | ||||
deficiencies, as well as benefits, of the existing specification and | ||||
related specifications made available over the last 15 years, and | ||||
therefore to pursue enhancement. This turned the project into | ||||
something rather more ambitious than was first intended. | ||||
Interestingly, the result is not massively different from that | ||||
original, although decisions, such as removing the list notation, | ||||
came as a surprise. | ||||
This "separated" version of the specification was part of the DRUMS | ||||
working group, with significant contributions from Jerome Abela, | ||||
Harald Alvestrand, Robert Elz, Roger Fajman, Aviva Garrett, Tom | ||||
Harsch, Dan Kohn, Bill McQuillan, Keith Moore, Chris Newman, Pete | ||||
Resnick, and Henning Schulzrinne. | ||||
Julian Reschke warrants a special thanks for converting the Draft | ||||
Standard version to XML source form. | ||||
Appendix B. APPENDIX - CORE ABNF OF ABNF | ||||
This Appendix is provided as a convenient core for specific grammars. | This Appendix is provided as a convenient core for specific grammars. | |||
The definitions may be used as a core set of rules. | The definitions may be used as a core set of rules. | |||
6.1 Core Rules | B.1. Core Rules | |||
Certain basic rules are in uppercase, such as SP, HTAB, CRLF, | Certain basic rules are in uppercase, such as SP, HTAB, CRLF, DIGIT, | |||
DIGIT, ALPHA, etc. | ALPHA, etc. | |||
ALPHA = %x41-5A / %x61-7A ; A-Z / a-z | ALPHA = %x41-5A / %x61-7A ; A-Z / a-z | |||
BIT = "0" / "1" | BIT = "0" / "1" | |||
CHAR = %x01-7F | CHAR = %x01-7F | |||
; any 7-bit US-ASCII character, | ; any 7-bit US-ASCII character, | |||
excluding NUL | ; excluding NUL | |||
CR = %x0D | CR = %x0D | |||
; carriage return | ; carriage return | |||
CRLF = CR LF | CRLF = CR LF | |||
; Internet standard newline | ; Internet standard newline | |||
CTL = %x00-1F / %x7F | CTL = %x00-1F / %x7F | |||
; controls | ; controls | |||
DIGIT = %x30-39 | DIGIT = %x30-39 | |||
; 0-9 | ; 0-9 | |||
DQUOTE = %x22 | DQUOTE = %x22 | |||
; " (Double Quote) | ; " (Double Quote) | |||
HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F" | HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F" | |||
HTAB = %x09 | HTAB = %x09 | |||
; horizontal tab | ; horizontal tab | |||
LF = %x0A | LF = %x0A | |||
; linefeed | ; linefeed | |||
LWSP = *(WSP / CRLF WSP) | LWSP = *(WSP / CRLF WSP) | |||
; linear white space (past newline) | ; linear white space (past newline) | |||
OCTET = %x00-FF | OCTET = %x00-FF | |||
; 8 bits of data | ; 8 bits of data | |||
SP = %x20 | SP = %x20 | |||
; space | ||||
VCHAR = %x21-7E | VCHAR = %x21-7E | |||
; visible (printing) characters | ; visible (printing) characters | |||
WSP = SP / HTAB | WSP = SP / HTAB | |||
; white space | ; white space | |||
6.2 Common Encoding | B.2. Common Encoding | |||
Externally, data are represented as "network virtual ASCII", namely | Externally, data are represented as "network virtual ASCII" (namely, | |||
7-bit US-ASCII in an 8-bit field, with the high (8th) bit set to | 7-bit US-ASCII in an 8-bit field), with the high (8th) bit set to | |||
zero. A string of values is in "network byte order" with the | zero. A string of values is in "network byte order", in which the | |||
higher-valued bytes represented on the left-hand side and being sent | higher-valued bytes are represented on the left-hand side and are | |||
over the network first. | sent over the network first. | |||
7. ACKNOWLEDGMENTS | Authors' Addresses | |||
The syntax for ABNF was originally specified in RFC 733. Ken L. | Dave Crocker (editor) | |||
Harrenstien, of SRI International, was responsible for re-coding the | Brandenburg InternetWorking | |||
BNF into an augmented BNF that makes the representation smaller and | 675 Spruce Dr. | |||
easier to understand. | Sunnyvale, CA 94086 | |||
US | ||||
This recent project began as a simple effort to cull out the portion | Phone: +1.408.246.8253 | |||
of RFC 822 which has been repeatedly cited by non-email specification | EMail: dcrocker@bbiw.net | |||
writers, namely the description of augmented BNF. Rather than simply | ||||
and blindly converting the existing text into a separate document, | Paul Overell | |||
the working group chose to give careful consideration to the | THUS plc. | |||
deficiencies, as well as benefits, of the existing specification and | 1/2 Berkeley Square | |||
related specifications available over the last 15 years and therefore | 99 Berkeley Street | |||
to pursue enhancement. This turned the project into something rather | Glasgow | |||
more ambitious than first intended. Interestingly the result is not | G3 7HR | |||
massively different from that original, although decisions such as | UK | |||
removing the list notation came as a surprise. | ||||
EMail: paul.overell@thus.net | ||||
The current round of specification was part of the DRUMS working | ||||
group, with significant contributions from Jerome Abela , Harald | Full Copyright Statement | |||
Alvestrand, Robert Elz, Roger Fajman, Aviva Garrett, Tom Harsch, Dan | ||||
Kohn, Bill McQuillan, Keith Moore, Chris Newman , Pete Resnick and | Copyright (C) The Internet Society (2005). | |||
Henning Schulzrinne. | ||||
This document is subject to the rights, licenses and restrictions | ||||
8. REFERENCES | contained in BCP 78, and except as set forth therein, the authors | |||
retain all their rights. | ||||
[US-ASCII] Coded Character Set--7-Bit American Standard Code for | ||||
Information Interchange, ANSI X3.4-1986. | This document and the information contained herein are provided on an | |||
"AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS | ||||
[RFC733] Crocker, D., Vittal, J., Pogran, K., and D. Henderson, | OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET | |||
"Standard for the Format of ARPA Network Text Message," RFC 733, | ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, | |||
November 1977. | INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE | |||
INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED | ||||
[RFC822] Crocker, D., "Standard for the Format of ARPA Internet Text | WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. | |||
Messages", STD 11, RFC 822, August 1982. | ||||
Intellectual Property | ||||
9. CONTACT | ||||
The IETF takes no position regarding the validity or scope of any | ||||
David H. Crocker Paul Overell | Intellectual Property Rights or other rights that might be claimed to | |||
pertain to the implementation or use of the technology described in | ||||
Internet Mail Consortium Demon Internet Ltd | this document or the extent to which any license under such rights | |||
675 Spruce Dr. Dorking Business Park | might or might not be available; nor does it represent that it has | |||
Sunnyvale, CA 94086 USA Dorking | made any independent effort to identify any such rights. Information | |||
Surrey, RH4 1HN | on the procedures with respect to rights in RFC documents can be | |||
UK | found in BCP 78 and BCP 79. | |||
Phone: +1 408 246 8253 | Copies of IPR disclosures made to the IETF Secretariat and any | |||
Fax: +1 408 249 6205 | assurances of licenses to be made available, or the result of an | |||
EMail: dcrocker@imc.org paulo@turnpike.com | attempt made to obtain a general license or permission for the use of | |||
such proprietary rights by implementers or users of this | ||||
10. Full Copyright Statement | specification can be obtained from the IETF on-line IPR repository at | |||
http://www.ietf.org/ipr. | ||||
Copyright (C) The Internet Society (1997). All Rights Reserved. | ||||
The IETF invites any interested party to bring to its attention any | ||||
This document and translations of it may be copied and furnished to | copyrights, patents or patent applications, or other proprietary | |||
others, and derivative works that comment on or otherwise explain it | rights that may cover technology that may be required to implement | |||
or assist in its implementation may be prepared, copied, published | this standard. Please address the information to the IETF at ietf- | |||
and distributed, in whole or in part, without restriction of any | ipr@ietf.org. | |||
kind, provided that the above copyright notice and this paragraph are | ||||
included on all such copies and derivative works. However, this | Acknowledgement | |||
document itself may not be modified in any way, such as by removing | ||||
the copyright notice or references to the Internet Society or other | Funding for the RFC Editor function is currently provided by the | |||
Internet organizations, except as needed for the purpose of | Internet Society. | |||
developing Internet standards in which case the procedures for | ||||
copyrights defined in the Internet Standards process must be | ||||
followed, or as required to translate it into languages other than | ||||
English. | ||||
The limited permissions granted above are perpetual and will not be | ||||
revoked by the Internet Society or its successors or assigns. | ||||
This document and the information contained herein is provided on an | ||||
"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING | ||||
TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING | ||||
BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION | ||||
HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF | ||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. | ||||
End of changes. 144 change blocks. | ||||
266 lines changed or deleted | 346 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |