r1327@opsdev009 (orig r70766): mcslee | 2007-11-19 17:39:25 -0800
[amiethrift.git] / thrift.bnf
blob60e757d746aa77d5c8b77ffc0428a3197147a52e
1 Thrift Protocol Structure
3 Mark Slee (mcslee@facebook.com)
5 Last Modified: 2007-Jun-29
7 Thrift is distributed under the Thrift open source software license.
8 Please see the included LICENSE file.
10 --------------------------------------------------------------------
12 This document describes the structure of the Thrift protocol
13 without specifying the encoding. Thus, the order of elements
14 could in some cases be rearranged depending upon the TProtocol
15 implementation, but this document specifies the minimum required
16 structure. There are some "dumb" terminals like STRING and INT
17 that take the place of an actual encoding specification.
19 They key point to notice is that ALL messages are just one wrapped
20 <struct>. Depending upon the message type, the <struct> can be
21 interpreted as the argument list to a function, the return value
22 of a function, or an exception.
24 --------------------------------------------------------------------
26 <message> ::= <message-begin> <struct> <message-end>
28 <message-begin> ::= <method-name> <message-type> <message-seqid>
30 <method-name> ::= STRING
32 <message-type> ::= T_CALL | T_REPLY | T_EXCEPTION
34 <message-seqid> ::= I32
36 <struct> ::= <struct-begin> <field>* <field-stop> <struct-end>
38 <struct-begin> ::= <struct-name>
40 <struct-name> ::= STRING
42 <field-stop> ::= T_STOP
44 <field> ::= <field-begin> <field-data> <field-end>
46 <field-begin> ::= <field-name> <field-type> <field-id>
48 <field-name> ::= STRING
50 <field-type> ::= T_BOOL | T_BYTE | T_I8 | T_I16 | T_I32 | T_I64 | T_DOUBLE
51 | T_STRING | T_STRUCT | T_MAP | T_SET | T_LIST
53 <field-id> ::= I16
55 <field-data> ::= I8 | I16 | I32 | I64 | DOUBLE | STRING |
56 <struct> | <map> | <list> | <set>
58 <map> ::= <map-begin> <field-datum>* <map-end>
60 <map-begin> ::= <map-key-type> <map-value-type> <map-size>
62 <map-key-type> ::= <field-type>
64 <map-value-type> ::= <field-type>
66 <map-size> ::= I32
68 <list> ::= <list-begin> <field-data>* <list-end>
70 <list-begin> ::= <list-elem-type> <list-size>
72 <list-elem-type> ::= <field-type>
74 <list-size> ::= I32
76 <set> ::= <set-begin> <field-data>* <set-end>
78 <set-begin> ::= <set-elem-type> <set-size>
80 <set-elem-type> ::= <field-type>
82 <set-size> ::= I32