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

Last change on this file since 1784 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: 42.0 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 4234";
275  }
276  @top-right {
277       content: "October 2005";
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 APPENDIX - CORE ABNF OF ABNF" href="#rfc.section.B">
315      <link rel="Alternate" title="Authorative ASCII Version" href="http://www.ietf.org/rfc/rfc4234.txt">
316      <link rel="Help" title="RFC-Editor's Status Page" href="http://www.rfc-editor.org/info/rfc4234">
317      <link rel="Help" title="Additional Information on tools.ietf.org" href="http://tools.ietf.org/html/rfc4234">
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:4234">
324      <meta name="dct.issued" scheme="ISO8601" content="2005-10">
325      <meta name="dct.replaces" content="urn:ietf:rfc:2234">
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: 4234</td>
339               <td class="right">Brandenburg InternetWorking</td>
340            </tr>
341            <tr>
342               <td class="left">Obsoletes: <a href="http://tools.ietf.org/html/rfc2234">2234</a></td>
343               <td class="right">P. Overell</td>
344            </tr>
345            <tr>
346               <td class="left">Category: Standards Track</td>
347               <td class="right">THUS plc.</td>
348            </tr>
349            <tr>
350               <td class="left"></td>
351               <td class="right">October 2005</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><a id="rfc.copyrightnotice" href="#rfc.copyrightnotice">Copyright Notice</a></h1>
362      <p>Copyright © The Internet Society (2005). All Rights Reserved.</p>
363      <h1 id="rfc.abstract"><a href="#rfc.abstract">Abstract</a></h1>
364      <p>Internet technical specifications often need to define a formal syntax. Over the years, a modified version of Backus-Naur
365         Form (BNF), called Augmented BNF (ABNF), has been popular among many Internet specifications. The current specification documents
366         ABNF. It balances compactness and simplicity, with reasonable representational power. The differences between standard BNF
367         and ABNF involve naming rules, repetition, alternatives, order- independence, and value ranges. This specification also supplies
368         additional rule definitions and encoding for a core lexical analyzer of the type common to several Internet specifications.
369      </p>
370      <hr class="noprint">
371      <h1 class="np" id="rfc.toc"><a href="#rfc.toc">Table of Contents</a></h1>
372      <ul class="toc">
373         <li>1.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.1">INTRODUCTION</a></li>
374         <li>2.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.2">RULE DEFINITION</a><ul>
375               <li>2.1.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.2.1">Rule Naming</a></li>
376               <li>2.2.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.2.2">Rule Form</a></li>
377               <li>2.3.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.2.3">Terminal Values</a></li>
378               <li>2.4.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.2.4">External Encodings</a></li>
379            </ul>
380         </li>
381         <li>3.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.3">OPERATORS</a><ul>
382               <li>3.1.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.3.1">Concatenation:  Rule1 Rule2</a></li>
383               <li>3.2.&nbsp;&nbsp;&nbsp;<a href="#Alternatives">Alternatives:  Rule1 / Rule2</a></li>
384               <li>3.3.&nbsp;&nbsp;&nbsp;<a href="#Incremental">Incremental Alternatives: Rule1 =/ Rule2</a></li>
385               <li>3.4.&nbsp;&nbsp;&nbsp;<a href="#Range">Value Range Alternatives:  %c##-##</a></li>
386               <li>3.5.&nbsp;&nbsp;&nbsp;<a href="#Sequence">Sequence Group:  (Rule1 Rule2)</a></li>
387               <li>3.6.&nbsp;&nbsp;&nbsp;<a href="#VarRep">Variable Repetition:  *Rule</a></li>
388               <li>3.7.&nbsp;&nbsp;&nbsp;<a href="#SpecRep">Specific Repetition:  nRule</a></li>
389               <li>3.8.&nbsp;&nbsp;&nbsp;<a href="#OptSeq">Optional Sequence:  [RULE]</a></li>
390               <li>3.9.&nbsp;&nbsp;&nbsp;<a href="#Comment">Comment:  ; Comment</a></li>
391               <li>3.10.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.3.10">Operator Precedence</a></li>
392            </ul>
393         </li>
394         <li>4.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.4">ABNF DEFINITION OF ABNF</a></li>
395         <li>5.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.5">SECURITY CONSIDERATIONS</a></li>
396         <li>6.&nbsp;&nbsp;&nbsp;<a href="#rfc.references">References</a><ul>
397               <li>6.1.&nbsp;&nbsp;&nbsp;<a href="#rfc.references.1">Normative References</a></li>
398               <li>6.2.&nbsp;&nbsp;&nbsp;<a href="#rfc.references.2">Informative References</a></li>
399            </ul>
400         </li>
401         <li><a href="#rfc.authors">Authors' Addresses</a></li>
402         <li>A.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.A">ACKNOWLEDGEMENTS</a></li>
403         <li>B.&nbsp;&nbsp;&nbsp;<a href="#CORE">APPENDIX - CORE ABNF OF ABNF</a><ul>
404               <li>B.1.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.B.1">Core Rules</a></li>
405               <li>B.2.&nbsp;&nbsp;&nbsp;<a href="#rfc.section.B.2">Common Encoding</a></li>
406            </ul>
407         </li>
408         <li><a href="#rfc.ipr">Intellectual Property and Copyright Statements</a></li>
409      </ul>
410      <h1 id="rfc.section.1" class="np"><a href="#rfc.section.1">1.</a>&nbsp;INTRODUCTION
411      </h1>
412      <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
413         deem useful. Over the years, a modified version of Backus-Naur Form (BNF), called Augmented BNF (ABNF), has been popular among
414         many Internet specifications. It balances compactness and simplicity, with reasonable representational power. In the early
415         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
416         reference. Predictably, it also provides some modifications and enhancements.
417      </p>
418      <p id="rfc.section.1.p.2">The differences between standard BNF and ABNF involve naming rules, repetition, alternatives, order-independence, and value
419         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.
420         It is provided as a convenience and is otherwise separate from the meta language defined in the body of this document, and
421         separate from its formal status.
422      </p>
423      <dl>
424         <dt>Changes since [RFC2234]:</dt>
425         <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;."
426         </dd>
427         <dd>Some continuation comment lines needed to be corrected to begin with comment character (";").</dd>
428      </dl>
429      <h1 id="rfc.section.2"><a href="#rfc.section.2">2.</a>&nbsp;RULE DEFINITION
430      </h1>
431      <h2 id="rfc.section.2.1"><a href="#rfc.section.2.1">2.1.</a>&nbsp;Rule Naming
432      </h2>
433      <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
434         followed by a combination of alphabetics, digits, and hyphens (dashes).
435      </p>
436      <p id="rfc.section.2.1.p.2"> </p>
437      <dl>
438         <dt>NOTE:  </dt>
439         <dd>Rule names are case-insensitive</dd>
440      </dl>
441      <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>
442      <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
443         their presence facilitates in discerning the use of a rule name. This is typically restricted to rule name references in free-form
444         prose, or to distinguish partial rules that combine into a string not separated by white space, such as shown in the discussion
445         about repetition, below.
446      </p>
447      <h2 id="rfc.section.2.2"><a href="#rfc.section.2.2">2.2.</a>&nbsp;Rule Form
448      </h2>
449      <p id="rfc.section.2.2.p.1">A rule is defined by the following sequence:</p>
450      <div id="rfc.figure.u.1"></div> <pre class="text">
451      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
452         indicator (carriage return followed by line feed). The equal sign separates the name from the definition of the rule. The
453         elements form a sequence of one or more rule names and/or value definitions, combined according to the various operators defined
454         in this document, such as alternative and repetition.
455      </p>
456      <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.
457         The left alignment and indentation are relative to the first lines of the ABNF rules and need not match the left margin of
458         the document.
459      </p>
460      <h2 id="rfc.section.2.3"><a href="#rfc.section.2.3">2.3.</a>&nbsp;Terminal Values
461      </h2>
462      <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
463         integer. In certain contexts, a specific mapping (encoding) of values into a character set (such as ASCII) will be specified.
464      </p>
465      <div id="rfc.figure.u.2"></div>
466      <p>Terminals are specified by one or more numeric characters, with the base interpretation of those characters indicated explicitly.
467         The following bases are currently defined:
468      </p>  <pre class="text">
469      b           =  binary
470
471      d           =  decimal
472
473      x           =  hexadecimal </pre> <div id="rfc.figure.u.3"></div>
474      <p>Hence:</p>  <pre class="text">
475      CR          =  %d13
476
477      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.
478      </p>
479      <div id="rfc.figure.u.4"></div>
480      <p>A concatenated string of such values is specified compactly, using a period (".") to indicate a separation of characters within
481         that value. Hence:
482      </p>  <pre class="text">
483      CRLF        =  %d13.10 </pre> <div id="rfc.figure.u.5"></div>
484      <p>ABNF permits the specification of literal text strings directly, enclosed in quotation-marks. Hence:</p>  <pre class="text">
485      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>
486      <p id="rfc.section.2.3.p.7"> </p>
487      <dl>
488         <dt>NOTE:  </dt>
489         <dd>ABNF strings are case-insensitive and the character set for these strings is us-ascii.</dd>
490      </dl>
491      <div id="rfc.figure.u.6"></div>
492      <p>Hence:</p>  <pre class="text">
493      rulename = "abc" </pre> <div id="rfc.figure.u.7"></div>
494      <p>and:</p>  <pre class="text">
495      rulename = "aBc"
496</pre>  <p>will match "abc", "Abc", "aBc", "abC", "ABc", "aBC", "AbC", and "ABC".</p>
497      <p id="rfc.section.2.3.p.10"> </p>
498      <ul class="empty">
499         <li>To specify a rule that IS case SENSITIVE, specify the characters individually.</li>
500      </ul>
501      <div id="rfc.figure.u.8"></div>
502      <p>For example:</p>  <pre class="text">
503      rulename    =  %d97 %d98 %d99
504</pre> <div id="rfc.figure.u.9"></div>
505      <p>or</p>  <pre class="text">
506      rulename    =  %d97.98.99
507</pre>  <p>will match only the string that comprises only the lowercased characters, abc.</p>
508      <h2 id="rfc.section.2.4"><a href="#rfc.section.2.4">2.4.</a>&nbsp;External Encodings
509      </h2>
510      <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.
511         Hence, the same ABNF-based grammar may have multiple external encodings, such as one for a 7-bit US-ASCII environment, another
512         for a binary octet environment, and still a different one when 16-bit Unicode is used. Encoding details are beyond the scope
513         of ABNF, although Appendix A (Core) provides definitions for a 7-bit US-ASCII environment as has been common to much of the
514         Internet.
515      </p>
516      <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
517         syntax.
518      </p>
519      <h1 id="rfc.section.3"><a href="#rfc.section.3">3.</a>&nbsp;OPERATORS
520      </h1>
521      <h2 id="rfc.section.3.1"><a href="#rfc.section.3.1">3.1.</a>&nbsp;Concatenation:  Rule1 Rule2
522      </h2>
523      <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
524         of rule names. For example:
525      </p>
526      <div id="rfc.figure.u.10"></div> <pre class="text">
527      foo         =  %x61           ; a
528
529      bar         =  %x62           ; b
530
531      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>
532      <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
533         parsed according to the rules defined in ABNF. For Internet specifications, there is some history of permitting linear white
534         space (space and horizontal tab) to be freely and implicitly interspersed around major constructs, such as delimiting special
535         characters or atomic strings.
536      </p>
537      <p id="rfc.section.3.1.p.5">NOTE: </p>
538      <ul class="empty">
539         <li>This specification for ABNF does not provide for implicit specification of linear white space.</li>
540      </ul>
541      <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
542         often useful to provide for such white space in "core" rules that are then used variously among higher-level rules. The "core"
543         rules might be formed into a lexical analyzer or simply be part of the main ruleset.
544      </p>
545      <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>
546      <p id="rfc.section.3.2.p.1">Elements separated by a forward slash ("/") are alternatives. Therefore,</p>
547      <div id="rfc.figure.u.11"></div> <pre class="text">
548      foo / bar 
549</pre>  <p>will accept &lt;foo&gt; or &lt;bar&gt;.</p>
550      <p id="rfc.section.3.2.p.3"> </p>
551      <dl>
552         <dt>NOTE:  </dt>
553         <dd>A quoted string containing alphabetic characters is a special form for specifying alternative characters and is interpreted
554            as a non-terminal representing the set of combinatorial strings with the contained characters, in the specified order but
555            with any mixture of upper and lower case.
556         </dd>
557      </dl>
558      <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>
559      <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
560         alternatives, with later rule definitions adding to the set of alternatives. This is particularly useful for otherwise, independent
561         specifications that derive from the same parent rule set, such as often occurs with parameter lists. ABNF permits this incremental
562         definition through the construct:
563      </p>
564      <div id="rfc.figure.u.12"></div> <pre class="text">
565      oldrule     =/ additional-alternatives </pre> <div id="rfc.figure.u.13"></div>
566      <p>So that the rule set</p>  <pre class="text">
567      ruleset     =  alt1 / alt2
568
569      ruleset     =/ alt3
570
571      ruleset     =/ alt4 / alt5 </pre> <div id="rfc.figure.u.14"></div>
572      <p>is the same as specifying</p>  <pre class="text">
573      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>
574      <div id="rfc.figure.u.15"></div>
575      <p>A range of alternative numeric values can be specified compactly, using dash ("-") to indicate the range of alternative values.
576         Hence:
577      </p>  <pre class="text">
578      DIGIT       =  %x30-39 </pre> <div id="rfc.figure.u.16"></div>
579      <p>is equivalent to:</p>  <pre class="text">
580      DIGIT       =  "0" / "1" / "2" / "3" / "4" / "5" / "6" /
581
582                     "7" / "8" / "9" </pre> <div id="rfc.figure.u.17"></div>
583      <p>Concatenated numeric values and numeric value ranges cannot be specified in the same string. A numeric value may use the dotted
584         notation for concatenation or it may use the dash notation to specify one value range. Hence, to specify one printable character
585         between end of line sequences, the specification could be:
586      </p>  <pre class="text">
587      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>
588      <div id="rfc.figure.u.18"></div>
589      <p>Elements enclosed in parentheses are treated as a single element, whose contents are STRICTLY ORDERED. Thus,</p>  <pre class="text">
590      elem (foo / bar) blat
591</pre>  <p>matches (elem foo blat) or (elem bar blat), and</p>
592      <div id="rfc.figure.u.19"></div> <pre class="text">
593      elem foo / bar blat
594</pre>  <p>matches (elem foo) or (bar blat).</p>
595      <p id="rfc.section.3.5.p.3"> </p>
596      <dl>
597         <dt>NOTE:  </dt>
598         <dd>It is strongly advised that grouping notation be used, rather than relying on the proper reading of "bare" alternations, when
599            alternatives consist of multiple rule names or literals.
600         </dd>
601      </dl>
602      <div id="rfc.figure.u.20"></div>
603      <p>Hence, it is recommended that the following form be used:</p>  <pre class="text">
604     (elem foo) / (bar blat)
605</pre>  <p>It will avoid misinterpretation by casual readers.</p>
606      <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>
607      <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>
608      <div id="rfc.figure.u.21"></div>
609      <p>The operator "*" preceding an element indicates repetition. The full form is:</p>  <pre class="text">
610      &lt;a&gt;*&lt;b&gt;element
611</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>
612      <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;
613         3*3&lt;element&gt; allows exactly 3 and 1*2&lt;element&gt; allows one or two.
614      </p>
615      <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>
616      <div id="rfc.figure.u.22"></div>
617      <p>A rule of the form:</p>  <pre class="text">
618      &lt;n&gt;element </pre> <div id="rfc.figure.u.23"></div>
619      <p>is equivalent to</p>  <pre class="text">
620      &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
621         characters.
622      </p>
623      <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>
624      <div id="rfc.figure.u.24"></div>
625      <p>Square brackets enclose an optional element sequence:</p>  <pre class="text">
626      [foo bar] </pre> <div id="rfc.figure.u.25"></div>
627      <p>is equivalent to</p>  <pre class="text">
628      *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>
629      <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
630         with the specifications.
631      </p>
632      <h2 id="rfc.section.3.10"><a href="#rfc.section.3.10">3.10.</a>&nbsp;Operator Precedence
633      </h2>
634      <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
635         (loosest) at the bottom:
636      </p>
637      <ul class="empty">
638         <li>Strings, Names formation</li>
639         <li>Comment</li>
640         <li>Value range</li>
641         <li>Repetition</li>
642         <li>Grouping, Optional</li>
643         <li>Concatenation</li>
644         <li>Alternative</li>
645      </ul>
646      <p id="rfc.section.3.10.p.2">Use of the alternative operator, freely mixed with concatenations, can be confusing.</p>
647      <p id="rfc.section.3.10.p.3"> </p>
648      <ul class="empty">
649         <li>Again, it is recommended that the grouping operator be used to make explicit concatenation groups.</li>
650      </ul>
651      <h1 id="rfc.section.4"><a href="#rfc.section.4">4.</a>&nbsp;ABNF DEFINITION OF ABNF
652      </h1>
653      <p id="rfc.section.4.p.1"> </p>
654      <dl>
655         <dt>NOTES:</dt>
656         <dd>
657            <ol>
658               <li>This syntax requires a formatting of rules that is relatively strict. Hence, the version of a ruleset included in a specification
659                  might need preprocessing to ensure that it can be interpreted by an ABNF parser.
660               </li>
661               <li>This syntax uses the rules provided in <a href="#CORE" title="APPENDIX - CORE ABNF OF ABNF">Appendix&nbsp;B</a> (Core).
662               </li>
663            </ol>
664         </dd>
665      </dl>
666      <div id="rfc.figure.u.26"></div> <pre class="inline">
667      rulelist       =  1*( rule / (*c-wsp c-nl) )
668
669      rule           =  rulename defined-as elements c-nl
670                             ; continues if next line starts
671                             ;  with white space
672
673      rulename       =  ALPHA *(ALPHA / DIGIT / "-")
674
675      defined-as     =  *c-wsp ("=" / "=/") *c-wsp
676                             ; basic rules definition and
677                             ;  incremental alternatives
678
679      elements       =  alternation *c-wsp
680
681      c-wsp          =  WSP / (c-nl WSP)
682
683      c-nl           =  comment / CRLF
684                             ; comment or newline
685
686      comment        =  ";" *(WSP / VCHAR) CRLF
687
688      alternation    =  concatenation
689                        *(*c-wsp "/" *c-wsp concatenation)
690
691      concatenation  =  repetition *(1*c-wsp repetition)
692
693      repetition     =  [repeat] element
694
695      repeat         =  1*DIGIT / (*DIGIT "*" *DIGIT)
696
697      element        =  rulename / group / option /
698                        char-val / num-val / prose-val
699
700      group          =  "(" *c-wsp alternation *c-wsp ")"
701
702      option         =  "[" *c-wsp alternation *c-wsp "]"
703
704      char-val       =  DQUOTE *(%x20-21 / %x23-7E) DQUOTE
705                             ; quoted string of SP and VCHAR
706                             ;  without DQUOTE
707
708      num-val        =  "%" (bin-val / dec-val / hex-val)
709
710      bin-val        =  "b" 1*BIT
711                        [ 1*("." 1*BIT) / ("-" 1*BIT) ]
712                             ; series of concatenated bit values
713                             ;  or single ONEOF range
714
715      dec-val        =  "d" 1*DIGIT
716                        [ 1*("." 1*DIGIT) / ("-" 1*DIGIT) ]
717
718      hex-val        =  "x" 1*HEXDIG
719                        [ 1*("." 1*HEXDIG) / ("-" 1*HEXDIG) ]
720
721      prose-val      =  "&lt;" *(%x20-3D / %x3F-7E) "&gt;"
722                             ; bracketed string of SP and VCHAR
723                             ;  without angles
724                             ; prose description, to be used as
725                             ;  last resort
726</pre> <h1 id="rfc.section.5"><a href="#rfc.section.5">5.</a>&nbsp;SECURITY CONSIDERATIONS
727      </h1>
728      <p id="rfc.section.5.p.1">Security is truly believed to be irrelevant to this document.</p>
729      <h1 id="rfc.references"><a id="rfc.section.6" href="#rfc.section.6">6.</a> References
730      </h1>
731      <h2 id="rfc.references.1"><a href="#rfc.section.6.1" id="rfc.section.6.1">6.1.</a> Normative References
732      </h2>
733      <table> 
734         <tr>
735            <td class="reference"><b id="US-ASCII">[US-ASCII]</b></td>
736            <td class="top">American National Standards
737               Institute, “Coded Character Set -- 7-bit American Standard Code for Information Interchange”, ANSI&nbsp;X3.4, 1986.
738            </td>
739         </tr>
740      </table>
741      <h2 id="rfc.references.2"><a href="#rfc.section.6.2" id="rfc.section.6.2">6.2.</a> Informative References
742      </h2>
743      <table>     
744         <tr>
745            <td class="reference"><b id="RFC2234">[RFC2234]</b></td>
746            <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.
747            </td>
748         </tr>
749         <tr>
750            <td class="reference"><b id="RFC733">[RFC733]</b></td>
751            <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.
752            </td>
753         </tr>
754         <tr>
755            <td class="reference"><b id="RFC822">[RFC822]</b></td>
756            <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.
757            </td>
758         </tr>
759      </table>
760      <div class="avoidbreak">
761         <h1 id="rfc.authors"><a href="#rfc.authors">Authors' Addresses</a></h1>
762         <address class="vcard"><span class="vcardline"><span class="fn">Dave Crocker</span>
763               (editor)
764               <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>
765         <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>
766      </div>
767      <h1 id="rfc.section.A" class="np"><a href="#rfc.section.A">A.</a>&nbsp;ACKNOWLEDGEMENTS
768      </h1>
769      <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
770         the BNF into an augmented BNF that makes the representation smaller and easier to understand.
771      </p>
772      <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
773         specification writers, namely the description of augmented BNF. Rather than simply and blindly converting the existing text
774         into a separate document, the working group chose to give careful consideration to the deficiencies, as well as benefits,
775         of the existing specification and related specifications made available over the last 15 years, and therefore to pursue enhancement.
776         This turned the project into something rather more ambitious than was first intended. Interestingly, the result is not massively
777         different from that original, although decisions, such as removing the list notation, came as a surprise.
778      </p>
779      <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
780         Abela, Harald Alvestrand, Robert Elz, Roger Fajman, Aviva Garrett, Tom Harsch, Dan Kohn, Bill McQuillan, Keith Moore, Chris
781         Newman, Pete Resnick, and Henning Schulzrinne.
782      </p>
783      <p id="rfc.section.A.p.4">Julian Reschke warrants a special thanks for converting the Draft Standard version to XML source form.</p>
784      <h1 id="rfc.section.B"><a href="#rfc.section.B">B.</a>&nbsp;<a id="CORE" href="#CORE">APPENDIX - CORE ABNF OF ABNF</a></h1>
785      <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>
786      <h2 id="rfc.section.B.1"><a href="#rfc.section.B.1">B.1.</a>&nbsp;Core Rules
787      </h2>
788      <p id="rfc.section.B.1.p.1">Certain basic rules are in uppercase, such as SP, HTAB, CRLF, DIGIT, ALPHA, etc.</p>
789      <div id="rfc.figure.u.27"></div> <pre class="inline">
790      ALPHA          =  %x41-5A / %x61-7A   ; A-Z / a-z
791
792      BIT            =  "0" / "1"
793
794      CHAR           =  %x01-7F
795                             ; any 7-bit US-ASCII character,
796                             ;  excluding NUL
797
798      CR             =  %x0D
799                             ; carriage return
800
801      CRLF           =  CR LF
802                             ; Internet standard newline
803
804      CTL            =  %x00-1F / %x7F
805                             ; controls
806
807      DIGIT          =  %x30-39
808                             ; 0-9
809
810      DQUOTE         =  %x22
811                             ; " (Double Quote)
812
813      HEXDIG         =  DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
814
815      HTAB           =  %x09
816                             ; horizontal tab
817
818      LF             =  %x0A
819                             ; linefeed
820
821      LWSP           =  *(WSP / CRLF WSP)
822                             ; linear white space (past newline)
823
824      OCTET          =  %x00-FF
825                             ; 8 bits of data
826
827      SP             =  %x20
828
829      VCHAR          =  %x21-7E
830                             ; visible (printing) characters
831
832      WSP            =  SP / HTAB
833                             ; white space
834</pre> <h2 id="rfc.section.B.2"><a href="#rfc.section.B.2">B.2.</a>&nbsp;Common Encoding
835      </h2>
836      <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)
837         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
838         side and are sent over the network first.
839      </p>
840      <h1><a id="rfc.copyright" href="#rfc.copyright">Full Copyright Statement</a></h1>
841      <p>Copyright © The Internet Society (2005).</p>
842      <p>This document is subject to the rights, licenses and restrictions contained in BCP 78, and except as set forth therein, the
843         authors retain all their rights.
844      </p>
845      <p>This document and the information contained herein are provided on an “AS IS” basis and THE CONTRIBUTOR, THE ORGANIZATION
846         HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES,
847         EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY
848         RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
849      </p>
850      <h1><a id="rfc.ipr" href="#rfc.ipr">Intellectual Property</a></h1>
851      <p>The IETF takes no position regarding the validity or scope of any Intellectual Property Rights or other rights that might
852         be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any
853         license under such rights might or might not be available; nor does it represent that it has made any independent effort to
854         identify any such rights. Information on the procedures with respect to rights in RFC documents can be found in BCP 78 and
855         BCP 79.
856      </p>
857      <p>Copies of IPR disclosures made to the IETF Secretariat and any assurances of licenses to be made available, or the result
858         of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users
859         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>.
860      </p>
861      <p>The IETF invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary
862         rights that may cover technology that may be required to implement this standard. Please address the information to the IETF
863         at <a href="mailto:ietf-ipr@ietf.org">ietf-ipr@ietf.org</a>.
864      </p>
865      <h1>Acknowledgment</h1>
866      <p>Funding for the RFC Editor function is currently provided by the Internet Society.</p>
867   </body>
868</html>
Note: See TracBrowser for help on using the repository browser.