Skip to main content

Appendix A. Collected Grammar

This appendix contains the complete BNF grammar for the media type syntax rules defined in RFC 2046.

Media Type Syntax

media-type = type "/" subtype *( ";" parameter )

type = discrete-type / composite-type

discrete-type = "text" / "image" / "audio" / "video" /
"application" / extension-token

composite-type = "message" / "multipart" / extension-token

extension-token = ietf-token / x-token

x-token = <The two characters "X-" or "x-" followed, with
no intervening white space, by any token>

ietf-token = <An extension token defined by a
standards-track RFC and registered
with IANA.>

subtype = extension-token / iana-token

iana-token = <A publicly-defined extension token>

parameter = attribute "=" value

attribute = token

value = token / quoted-string

Multipart Syntax

boundary := 0*69<bchars> bcharsnospace

bchars := bcharsnospace / " "

bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" /
"+" / "_" / "," / "-" / "." /
"/" / ":" / "=" / "?"

dash-boundary := "--" boundary

close-delimiter := delimiter "--"

delimiter := CRLF dash-boundary

discard-text := *(*text CRLF)

preamble := discard-text

epilogue := discard-text

body-part := MIME-part-headers [CRLF *OCTET]

encapsulation := delimiter
body-part

multipart-body := [preamble]
dash-boundary CRLF
body-part
*encapsulation
close-delimiter
[epilogue]

Notes:

  • This grammar is used in conjunction with RFC 2045 and RFC 822
  • Complete syntax requires reference to all related RFCs
  • IANA maintains a list of registered media types