跳到主要内容

附录 A:BNF 规范

这里给出一个相当详细的“BNF”定义,描述计算机邮件“邮箱”(mailbox)的允许形式,它由“local-part”(本地部分)和“domain”(域)两部分组成(以 at 符号分隔)。显然,域也可以单独用于其他面向网络的应用。

<mailbox> ::= <local-part> "@" <domain>

<local-part> ::= <string> | <quoted-string>

<string> ::= <char> | <char> <string>

<quoted-string> ::= """ <qtext> """

<qtext> ::= "\" <x> | "\" <x> <qtext> | <q> | <q> <qtext>

<char> ::= <c> | "\" <x>

<domain> ::= <naming-domain> | <naming-domain> "." <domain>

<naming-domain> ::= <simple-name> | <address>

<simple-name> ::= <a> <ldh-str> <let-dig>

<ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>

<let-dig> ::= <a> | <d>

<let-dig-hyp> ::= <a> | <d> | "-"

<address> :: = "#" <number> | "[" <dotnum> "]"

<number> ::= <d> | <d> <number>

<dotnum> ::= <snum> "." <snum> "." <snum> "." <snum>

<snum> ::= one, two, or three digits representing a decimal integer
value in the range 0 through 255

<a> ::= any one of the 52 alphabetic characters A through Z in upper
case and a through z in lower case

<c> ::= any one of the 128 ASCII characters except <s> or <SP>

<d> ::= any one of the ten digits 0 through 9

<q> ::= any one of the 128 ASCII characters except CR, LF, quote ("),
or backslash (\)

<x> ::= any one of the 128 ASCII characters (no exceptions)

<s> ::= "<", ">", "(", ")", "[", "]", "\", ".", ",", ";", ":", "@",
""", and the control characters (ASCII codes 0 through 31 inclusive
and 127)

请注意,反斜杠“\”是一个引用字符,用于指示下一个字符按字面使用(而非其通常的解释)。例如,“Joe\,Smith”可用来表示一个由九个字符组成的单一用户字段,其中逗号是该字段的第四个字符。

构成域的简单名称可以同时包含大写和小写字母(以及数字和连字符),但这些名称不区分大小写。

主机通常以名称为人所知。有时主机不为转换函数所知,通信因而受阻。为绕过这一障碍,主机“名称”还允许使用两种形式的地址。一种形式是以井号“#”为前缀的十进制整数。另一种形式称为“点分十进制”(dotted decimal),由四个以点分隔并用方括号括起的小十进制整数组成,例如“[123.255.37.2]”,表示由四个 8 位字段构成的 32 位 ARPA 互联网地址。(当然,这些数字地址形式是互联网特有的,如果在其他传输系统中出现此问题,可能需要提供其他形式。)