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

Last change on this file since 227 was 227, checked in by julian.reschke@…, 13 years ago

Update to latest version of rfc2629.xslt (matching xml2rfc 1.33).

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