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

Last change on this file since 50 was 17, checked in by fielding@…, 12 years ago

generated files

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