source: draft-ietf-httpbis/orig/rfc5234.html @ 1657

Last change on this file since 1657 was 1305, checked in by julian.reschke@…, 12 years ago

add RFC6266 to the specs folder, add link to published spec in "latest" draft, regen HTML

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/html
File size: 41.2 KB
Line 
1<!DOCTYPE html
2  PUBLIC "-//W3C//DTD HTML 4.01//EN">
3<html lang="en">
4   <head profile="http://www.w3.org/2006/03/hcard http://dublincore.org/documents/2008/08/04/dc-html/">
5      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6      <title>Augmented BNF for Syntax Specifications: ABNF</title><style type="text/css" title="Xml2Rfc (sans serif)">
7a {
8  text-decoration: none;
9}
10a.smpl {
11  color: black;
12}
13a:hover {
14  text-decoration: underline;
15}
16a:active {
17  text-decoration: underline;
18}
19address {
20  margin-top: 1em;
21  margin-left: 2em;
22  font-style: normal;
23}
24body {
25  color: black;
26  font-family: verdana, helvetica, arial, sans-serif;
27  font-size: 10pt;
28}
29cite {
30  font-style: normal;
31}
32dd {
33  margin-right: 2em;
34}
35dl {
36  margin-left: 2em;
37}
38
39ul.empty {
40  list-style-type: none;
41}
42ul.empty li {
43  margin-top: .5em;
44}
45dl p {
46  margin-left: 0em;
47}
48dt {
49  margin-top: .5em;
50}
51h1 {
52  font-size: 14pt;
53  line-height: 21pt;
54  page-break-after: avoid;
55}
56h1.np {
57  page-break-before: always;
58}
59h1 a {
60  color: #333333;
61}
62h2 {
63  font-size: 12pt;
64  line-height: 15pt;
65  page-break-after: avoid;
66}
67h3, h4, h5, h6 {
68  font-size: 10pt;
69  page-break-after: avoid;
70}
71h2 a, h3 a, h4 a, h5 a, h6 a {
72  color: black;
73}
74img {
75  margin-left: 3em;
76}
77li {
78  margin-left: 2em;
79  margin-right: 2em;
80}
81ol {
82  margin-left: 2em;
83  margin-right: 2em;
84}
85ol.la {
86  list-style-type: lower-alpha;
87}
88ol.ua {
89  list-style-type: upper-alpha;
90}
91ol p {
92  margin-left: 0em;
93}
94p {
95  margin-left: 2em;
96  margin-right: 2em;
97}
98pre {
99  margin-left: 3em;
100  background-color: lightyellow;
101  padding: .25em;
102}
103pre.text2 {
104  border-style: dotted;
105  border-width: 1px;
106  background-color: #f0f0f0;
107  width: 69em;
108}
109pre.inline {
110  background-color: white;
111  padding: 0em;
112}
113pre.text {
114  border-style: dotted;
115  border-width: 1px;
116  background-color: #f8f8f8;
117  width: 69em;
118}
119pre.drawing {
120  border-style: solid;
121  border-width: 1px;
122  background-color: #f8f8f8;
123  padding: 2em;
124}
125table {
126  margin-left: 2em;
127}
128table.header {
129  border-spacing: 1px;
130  width: 95%;
131  font-size: 10pt;
132  color: white;
133}
134td.top {
135  vertical-align: top;
136}
137td.topnowrap {
138  vertical-align: top;
139  white-space: nowrap;
140}
141table.header td {
142  background-color: gray;
143  width: 50%;
144}
145table.header a {
146  color: white;
147}
148td.reference {
149  vertical-align: top;
150  white-space: nowrap;
151  padding-right: 1em;
152}
153thead {
154  display:table-header-group;
155}
156ul.toc, ul.toc ul {
157  list-style: none;
158  margin-left: 1.5em;
159  margin-right: 0em;
160  padding-left: 0em;
161}
162ul.toc li {
163  line-height: 150%;
164  font-weight: bold;
165  font-size: 10pt;
166  margin-left: 0em;
167  margin-right: 0em;
168}
169ul.toc li li {
170  line-height: normal;
171  font-weight: normal;
172  font-size: 9pt;
173  margin-left: 0em;
174  margin-right: 0em;
175}
176li.excluded {
177  font-size: 0pt;
178}
179ul p {
180  margin-left: 0em;
181}
182
183.comment {
184  background-color: yellow;
185}
186.center {
187  text-align: center;
188}
189.error {
190  color: red;
191  font-style: italic;
192  font-weight: bold;
193}
194.figure {
195  font-weight: bold;
196  text-align: center;
197  font-size: 9pt;
198}
199.filename {
200  color: #333333;
201  font-weight: bold;
202  font-size: 12pt;
203  line-height: 21pt;
204  text-align: center;
205}
206.fn {
207  font-weight: bold;
208}
209.hidden {
210  display: none;
211}
212.left {
213  text-align: left;
214}
215.right {
216  text-align: right;
217}
218.title {
219  color: #990000;
220  font-size: 18pt;
221  line-height: 18pt;
222  font-weight: bold;
223  text-align: center;
224  margin-top: 36pt;
225}
226.vcardline {
227  display: block;
228}
229.warning {
230  font-size: 14pt;
231  background-color: yellow;
232}
233
234
235@media print {
236  .noprint {
237    display: none;
238  }
239 
240  a {
241    color: black;
242    text-decoration: none;
243  }
244
245  table.header {
246    width: 90%;
247  }
248
249  td.header {
250    width: 50%;
251    color: black;
252    background-color: white;
253    vertical-align: top;
254    font-size: 12pt;
255  }
256
257  ul.toc a::after {
258    content: leader('.') target-counter(attr(href), page);
259  }
260 
261  ul.ind li li a {
262    content: target-counter(attr(href), page);
263  }
264 
265  .print2col {
266    column-count: 2;
267    -moz-column-count: 2;
268    column-fill: auto;
269  }
270}
271
272@page {
273  @top-left {
274       content: "RFC 5234";
275  }
276  @top-right {
277       content: "January 2008";
278  }
279  @top-center {
280       content: "ABNF";
281  }
282  @bottom-left {
283       content: "Crocker & Overell";
284  }
285  @bottom-center {
286       content: "Standards Track";
287  }
288  @bottom-right {
289       content: "[Page " counter(page) "]";
290  }
291}
292
293@page:first {
294    @top-left {
295      content: normal;
296    }
297    @top-right {
298      content: normal;
299    }
300    @top-center {
301      content: normal;
302    }
303}
304</style><link rel="Contents" href="#rfc.toc">
305      <link rel="Author" href="#rfc.authors">
306      <link rel="Copyright" href="#rfc.copyright">
307      <link rel="Chapter" title="1 Introduction" href="#rfc.section.1">
308      <link rel="Chapter" title="2 Rule Definition" href="#rfc.section.2">
309      <link rel="Chapter" title="3 Operators" href="#rfc.section.3">
310      <link rel="Chapter" title="4 ABNF Definition of ABNF" href="#rfc.section.4">
311      <link rel="Chapter" title="5 Security Considerations" href="#rfc.section.5">
312      <link rel="Chapter" href="#rfc.section.6" title="6 References">
313      <link rel="Appendix" title="A Acknowledgements" href="#rfc.section.A">
314      <link rel="Appendix" title="B Core ABNF of ABNF" href="#rfc.section.B">
315      <link rel="Alternate" title="Authorative ASCII Version" href="http://www.ietf.org/rfc/rfc5234.txt">
316      <link rel="Help" title="RFC-Editor's Status Page" href="http://www.rfc-editor.org/info/rfc5234">
317      <link rel="Help" title="Additional Information on tools.ietf.org" href="http://tools.ietf.org/html/rfc5234">
318      <meta name="generator" content="http://greenbytes.de/tech/webdav/rfc2629.xslt, Revision 1.550, 2011-05-30 14:02:12, XSLT vendor: SAXON 8.9 from Saxonica http://www.saxonica.com/">
319      <meta name="keywords" content="ABNF, Augmented, Backus-Naur, Form, electronic, mail">
320      <link rel="schema.dct" href="http://purl.org/dc/terms/">
321      <meta name="dct.creator" content="Crocker, D.">
322      <meta name="dct.creator" content="Overell, P.">
323      <meta name="dct.identifier" content="urn:ietf:rfc:5234">
324      <meta name="dct.issued" scheme="ISO8601" content="2008-01">
325      <meta name="dct.replaces" content="urn:ietf:rfc:4234">
326      <meta name="dct.abstract" content="Internet technical specifications often need to define a formal syntax. Over the years, a modified version of Backus-Naur Form (BNF), called Augmented BNF (ABNF), has been popular among many Internet specifications. The current specification documents ABNF. It balances compactness and simplicity with reasonable representational power. The differences between standard BNF and ABNF involve naming rules, repetition, alternatives, order- independence, and value ranges. This specification also supplies additional rule definitions and encoding for a core lexical analyzer of the type common to several Internet specifications.">
327      <meta name="dct.isPartOf" content="urn:issn:2070-1721">
328      <meta name="description" content="Internet technical specifications often need to define a formal syntax. Over the years, a modified version of Backus-Naur Form (BNF), called Augmented BNF (ABNF), has been popular among many Internet specifications. The current specification documents ABNF. It balances compactness and simplicity with reasonable representational power. The differences between standard BNF and ABNF involve naming rules, repetition, alternatives, order- independence, and value ranges. This specification also supplies additional rule definitions and encoding for a core lexical analyzer of the type common to several Internet specifications.">
329   </head>
330   <body>
331      <table class="header">
332         <tbody>
333            <tr>
334               <td class="left">Network Working Group</td>
335               <td class="right">D. Crocker, Editor</td>
336            </tr>
337            <tr>
338               <td class="left">Request for Comments: 5234</td>
339               <td class="right">Brandenburg InternetWorking</td>
340            </tr>
341            <tr>
342               <td class="left">Obsoletes: <a href="http://tools.ietf.org/html/rfc4234">4234</a></td>
343               <td class="right">P. Overell</td>
344            </tr>
345            <tr>
346               <td class="left">STD: 68</td>
347               <td class="right">THUS plc.</td>
348            </tr>
349            <tr>
350               <td class="left">Category: Standards Track</td>
351               <td class="right">January 2008</td>
352            </tr>
353         </tbody>
354      </table>
355      <p class="title">Augmented BNF for Syntax Specifications: ABNF</p>
356      <h1><a id="rfc.status" href="#rfc.status">Status of This Memo</a></h1>
357      <p>This document specifies an Internet standards track protocol for the Internet community, and requests discussion and suggestions
358         for improvements. Please refer to the current edition of the “Internet Official Protocol Standards” (STD 1) for the standardization
359         state and status of this protocol. Distribution of this memo is unlimited.
360      </p>
361      <h1 id="rfc.abstract"><a href="#rfc.abstract">Abstract</a></h1>
362      <p>Internet technical specifications often need to define a formal syntax. Over the years, a modified version of Backus-Naur
363         Form (BNF), called Augmented BNF (ABNF), has been popular among many Internet specifications. The current specification documents
364         ABNF. It balances compactness and simplicity with reasonable representational power. The differences between standard BNF
365         and ABNF involve naming rules, repetition, alternatives, order- independence, and value ranges. This specification also supplies
366         additional rule definitions and encoding for a core lexical analyzer of the type common to several Internet specifications.
367      </p>
368      <hr class="noprint">
369      <h1 class="np" id="rfc.toc"><a href="#rfc.toc">Table of Contents</a></h1>
370      <ul class="toc">
371         <li>1.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.1">Introduction</a></li>
372         <li>2.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.2">Rule Definition</a><ul>
373               <li>2.1&nbsp;&nbsp;&nbsp;<a href="#rfc.section.2.1">Rule Naming</a></li>
374               <li>2.2&nbsp;&nbsp;&nbsp;<a href="#rfc.section.2.2">Rule Form</a></li>
375               <li>2.3&nbsp;&nbsp;&nbsp;<a href="#rfc.section.2.3">Terminal Values</a></li>
376               <li>2.4&nbsp;&nbsp;&nbsp;<a href="#rfc.section.2.4">External Encodings</a></li>
377            </ul>
378         </li>
379         <li>3.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.3">Operators</a><ul>
380               <li>3.1&nbsp;&nbsp;&nbsp;<a href="#rfc.section.3.1">Concatenation:  Rule1 Rule2</a></li>
381               <li>3.2&nbsp;&nbsp;&nbsp;<a href="#Alternatives">Alternatives:  Rule1 / Rule2</a></li>
382               <li>3.3&nbsp;&nbsp;&nbsp;<a href="#Incremental">Incremental Alternatives: Rule1 =/ Rule2</a></li>
383               <li>3.4&nbsp;&nbsp;&nbsp;<a href="#Range">Value Range Alternatives:  %c##-##</a></li>
384               <li>3.5&nbsp;&nbsp;&nbsp;<a href="#Sequence">Sequence Group:  (Rule1 Rule2)</a></li>
385               <li>3.6&nbsp;&nbsp;&nbsp;<a href="#VarRep">Variable Repetition:  *Rule</a></li>
386               <li>3.7&nbsp;&nbsp;&nbsp;<a href="#SpecRep">Specific Repetition:  nRule</a></li>
387               <li>3.8&nbsp;&nbsp;&nbsp;<a href="#OptSeq">Optional Sequence:  [RULE]</a></li>
388               <li>3.9&nbsp;&nbsp;&nbsp;<a href="#Comment">Comment:  ; Comment</a></li>
389               <li>3.10&nbsp;&nbsp;&nbsp;<a href="#rfc.section.3.10">Operator Precedence</a></li>
390            </ul>
391         </li>
392         <li>4.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.4">ABNF Definition of ABNF</a></li>
393         <li>5.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.5">Security Considerations</a></li>
394         <li>6.&nbsp;&nbsp;&nbsp;<a href="#rfc.references">References</a><ul>
395               <li>6.1&nbsp;&nbsp;&nbsp;<a href="#rfc.references.1">Normative References</a></li>
396               <li>6.2&nbsp;&nbsp;&nbsp;<a href="#rfc.references.2">Informative References</a></li>
397            </ul>
398         </li>
399         <li><a href="#rfc.authors">Authors' Addresses</a></li>
400         <li>A.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.A">Acknowledgements</a></li>
401         <li>B.&nbsp;&nbsp;&nbsp;<a href="#CORE">Core ABNF of ABNF</a><ul>
402               <li>B.1&nbsp;&nbsp;&nbsp;<a href="#rfc.section.B.1">Core Rules</a></li>
403               <li>B.2&nbsp;&nbsp;&nbsp;<a href="#rfc.section.B.2">Common Encoding</a></li>
404            </ul>
405         </li>
406         <li><a href="#rfc.ipr">Intellectual Property and Copyright Statements</a></li>
407      </ul>
408      <h1 id="rfc.section.1" class="np"><a href="#rfc.section.1">1.</a>&nbsp;Introduction
409      </h1>
410      <p id="rfc.section.1.p.1">Internet technical specifications often need to define a formal syntax and are free to employ whatever notation their authors
411         deem useful. Over the years, a modified version of Backus-Naur Form (BNF), called Augmented BNF (ABNF), has been popular among
412         many Internet specifications. It balances compactness and simplicity with reasonable representational power. In the early
413         days of the Arpanet, each specification contained its own definition of ABNF. This included the email specifications, <a href="#RFC733"><cite title="Standard for the format of ARPA network text messages">[RFC733]</cite></a> and then <a href="#RFC822"><cite title="Standard for the format of ARPA Internet text messages">[RFC822]</cite></a>, which came to be the common citations for defining ABNF. The current document separates those definitions to permit selective
414         reference. Predictably, it also provides some modifications and enhancements.
415      </p>
416      <p id="rfc.section.1.p.2">The differences between standard BNF and ABNF involve naming rules, repetition, alternatives, order-independence, and value
417         ranges. <a href="#CORE" title="Core ABNF of ABNF">Appendix&nbsp;B</a> supplies rule definitions and encoding for a core lexical analyzer of the type common to several Internet specifications.
418         It is provided as a convenience and is otherwise separate from the meta language defined in the body of this document, and
419         separate from its formal status.
420      </p>
421      <h1 id="rfc.section.2"><a href="#rfc.section.2">2.</a>&nbsp;Rule Definition
422      </h1>
423      <h2 id="rfc.section.2.1"><a href="#rfc.section.2.1">2.1</a>&nbsp;Rule Naming
424      </h2>
425      <p id="rfc.section.2.1.p.1">The name of a rule is simply the name itself, that is, a sequence of characters, beginning with an alphabetic character, and
426         followed by a combination of alphabetics, digits, and hyphens (dashes).
427      </p>
428      <p id="rfc.section.2.1.p.2"> </p>
429      <dl>
430         <dt>NOTE:  </dt>
431         <dd>Rule names are case insensitive.</dd>
432      </dl>
433      <p id="rfc.section.2.1.p.3">The names &lt;rulename&gt;, &lt;Rulename&gt;, &lt;RULENAME&gt;, and &lt;rUlENamE&gt; all refer to the same rule.</p>
434      <p id="rfc.section.2.1.p.4">Unlike original BNF, angle brackets ("&lt;", "&gt;") are not required. However, angle brackets may be used around a rule name whenever
435         their presence facilitates in discerning the use of a rule name. This is typically restricted to rule name references in free-form
436         prose, or to distinguish partial rules that combine into a string not separated by white space, such as shown in the discussion
437         about repetition, below.
438      </p>
439      <h2 id="rfc.section.2.2"><a href="#rfc.section.2.2">2.2</a>&nbsp;Rule Form
440      </h2>
441      <p id="rfc.section.2.2.p.1">A rule is defined by the following sequence:</p>
442      <div id="rfc.figure.u.1"></div> <pre>
443      name =  elements crlf </pre> <p id="rfc.section.2.2.p.3">where &lt;name&gt; is the name of the rule, &lt;elements&gt; is one or more rule names or terminal specifications, and &lt;crlf&gt; is the end-of-line
444         indicator (carriage return followed by line feed). The equal sign separates the name from the definition of the rule. The
445         elements form a sequence of one or more rule names and/or value definitions, combined according to the various operators defined
446         in this document, such as alternative and repetition.
447      </p>
448      <p id="rfc.section.2.2.p.4">For visual ease, rule definitions are left aligned. When a rule requires multiple lines, the continuation lines are indented.
449         The left alignment and indentation are relative to the first lines of the ABNF rules and need not match the left margin of
450         the document.
451      </p>
452      <h2 id="rfc.section.2.3"><a href="#rfc.section.2.3">2.3</a>&nbsp;Terminal Values
453      </h2>
454      <p id="rfc.section.2.3.p.1">Rules resolve into a string of terminal values, sometimes called characters. In ABNF, a character is merely a non-negative
455         integer. In certain contexts, a specific mapping (encoding) of values into a character set (such as ASCII) will be specified.
456      </p>
457      <div id="rfc.figure.u.2"></div>
458      <p>Terminals are specified by one or more numeric characters, with the base interpretation of those characters indicated explicitly.
459         The following bases are currently defined:
460      </p>  <pre>
461      b           =  binary
462
463      d           =  decimal
464
465      x           =  hexadecimal </pre> <div id="rfc.figure.u.3"></div>
466      <p>Hence:</p>  <pre>
467      CR          =  %d13
468
469      CR          =  %x0D
470</pre>  <p>respectively specify the decimal and hexadecimal representation of <a href="#US-ASCII"><cite title="Coded Character Set -- 7-bit American Standard Code for Information Interchange">[US-ASCII]</cite></a> for carriage return.
471      </p>
472      <div id="rfc.figure.u.4"></div>
473      <p>A concatenated string of such values is specified compactly, using a period (".") to indicate a separation of characters within
474         that value. Hence:
475      </p>  <pre>
476      CRLF        =  %d13.10 </pre> <div id="rfc.figure.u.5"></div>
477      <p>ABNF permits the specification of literal text strings directly, enclosed in quotation marks. Hence:</p>  <pre>
478      command     =  "command string" </pre> <p id="rfc.section.2.3.p.6">Literal text strings are interpreted as a concatenated set of printable characters.</p>
479      <p id="rfc.section.2.3.p.7"> </p>
480      <dl>
481         <dt>NOTE:  </dt>
482         <dd>ABNF strings are case insensitive and the character set for these strings is US-ASCII.</dd>
483      </dl>
484      <div id="rfc.figure.u.6"></div>
485      <p>Hence:</p>  <pre>
486      rulename = "abc" </pre> <div id="rfc.figure.u.7"></div>
487      <p>and:</p>  <pre>
488      rulename = "aBc"
489</pre>  <p>will match "abc", "Abc", "aBc", "abC", "ABc", "aBC", "AbC", and "ABC".</p>
490      <p id="rfc.section.2.3.p.10"> </p>
491      <ul class="empty">
492         <li>To specify a rule that is case sensitive, specify the characters individually.</li>
493      </ul>
494      <div id="rfc.figure.u.8"></div>
495      <p>For example:</p>  <pre>
496      rulename    =  %d97 %d98 %d99
497</pre> <div id="rfc.figure.u.9"></div>
498      <p>or</p>  <pre>
499      rulename    =  %d97.98.99
500</pre>  <p>will match only the string that comprises only the lowercase characters, abc.</p>
501      <h2 id="rfc.section.2.4"><a href="#rfc.section.2.4">2.4</a>&nbsp;External Encodings
502      </h2>
503      <p id="rfc.section.2.4.p.1">External representations of terminal value characters will vary according to constraints in the storage or transmission environment.
504         Hence, the same ABNF-based grammar may have multiple external encodings, such as one for a 7-bit US-ASCII environment, another
505         for a binary octet environment, and still a different one when 16-bit Unicode is used. Encoding details are beyond the scope
506         of ABNF, although <a href="#CORE" title="Core ABNF of ABNF">Appendix&nbsp;B</a> provides definitions for a 7-bit US-ASCII environment as has been common to much of the Internet.
507      </p>
508      <p id="rfc.section.2.4.p.2">By separating external encoding from the syntax, it is intended that alternate encoding environments can be used for the same
509         syntax.
510      </p>
511      <h1 id="rfc.section.3"><a href="#rfc.section.3">3.</a>&nbsp;Operators
512      </h1>
513      <h2 id="rfc.section.3.1"><a href="#rfc.section.3.1">3.1</a>&nbsp;Concatenation:  Rule1 Rule2
514      </h2>
515      <p id="rfc.section.3.1.p.1">A rule can define a simple, ordered string of values (i.e., a concatenation of contiguous characters) by listing a sequence
516         of rule names. For example:
517      </p>
518      <div id="rfc.figure.u.10"></div> <pre>
519      foo         =  %x61           ; a
520
521      bar         =  %x62           ; b
522
523      mumble      =  foo bar foo </pre> <p id="rfc.section.3.1.p.3">So that the rule &lt;mumble&gt; matches the lowercase string "aba".</p>
524      <p id="rfc.section.3.1.p.4">Linear white space: Concatenation is at the core of the ABNF parsing model. A string of contiguous characters (values) is
525         parsed according to the rules defined in ABNF. For Internet specifications, there is some history of permitting linear white
526         space (space and horizontal tab) to be freely and implicitly interspersed around major constructs, such as delimiting special
527         characters or atomic strings.
528      </p>
529      <p id="rfc.section.3.1.p.5">NOTE: </p>
530      <ul class="empty">
531         <li>This specification for ABNF does not provide for implicit specification of linear white space.</li>
532      </ul>
533      <p id="rfc.section.3.1.p.6">Any grammar that wishes to permit linear white space around delimiters or string segments must specify it explicitly. It is
534         often useful to provide for such white space in "core" rules that are then used variously among higher-level rules. The "core"
535         rules might be formed into a lexical analyzer or simply be part of the main ruleset.
536      </p>
537      <h2 id="rfc.section.3.2"><a href="#rfc.section.3.2">3.2</a>&nbsp;<a id="Alternatives" href="#Alternatives">Alternatives:  Rule1 / Rule2</a></h2>
538      <p id="rfc.section.3.2.p.1">Elements separated by a forward slash ("/") are alternatives. Therefore,</p>
539      <div id="rfc.figure.u.11"></div> <pre>
540      foo / bar 
541</pre>  <p>will accept &lt;foo&gt; or &lt;bar&gt;.</p>
542      <p id="rfc.section.3.2.p.3"> </p>
543      <dl>
544         <dt>NOTE:  </dt>
545         <dd>A quoted string containing alphabetic characters is a special form for specifying alternative characters and is interpreted
546            as a non-terminal representing the set of combinatorial strings with the contained characters, in the specified order but
547            with any mixture of upper- and lowercase.
548         </dd>
549      </dl>
550      <h2 id="rfc.section.3.3"><a href="#rfc.section.3.3">3.3</a>&nbsp;<a id="Incremental" href="#Incremental">Incremental Alternatives: Rule1 =/ Rule2</a></h2>
551      <p id="rfc.section.3.3.p.1">It is sometimes convenient to specify a list of alternatives in fragments. That is, an initial rule may match one or more
552         alternatives, with later rule definitions adding to the set of alternatives. This is particularly useful for otherwise independent
553         specifications that derive from the same parent ruleset, such as often occurs with parameter lists. ABNF permits this incremental
554         definition through the construct:
555      </p>
556      <div id="rfc.figure.u.12"></div> <pre>
557      oldrule     =/ additional-alternatives </pre> <div id="rfc.figure.u.13"></div>
558      <p>So that the ruleset</p>  <pre>
559      ruleset     =  alt1 / alt2
560
561      ruleset     =/ alt3
562
563      ruleset     =/ alt4 / alt5 </pre> <div id="rfc.figure.u.14"></div>
564      <p>is the same as specifying</p>  <pre>
565      ruleset     =  alt1 / alt2 / alt3 / alt4 / alt5 </pre> <h2 id="rfc.section.3.4"><a href="#rfc.section.3.4">3.4</a>&nbsp;<a id="Range" href="#Range">Value Range Alternatives:  %c##-##</a></h2>
566      <div id="rfc.figure.u.15"></div>
567      <p>A range of alternative numeric values can be specified compactly, using a dash ("-") to indicate the range of alternative
568         values. Hence:
569      </p>  <pre>
570      DIGIT       =  %x30-39 </pre> <div id="rfc.figure.u.16"></div>
571      <p>is equivalent to:</p>  <pre>
572      DIGIT       =  "0" / "1" / "2" / "3" / "4" / "5" / "6" /
573
574                     "7" / "8" / "9" </pre> <div id="rfc.figure.u.17"></div>
575      <p>Concatenated numeric values and numeric value ranges cannot be specified in the same string. A numeric value may use the dotted
576         notation for concatenation or it may use the dash notation to specify one value range. Hence, to specify one printable character
577         between end-of-line sequences, the specification could be:
578      </p>  <pre>
579      char-line = %x0D.0A %x20-7E %x0D.0A </pre> <h2 id="rfc.section.3.5"><a href="#rfc.section.3.5">3.5</a>&nbsp;<a id="Sequence" href="#Sequence">Sequence Group:  (Rule1 Rule2)</a></h2>
580      <div id="rfc.figure.u.18"></div>
581      <p>Elements enclosed in parentheses are treated as a single element, whose contents are strictly ordered. Thus,</p>  <pre>
582      elem (foo / bar) blat
583</pre>  <p>matches (elem foo blat) or (elem bar blat), and</p>
584      <div id="rfc.figure.u.19"></div> <pre>
585      elem foo / bar blat
586</pre>  <p>matches (elem foo) or (bar blat).</p>
587      <p id="rfc.section.3.5.p.3"> </p>
588      <dl>
589         <dt>NOTE:  </dt>
590         <dd>It is strongly advised that grouping notation be used, rather than relying on the proper reading of "bare" alternations, when
591            alternatives consist of multiple rule names or literals.
592         </dd>
593      </dl>
594      <div id="rfc.figure.u.20"></div>
595      <p>Hence, it is recommended that the following form be used:</p>  <pre>
596     (elem foo) / (bar blat)
597</pre>  <p>It will avoid misinterpretation by casual readers.</p>
598      <p id="rfc.section.3.5.p.5">The sequence group notation is also used within free text to set off an element sequence from the prose.</p>
599      <h2 id="rfc.section.3.6"><a href="#rfc.section.3.6">3.6</a>&nbsp;<a id="VarRep" href="#VarRep">Variable Repetition:  *Rule</a></h2>
600      <div id="rfc.figure.u.21"></div>
601      <p>The operator "*" preceding an element indicates repetition. The full form is:</p>  <pre>
602      &lt;a&gt;*&lt;b&gt;element
603</pre>  <p>where &lt;a&gt; and &lt;b&gt; are optional decimal values, indicating at least &lt;a&gt; and at most &lt;b&gt; occurrences of the element.</p>
604      <p id="rfc.section.3.6.p.2">Default values are 0 and infinity so that *&lt;element&gt; allows any number, including zero; 1*&lt;element&gt; requires at least one;
605         3*3&lt;element&gt; allows exactly 3; and 1*2&lt;element&gt; allows one or two.
606      </p>
607      <h2 id="rfc.section.3.7"><a href="#rfc.section.3.7">3.7</a>&nbsp;<a id="SpecRep" href="#SpecRep">Specific Repetition:  nRule</a></h2>
608      <div id="rfc.figure.u.22"></div>
609      <p>A rule of the form:</p>  <pre>
610      &lt;n&gt;element </pre> <div id="rfc.figure.u.23"></div>
611      <p>is equivalent to</p>  <pre>
612      &lt;n&gt;*&lt;n&gt;element </pre> <p id="rfc.section.3.7.p.3">That is, exactly &lt;n&gt; occurrences of &lt;element&gt;. Thus, 2DIGIT is a 2-digit number, and 3ALPHA is a string of three alphabetic
613         characters.
614      </p>
615      <h2 id="rfc.section.3.8"><a href="#rfc.section.3.8">3.8</a>&nbsp;<a id="OptSeq" href="#OptSeq">Optional Sequence:  [RULE]</a></h2>
616      <div id="rfc.figure.u.24"></div>
617      <p>Square brackets enclose an optional element sequence:</p>  <pre>
618      [foo bar] </pre> <div id="rfc.figure.u.25"></div>
619      <p>is equivalent to</p>  <pre>
620      *1(foo bar). </pre> <h2 id="rfc.section.3.9"><a href="#rfc.section.3.9">3.9</a>&nbsp;<a id="Comment" href="#Comment">Comment:  ; Comment</a></h2>
621      <p id="rfc.section.3.9.p.1">A semicolon starts a comment that continues to the end of line. This is a simple way of including useful notes in parallel
622         with the specifications.
623      </p>
624      <h2 id="rfc.section.3.10"><a href="#rfc.section.3.10">3.10</a>&nbsp;Operator Precedence
625      </h2>
626      <p id="rfc.section.3.10.p.1">The various mechanisms described above have the following precedence, from highest (binding tightest) at the top, to lowest
627         (loosest) at the bottom:
628      </p>
629      <ul class="empty">
630         <li>Rule name, prose-val, Terminal value</li>
631         <li>Comment</li>
632         <li>Value range</li>
633         <li>Repetition</li>
634         <li>Grouping, Optional</li>
635         <li>Concatenation</li>
636         <li>Alternative</li>
637      </ul>
638      <p id="rfc.section.3.10.p.2">Use of the alternative operator, freely mixed with concatenations, can be confusing.</p>
639      <p id="rfc.section.3.10.p.3"> </p>
640      <ul class="empty">
641         <li>Again, it is recommended that the grouping operator be used to make explicit concatenation groups.</li>
642      </ul>
643      <h1 id="rfc.section.4"><a href="#rfc.section.4">4.</a>&nbsp;ABNF Definition of ABNF
644      </h1>
645      <p id="rfc.section.4.p.1"> </p>
646      <dl>
647         <dt>NOTES:</dt>
648         <dd>
649            <ol>
650               <li>This syntax requires a formatting of rules that is relatively strict. Hence, the version of a ruleset included in a specification
651                  might need preprocessing to ensure that it can be interpreted by an ABNF parser.
652               </li>
653               <li>This syntax uses the rules provided in <a href="#CORE" title="Core ABNF of ABNF">Appendix&nbsp;B</a>.
654               </li>
655            </ol>
656         </dd>
657      </dl>
658      <div id="rfc.figure.u.26"></div> <pre class="inline">
659      rulelist       =  1*( rule / (*c-wsp c-nl) )
660
661      rule           =  rulename defined-as elements c-nl
662                             ; continues if next line starts
663                             ;  with white space
664
665      rulename       =  ALPHA *(ALPHA / DIGIT / "-")
666
667      defined-as     =  *c-wsp ("=" / "=/") *c-wsp
668                             ; basic rules definition and
669                             ;  incremental alternatives
670
671      elements       =  alternation *c-wsp
672
673      c-wsp          =  WSP / (c-nl WSP)
674
675      c-nl           =  comment / CRLF
676                             ; comment or newline
677
678      comment        =  ";" *(WSP / VCHAR) CRLF
679
680      alternation    =  concatenation
681                        *(*c-wsp "/" *c-wsp concatenation)
682
683      concatenation  =  repetition *(1*c-wsp repetition)
684
685      repetition     =  [repeat] element
686
687      repeat         =  1*DIGIT / (*DIGIT "*" *DIGIT)
688
689      element        =  rulename / group / option /
690                        char-val / num-val / prose-val
691
692      group          =  "(" *c-wsp alternation *c-wsp ")"
693
694      option         =  "[" *c-wsp alternation *c-wsp "]"
695
696      char-val       =  DQUOTE *(%x20-21 / %x23-7E) DQUOTE
697                             ; quoted string of SP and VCHAR
698                             ;  without DQUOTE
699
700      num-val        =  "%" (bin-val / dec-val / hex-val)
701
702      bin-val        =  "b" 1*BIT
703                        [ 1*("." 1*BIT) / ("-" 1*BIT) ]
704                             ; series of concatenated bit values
705                             ;  or single ONEOF range
706
707      dec-val        =  "d" 1*DIGIT
708                        [ 1*("." 1*DIGIT) / ("-" 1*DIGIT) ]
709
710      hex-val        =  "x" 1*HEXDIG
711                        [ 1*("." 1*HEXDIG) / ("-" 1*HEXDIG) ]
712
713
714
715
716      prose-val      =  "&lt;" *(%x20-3D / %x3F-7E) "&gt;"
717                             ; bracketed string of SP and VCHAR
718                             ;  without angles
719                             ; prose description, to be used as
720                             ;  last resort </pre> <h1 id="rfc.section.5"><a href="#rfc.section.5">5.</a>&nbsp;Security Considerations
721      </h1>
722      <p id="rfc.section.5.p.1">Security is truly believed to be irrelevant to this document.</p>
723      <h1 id="rfc.references"><a id="rfc.section.6" href="#rfc.section.6">6.</a> References
724      </h1>
725      <h2 id="rfc.references.1"><a href="#rfc.section.6.1" id="rfc.section.6.1">6.1</a> Normative References
726      </h2>
727      <table> 
728         <tr>
729            <td class="reference"><b id="US-ASCII">[US-ASCII]</b></td>
730            <td class="top">American National Standards
731               Institute, “Coded Character Set -- 7-bit American Standard Code for Information Interchange”, ANSI&nbsp;X3.4, 1986.
732            </td>
733         </tr>
734      </table>
735      <h2 id="rfc.references.2"><a href="#rfc.section.6.2" id="rfc.section.6.2">6.2</a> Informative References
736      </h2>
737      <table>   
738         <tr>
739            <td class="reference"><b id="RFC733">[RFC733]</b></td>
740            <td class="top"><a href="mailto:DCrocker@Rand-Unix" title="The Rand Corporation, Information Sciences&#xA;                     Department">Crocker, D.</a>, <a href="mailto:Vittal@BBN-TenexD" title="Bolt Beranek and Newman Inc. (BBN)">Vittal, J.</a>, <a href="mailto:Pogran@MIT-Multics" title="Massachusets Institute of Technology (MIT),&#xA;                     Laboratory for Computer Science">Pogran, K.</a>, and <a href="mailto:Henderson@BBN-TenexD" title="Bolt Beranek and Newman Inc. (BBN)">D. Henderson</a>, “<a href="http://tools.ietf.org/html/rfc733">Standard for the format of ARPA network text messages</a>”, RFC&nbsp;733, November&nbsp;1977.
741            </td>
742         </tr>
743         <tr>
744            <td class="reference"><b id="RFC822">[RFC822]</b></td>
745            <td class="top"><a href="mailto:DCrocker@UDel-Relay" title="University of Delaware, Dept. of Electrical&#xA;                     Engineering">Crocker, D.</a>, “<a href="http://tools.ietf.org/html/rfc822">Standard for the format of ARPA Internet text messages</a>”, STD&nbsp;11, RFC&nbsp;822, August&nbsp;1982.
746            </td>
747         </tr>
748      </table>
749      <div class="avoidbreak">
750         <h1 id="rfc.authors"><a href="#rfc.authors">Authors' Addresses</a></h1>
751         <address class="vcard"><span class="vcardline"><span class="fn">Dave Crocker</span>
752               (editor)
753               <span class="n hidden"><span class="family-name">Crocker</span><span class="given-name">Dave</span></span></span><span class="org vcardline">Brandenburg InternetWorking</span><span class="adr"><span class="street-address vcardline">675 Spruce Dr.</span><span class="vcardline"><span class="locality">Sunnyvale</span>, <span class="region">CA</span>&nbsp;<span class="postal-code">94086</span></span><span class="country-name vcardline">US</span></span><span class="vcardline tel">Phone: <a href="tel:+1.408.246.8253"><span class="value">+1.408.246.8253</span></a></span><span class="vcardline">Email: <a href="mailto:dcrocker@bbiw.net"><span class="email">dcrocker@bbiw.net</span></a></span></address>
754         <address class="vcard"><span class="vcardline"><span class="fn">Paul Overell</span><span class="n hidden"><span class="family-name">Overell</span><span class="given-name">Paul</span></span></span><span class="org vcardline">THUS plc.</span><span class="adr"><span class="street-address vcardline">1/2 Berkeley Square,</span><span class="street-address vcardline">99 Berkeley Street</span><span class="vcardline"><span class="locality">Glasgow</span>, <span class="postal-code">G3 7HR</span></span><span class="country-name vcardline">UK</span></span><span class="vcardline">Email: <a href="mailto:paul.overell@thus.net"><span class="email">paul.overell@thus.net</span></a></span></address>
755      </div>
756      <h1 id="rfc.section.A" class="np"><a href="#rfc.section.A">A.</a>&nbsp;Acknowledgements
757      </h1>
758      <p id="rfc.section.A.p.1">The syntax for ABNF was originally specified in RFC 733. Ken L. Harrenstien, of SRI International, was responsible for re-coding
759         the BNF into an Augmented BNF that makes the representation smaller and easier to understand.
760      </p>
761      <p id="rfc.section.A.p.2">This recent project began as a simple effort to cull out the portion of RFC 822 that has been repeatedly cited by non-email
762         specification writers, namely the description of Augmented BNF. Rather than simply and blindly converting the existing text
763         into a separate document, the working group chose to give careful consideration to the deficiencies, as well as benefits,
764         of the existing specification and related specifications made available over the last 15 years, and therefore to pursue enhancement.
765         This turned the project into something rather more ambitious than was first intended. Interestingly, the result is not massively
766         different from that original, although decisions, such as removing the list notation, came as a surprise.
767      </p>
768      <p id="rfc.section.A.p.3">This "separated" version of the specification was part of the DRUMS working group, with significant contributions from Jerome
769         Abela, Harald Alvestrand, Robert Elz, Roger Fajman, Aviva Garrett, Tom Harsch, Dan Kohn, Bill McQuillan, Keith Moore, Chris
770         Newman, Pete Resnick, and Henning Schulzrinne.
771      </p>
772      <p id="rfc.section.A.p.4">Julian Reschke warrants a special thanks for converting the Draft Standard version to XML source form.</p>
773      <h1 id="rfc.section.B"><a href="#rfc.section.B">B.</a>&nbsp;<a id="CORE" href="#CORE">Core ABNF of ABNF</a></h1>
774      <p id="rfc.section.B.p.1">This appendix contains some basic rules that are in common use. Basic rules are in uppercase. Note that these rules are only
775         valid for ABNF encoded in 7-bit ASCII or in characters sets that are a superset of 7-bit ASCII.
776      </p>
777      <h2 id="rfc.section.B.1"><a href="#rfc.section.B.1">B.1</a>&nbsp;Core Rules
778      </h2>
779      <p id="rfc.section.B.1.p.1">Certain basic rules are in uppercase, such as SP, HTAB, CRLF, DIGIT, ALPHA, etc.</p>
780      <div id="rfc.figure.u.27"></div> <pre class="inline">
781      ALPHA          =  %x41-5A / %x61-7A   ; A-Z / a-z
782
783      BIT            =  "0" / "1"
784
785      CHAR           =  %x01-7F
786                             ; any 7-bit US-ASCII character,
787                             ;  excluding NUL
788
789      CR             =  %x0D
790                             ; carriage return
791
792      CRLF           =  CR LF
793                             ; Internet standard newline
794
795      CTL            =  %x00-1F / %x7F
796                             ; controls
797
798      DIGIT          =  %x30-39
799                             ; 0-9
800
801      DQUOTE         =  %x22
802                             ; " (Double Quote)
803
804      HEXDIG         =  DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
805
806      HTAB           =  %x09
807                             ; horizontal tab
808
809      LF             =  %x0A
810                             ; linefeed
811
812      LWSP           =  *(WSP / CRLF WSP)
813                             ; Use of this linear-white-space rule
814                             ;  permits lines containing only white
815                             ;  space that are no longer legal in
816                             ;  mail headers and have caused
817                             ;  interoperability problems in other
818                             ;  contexts.
819                             ; Do not use when defining mail
820                             ;  headers and use with caution in
821                             ;  other contexts.
822
823      OCTET          =  %x00-FF
824                             ; 8 bits of data
825
826      SP             =  %x20
827
828      VCHAR          =  %x21-7E
829                             ; visible (printing) characters
830
831      WSP            =  SP / HTAB
832                             ; white space </pre> <h2 id="rfc.section.B.2"><a href="#rfc.section.B.2">B.2</a>&nbsp;Common Encoding
833      </h2>
834      <p id="rfc.section.B.2.p.1">Externally, data are represented as "network virtual ASCII" (namely, 7-bit US-ASCII in an 8-bit field), with the high (8th)
835         bit set to zero. A string of values is in "network byte order", in which the higher-valued bytes are represented on the left-hand
836         side and are sent over the network first.
837      </p>
838      <h1><a id="rfc.copyright" href="#rfc.copyright">Full Copyright Statement</a></h1>
839      <p>Copyright © The IETF Trust (2008).</p>
840      <p>This document is subject to the rights, licenses and restrictions contained in BCP 78, and except as set forth therein, the
841         authors retain all their rights.
842      </p>
843      <p>This document and the information contained herein are provided on an “AS IS” basis and THE CONTRIBUTOR, THE ORGANIZATION
844         HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY, THE IETF TRUST AND THE INTERNET ENGINEERING TASK FORCE
845         DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN
846         WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
847      </p>
848      <h1><a id="rfc.ipr" href="#rfc.ipr">Intellectual Property</a></h1>
849      <p>The IETF takes no position regarding the validity or scope of any Intellectual Property Rights or other rights that might
850         be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any
851         license under such rights might or might not be available; nor does it represent that it has made any independent effort to
852         identify any such rights. Information on the procedures with respect to rights in RFC documents can be found in BCP 78 and
853         BCP 79.
854      </p>
855      <p>Copies of IPR disclosures made to the IETF Secretariat and any assurances of licenses to be made available, or the result
856         of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users
857         of this specification can be obtained from the IETF on-line IPR repository at <a href="http://www.ietf.org/ipr">http://www.ietf.org/ipr</a>.
858      </p>
859      <p>The IETF invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary
860         rights that may cover technology that may be required to implement this standard. Please address the information to the IETF
861         at <a href="mailto:ietf-ipr@ietf.org">ietf-ipr@ietf.org</a>.
862      </p>
863   </body>
864</html>
Note: See TracBrowser for help on using the repository browser.