第9頁
--------------------------------------------------------------------------------------------------------
3.2. HEADER FIELD DEFINITIONS
These rules show a field meta-syntax, without regard for the
particular type or internal syntax. Their purpose is to permit
detection of fields; also, they present to higher-level parsers
an image of each field as fitting on one line.
field = field-name ":" [ field-body ] CRLF
field-name = 1*<any CHAR, excluding CTLs, SPACE, and ":">
field-body = field-body-contents
[CRLF LWSP-char field-body]
field-body-contents =
<the ASCII characters making up the field-body, as
defined in the following sections, and consisting
of combinations of atom, quoted-string, and
specials tokens, or else consisting of texts>
--------------------------------------------------------------------------------------------------------
3.2. 消息頭域定義
這些規則是消息頭域的元語法定義, 它不是爲了定義特殊的類型或者某個內部語法
(是通用的定義), 此語法定義的目的是爲了在一行裏方便的找到消息頭的域, 並且把消息
的各部分傳遞給更高級的解析器.
域 = 域名 ":" [ 域主體 ] 回車換行
域名 = 1*<任意字符, 除了 控制字符, 空格, 和 ":">
域主體 = 域內容
[回車換行 分割符 域主體]
域內容 =
<ASCII字符組成了域主體,就如下面章節的定義,
由詞,被引串,特殊字符和其他的文本聯合組成域內容>
--------------------------------------------------------------------------------------------------------
第10頁
--------------------------------------------------------------------------------------------------------
3.3. LEXICAL TOKENS
The following rules are used to define an underlying lexical
analyzer, which feeds tokens to higher level parsers. See the
ANSI references, in the Bibliography.
; ( Octal, Decimal.)
CHAR = <any ASCII character> ; ( 0-177, 0.-127.)
ALPHA = <any ASCII alphabetic character>
; (101-132, 65.- 90.)
; (141-172, 97.-122.)
DIGIT = <any ASCII decimal digit> ; ( 60- 71, 48.- 57.)
CTL = <any ASCII control ; ( 0- 37, 0.- 31.)
character and DEL> ; ( 177, 127.)
CR = <ASCII CR, carriage return> ; ( 15, 13.)
LF = <ASCII LF, linefeed> ; ( 12, 10.)
SPACE = <ASCII SP, space> ; ( 40, 32.)
HTAB = <ASCII HT, horizontal-tab> ; ( 11, 9.)
<"> = <ASCII quote mark> ; ( 42, 34.)
CRLF = CR LF
LWSP-char = SPACE / HTAB ; semantics = SPACE
linear-white-space = 1*([CRLF] LWSP-char) ; semantics = SPACE
; CRLF => folding
specials = "(" / ")" / "<" / ">" / "@" ; Must be in quoted-
/ "," / ";" / ":" / "/" / <"> ; string, to use
/ "." / "[" / "]" ; within a word.
delimiters = specials / linear-white-space / comment
text = <any CHAR, including bare ; => atoms, specials,
CR & bare LF, but NOT ; comments and
including CRLF> ; quoted-strings are
; NOT recognized.
atom = 1*<any CHAR except specials, SPACE and CTLs>
quoted-string = <"> *(qtext/quoted-pair) <">; Regular qtext or
; quoted chars.
qtext = <any CHAR excepting <">, ; => may be folded
"/" & CR, and including
linear-white-space>
domain-literal = "[" *(dtext / quoted-pair) "]"
--------------------------------------------------------------------------------------------------------
3.3. 詞定義
下面的規則用來定義基本的詞法分析規則,
本規則是爲了把詞分析出來送到更高級的解析器,參看參考數目裏的ANSI引用
; ( 八進制,十進制 )
字符 = <任意 ASCII 字符> ; ( 0-177, 0.-127.)
字母 = <任意 ASCII 字母> ; (101-132, 65.- 90.)
; (141-172, 97.-122.)
數字 = <任意 ASCII 十進制數字> ; ( 60- 71, 48.- 57.)
控制字符 = <任意 ASCII 控制字符 ; ( 0- 37, 0.- 31.)
和刪除字符DEL> ; ( 177, 127.)
回車 = <ASCII CR, 回車> ; ( 15, 13.)
換行 = <ASCII LF, 換行> ; ( 12, 10.)
空格 = <ASCII SP, 空格> ; ( 40, 32.)
製表符 = <ASCII HT, 製表符> ; ( 11, 9.)
<"> = <ASCII 引號> ; ( 42, 34.)
回車換行 = 回車 換行
間隔符 = 空格 / 製表符 ; 語義上,可以把間隔符看成空格
折行符 = 1*([回車換行] 間隔符) ; 語義上,可以把間隔符看成空格
; 回車換行 => 折行
特殊字符 = "(" / ")" / "<" / ">" / "@" ; 爲了在一個詞裏使用,必須用引號
/ "," / ";" / ":" / "/" / <"> ; 引起來
/ "." / "[" / "]" ;
分隔符 = 特殊字符 / 折行符 / 註釋
文本 = <任意字符, 包括單獨的回車, ; => 詞, 特殊字符,
單獨的換行,但是不能包括 ; 註釋和被引串
回車換行> ; 不是文本
;
詞 = 1*<任意字符 除了特殊字符,空格,控制字符>
被引串 = <"> *(被引文本/轉義字符) <"> ; 通常的被引文本或者
; 被引字符
被引文本 = <任意字符,除了<">,"/", ; => 可能會折行
回車, 還包含折行符>
域名 = "[" *(域名文本 / 轉義字符) "]"
--------------------------------------------------------------------------------------------------------