An user-defined attribute name validation (#4689)
[platform/upstream/flatbuffers.git] / docs / source / Grammar.md
1 Grammar of the schema language    {#flatbuffers_grammar}
2 ==============================
3
4 schema = include*
5          ( namespace\_decl | type\_decl | enum\_decl | root\_decl |
6            file_extension_decl | file_identifier_decl |
7            attribute\_decl | rpc\_decl | object )*
8
9 include = `include` string\_constant `;`
10
11 namespace\_decl = `namespace` ident ( `.` ident )* `;`
12
13 attribute\_decl = `attribute` ident | `"`ident`"` `;`
14
15 type\_decl = ( `table` | `struct` ) ident metadata `{` field\_decl+ `}`
16
17 enum\_decl = ( `enum` ident [ `:` type ] | `union` ident )  metadata `{`
18 commasep( enumval\_decl ) `}`
19
20 root\_decl = `root_type` ident `;`
21
22 field\_decl = ident `:` type [ `=` scalar ] metadata `;`
23
24 rpc\_decl = `rpc_service` ident `{` rpc\_method+ `}`
25
26 rpc\_method = ident `(` ident `)` `:` ident metadata `;`
27
28 type = `bool` | `byte` | `ubyte` | `short` | `ushort` | `int` | `uint` |
29 `float` | `long` | `ulong` | `double` |
30 `int8` | `uint8` | `int16` | `uint16` | `int32` | `uint32`| `int64` | `uint64` |
31 `float32` | `float64` |
32 `string` | `[` type `]` | ident
33
34 enumval\_decl = ident [ `=` integer\_constant ]
35
36 metadata = [ `(` commasep( ident [ `:` single\_value ] ) `)` ]
37
38 scalar = integer\_constant | float\_constant
39
40 object = { commasep( ident `:` value ) }
41
42 single\_value = scalar | string\_constant
43
44 value = single\_value | object | `[` commasep( value ) `]`
45
46 commasep(x) = [ x ( `,` x )\* ]
47
48 file_extension_decl = `file_extension` string\_constant `;`
49
50 file_identifier_decl = `file_identifier` string\_constant `;`
51
52 integer\_constant = `-?[0-9]+` | `true` | `false`
53
54 float\_constant = `-?[0-9]+.[0-9]+((e|E)(+|-)?[0-9]+)?`
55
56 string\_constant = `\".*?\"`
57
58 ident = `[a-zA-Z_][a-zA-Z0-9_]*`
59