RFC 822 中文版 MIME解析基础(6)(第9-10页)

第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*

     field-body  =  field-body-contents
                    [CRLF LWSP-char field-body]

     field-body-contents =
                                       defined in the following sections, and consisting
                    of combinations of atom, quoted-string, and
                    specials tokens, or else consisting of texts>

--------------------------------------------------------------------------------------------------------

     3.2.  消息头域定义

          这些规则是消息头域的元语法定义, 它不是为了定义特殊的类型或者某个内部语法
     (是通用的定义), 此语法定义的目的是为了在一行里方便的找到消息头的域, 并且把消息
     的各部分传递给更高级的解析器.

     域       =  域名 ":" [ 域主体 ] 回车换行

     域名  =  1*<任意字符, 除了 控制字符, 空格, 和 ":">

     域主体  =  域内容
                    [回车换行 分割符 域主体]

     域内容 =
                                      由词,被引串,特殊字符和其他的文本联合组成域内容>

--------------------------------------------------------------------------------------------------------

第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        =          ; (  0-177,  0.-127.)
     ALPHA       = 
                                                 ; (101-132, 65.- 90.)
                                                 ; (141-172, 97.-122.)
     DIGIT       =      ; ( 60- 71, 48.- 57.)
     CTL         =                       character and DEL>          ; (    177,     127.)
     CR          =    ; (     15,      13.)
     LF          =           ; (     12,      10.)
     SPACE       =              ; (     40,      32.)
     HTAB        =     ; (     11,       9.)
     <">         =             ; (     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        =  atoms, specials,
                     CR & bare LF, but NOT       ;  comments and
                     including CRLF>             ;  quoted-strings are
                                                 ;  NOT recognized.

     atom        =  1*

     quoted-string = <"> *(qtext/quoted-pair) <">; Regular qtext or
                                                 ;   quoted chars.

     qtext       =  ,     ; => 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.)
     回车        =               ; (     15,      13.)
     换行        =               ; (     12,      10.)
     空格        =               ; (     40,      32.)
     制表符     =             ; (     11,       9.)
     <">         =                   ; (     42,      34.)
     回车换行    =  回车 换行

     间隔符      =  空格 / 制表符                ; 语义上,可以把间隔符看成空格

     折行符      =  1*([回车换行] 间隔符)        ; 语义上,可以把间隔符看成空格
                                                 ; 回车换行 => 折行

     特殊字符    =  "(" / ")" / "<" / ">" / "@"  ; 为了在一个词里使用,必须用引号
                 /  "," / ";" / ":" / "/" / <">  ;  引起来
                 /  "." / "[" / "]"              ; 

     分隔符      =  特殊字符 / 折行符 / 注释

     文本        =  <任意字符, 包括单独的回车,    ; => 词, 特殊字符,
                     单独的换行,但是不能包括      ;  注释和被引串
                     回车换行>                     ;  不是文本
                                                   ; 

     词          =  1*<任意字符 除了特殊字符,空格,控制字符>

     被引串      = <"> *(被引文本/转义字符) <">    ; 通常的被引文本或者
                                                   ;   被引字符

     被引文本     =  <任意字符,除了<">,"/",      ; => 可能会折行
                     回车, 还包含折行符>

     域名         =  "[" *(域名文本 / 转义字符) "]"

 

--------------------------------------------------------------------------------------------------------

你可能感兴趣的:(RFC 822 中文版 MIME解析基础(6)(第9-10页))