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