形式化定义

ABNF:

  1. serialize-data = integer / long / double / nan / positive-infinity / negative-infinity /
  2. true / false / null / empty / utf8-char / bytes / string / datetime / guid /
  3. list / map / object / ref
  4.  
  5. UINT = "0" / %x31-39 *DIGIT
  6.  
  7. SINT = *("+" / "-") UINT
  8.  
  9. integer = DIGIT / %x69 SINT ";"
  10.  
  11. long = %x6C SINT ";"
  12.  
  13. double = %x64 SINT ["." 1*DIGIT ["E" SINT]] ";"
  14.  
  15. nan = %x4E
  16.  
  17. positive-infinity = %x49 "+"
  18.  
  19. negative-infinity = %x49 "-"
  20.  
  21. true = %x74
  22.  
  23. false = %x66
  24.  
  25. null = %x6E
  26.  
  27. empty = %x65
  28.  
  29. one-byte-utf8 = %x00-7F
  30.  
  31. two-byte-utf8 = %xC0-DF %x80-BF
  32.  
  33. three-byte-utf8 = %xE0-EF %x80-BF %x80-BF
  34.  
  35. four-byte-utf8 = %xF0-F7 %x80-BF %x80-BF %x80-BF
  36.  
  37. utf8 = one-byte-utf8 / two-byte-utf8 / three-byte-utf8 / four-byte-utf8
  38.  
  39. utf8-char = %x75 (one-byte-utf8 / two-byte-utf8 / three-byte-utf8)
  40.  
  41. bytes-length = UINT
  42.  
  43. bytes = %x62 DQUOTE DQUOTE / %x62 bytes-length DQUOTE <bytes-length>OCTET DQUOTE
  44.  
  45. string-length = UINT
  46.  
  47. string = %x73 DQUOTE DQUOTE / %x73 string-length DQUOTE <string-length>utf8 DQUOTE
  48.  
  49. year = 4DIGIT
  50.  
  51. month = "0" %x31-39 / "1" %x30-32
  52.  
  53. day = "0" %x31-39 / %x31-32 %x30-39 / "3" %x30-31
  54.  
  55. local = ";"
  56.  
  57. utc = %x5A
  58.  
  59. timezone = local / utc
  60.  
  61. date = %x44 year month day timezone
  62.  
  63. hour = %x30-31 DIGIT / "2" %x30-x33
  64.  
  65. minute = %x30-35 DIGIT
  66.  
  67. second = %x30-35 DIGIT
  68.  
  69. millisecond = 3DIGIT
  70.  
  71. microsecond = 6DIGIT
  72.  
  73. nanosecond = 9DIGIT
  74.  
  75. time = %x54 hour minute second ["." (millisecond / microsecond / nanosecond)] timezone
  76.  
  77. datetime = date / time / %x44 year month day time
  78.  
  79. guid = %x67 "{" 8HEXDIG "-" 4HEXDIG "-" 4HEXDIG "-" 4HEXDIG "-" 12HEXDIG "}"
  80.  
  81. element = serialize-data
  82.  
  83. list-count = UINT
  84.  
  85. list = %x61 "{" "}" / %x61 list-count "{" <list-count>element "}"
  86.  
  87. key = serialize-data
  88.  
  89. value = serialize-data
  90.  
  91. keyvalue = key value
  92.  
  93. map-count = UINT
  94.  
  95. map = %x6D "{" "}" / %x6D map-count "{" <map-count>keyvalue "}"
  96.  
  97. classname-length = UINT
  98.  
  99. classname = classname-length DQUOTE <classname-length>utf8 DQUOTE
  100.  
  101. fieldname = string
  102.  
  103. field-count = UINT
  104.  
  105. class = %x63 classname field-count "{" <field-count>fieldname "}"
  106.  
  107. class-ref = UINT
  108.  
  109. fieldvalue = serialize-data
  110.  
  111. object = [class] %x6F class-ref "{" <field-count>fieldvalue "}"
  112.  
  113. ref = %x72 UINT ";"
  114.  
  115. string-list = %x61 list-count "{" <list-count>string "}"
  116.  
  117. end = %x7A
  118.  
  119. function-list = %x46 string-list end
  120.  
  121. function-name = string
  122.  
  123. function-arguments = list
  124.  
  125. passing-by-ref = true
  126.  
  127. rpc-call = 1*(%x43 function-name [function-arguments [passing-by-ref]]) end
  128.  
  129. rpc-result = %x52 serialize-data
  130.  
  131. rpc-arguments = %x41 list
  132.  
  133. rpc-error = %x45 string
  134.  
  135. rpc-reply = rpc-error end / 1*(rpc-result [rpc-arguments]) [rpc-error] end
  136.