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

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

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

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