• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1## EBNF
2
3```ebnf
4schema = include* ( namespace_decl | type_decl | enum_decl | root_decl |
5           file_extension_decl | file_identifier_decl |
6           attribute_decl | rpc_decl | object )*
7
8include = `include` string_constant `;`
9
10namespace_decl = `namespace` ident ( `.` ident )* `;`
11
12attribute_decl = `attribute` ident | `"` ident `"` `;`
13
14type_decl = ( `table` | `struct` ) ident metadata `{` field_decl+ `}`
15
16enum_decl = ( `enum` ident `:` type | `union` ident )  metadata `{`
17commasep( enumval_decl ) `}`
18
19root_decl = `root_type` ident `;`
20
21field_decl = ident `:` type [ `=` scalar ] metadata `;`
22
23rpc_decl = `rpc_service` ident `{` rpc_method+ `}`
24
25rpc_method = ident `(` ident `)` `:` ident metadata `;`
26
27type = `bool` | `byte` | `ubyte` | `short` | `ushort` | `int` | `uint` |
28       `float` | `long` | `ulong` | `double` | `int8` | `uint8` | `int16` |
29       `uint16` | `int32` | `uint32`| `int64` | `uint64` | `float32` |
30       `float64` | `string` | `[` type `]` | ident
31
32enumval_decl = ident [ `=` integer_constant ] metadata
33
34metadata = [ `(` commasep( ident [ `:` single_value ] ) `)` ]
35
36scalar = boolean_constant | integer_constant | float_constant
37
38object = `{` commasep( ident `:` value ) `}`
39
40single_value = scalar | string_constant
41
42value = single_value | object | `[` commasep( value ) `]`
43
44commasep(x) = [ x ( `,` x )\* ]
45
46file_extension_decl = `file_extension` string_constant `;`
47
48file_identifier_decl = `file_identifier` string_constant `;`
49
50string_constant = `\".*?\"`
51
52ident = `[a-zA-Z_][a-zA-Z0-9_]*`
53
54`[:digit:]` = `[0-9]`
55
56`[:xdigit:]` = `[0-9a-fA-F]`
57
58dec_integer_constant = `[-+]?[:digit:]+`
59
60hex_integer_constant = `[-+]?0[xX][:xdigit:]+`
61
62integer_constant = dec_integer_constant | hex_integer_constant
63
64dec_float_constant = `[-+]?(([.][:digit:]+)|([:digit:]+[.][:digit:]*)|([:digit:]+))([eE][-+]?[:digit:]+)?`
65
66hex_float_constant = `[-+]?0[xX](([.][:xdigit:]+)|([:xdigit:]+[.][:xdigit:]*)|([:xdigit:]+))([pP][-+]?[:digit:]+)`
67
68special_float_constant = `[-+]?(nan|inf|infinity)`
69
70float_constant = dec_float_constant | hex_float_constant | special_float_constant
71
72boolean_constant = `true` | `false`
73```
74