source: draft-ietf-httpbis/orig/rfc4234.html

Last change on this file was 2564, checked in by julian.reschke@…, 6 years ago

update rfc2617.xml (ABNF alignment was off from published version), regen all HTML

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