2015-12-04 04:30:54 +00:00
|
|
|
Grammar of the schema language {#flatbuffers_grammar}
|
|
|
|
==============================
|
2014-01-28 00:52:49 +00:00
|
|
|
|
2014-08-19 21:20:05 +00:00
|
|
|
schema = include*
|
2014-11-18 01:27:26 +00:00
|
|
|
( namespace\_decl | type\_decl | enum\_decl | root\_decl |
|
2015-07-09 00:49:01 +00:00
|
|
|
file_extension_decl | file_identifier_decl |
|
2017-08-14 18:58:25 +00:00
|
|
|
attribute\_decl | rpc\_decl | object )*
|
2014-08-19 21:20:05 +00:00
|
|
|
|
|
|
|
include = `include` string\_constant `;`
|
2014-01-28 00:52:49 +00:00
|
|
|
|
|
|
|
namespace\_decl = `namespace` ident ( `.` ident )* `;`
|
|
|
|
|
2018-04-06 16:07:59 +00:00
|
|
|
attribute\_decl = `attribute` ident | `"`ident`"` `;`
|
2014-11-18 01:27:26 +00:00
|
|
|
|
2014-01-28 00:52:49 +00:00
|
|
|
type\_decl = ( `table` | `struct` ) ident metadata `{` field\_decl+ `}`
|
|
|
|
|
2017-08-14 19:18:06 +00:00
|
|
|
enum\_decl = ( `enum` ident [ `:` type ] | `union` ident ) metadata `{`
|
|
|
|
commasep( enumval\_decl ) `}`
|
2014-01-28 00:52:49 +00:00
|
|
|
|
|
|
|
root\_decl = `root_type` ident `;`
|
|
|
|
|
2015-07-10 23:39:47 +00:00
|
|
|
field\_decl = ident `:` type [ `=` scalar ] metadata `;`
|
2014-01-28 00:52:49 +00:00
|
|
|
|
2017-08-14 18:58:25 +00:00
|
|
|
rpc\_decl = `rpc_service` ident `{` rpc\_method+ `}`
|
|
|
|
|
|
|
|
rpc\_method = ident `(` ident `)` `:` ident metadata `;`
|
|
|
|
|
2014-01-28 00:52:49 +00:00
|
|
|
type = `bool` | `byte` | `ubyte` | `short` | `ushort` | `int` | `uint` |
|
2017-08-14 18:58:25 +00:00
|
|
|
`float` | `long` | `ulong` | `double` |
|
|
|
|
`int8` | `uint8` | `int16` | `uint16` | `int32` | `uint32`| `int64` | `uint64` |
|
|
|
|
`float32` | `float64` |
|
|
|
|
`string` | `[` type `]` | ident
|
2014-01-28 00:52:49 +00:00
|
|
|
|
|
|
|
enumval\_decl = ident [ `=` integer\_constant ]
|
|
|
|
|
2015-07-31 19:26:23 +00:00
|
|
|
metadata = [ `(` commasep( ident [ `:` single\_value ] ) `)` ]
|
2014-01-28 00:52:49 +00:00
|
|
|
|
2015-07-31 19:26:23 +00:00
|
|
|
scalar = integer\_constant | float\_constant
|
2014-01-28 00:52:49 +00:00
|
|
|
|
|
|
|
object = { commasep( ident `:` value ) }
|
|
|
|
|
2015-07-31 19:26:23 +00:00
|
|
|
single\_value = scalar | string\_constant
|
|
|
|
|
|
|
|
value = single\_value | object | `[` commasep( value ) `]`
|
2014-01-28 00:52:49 +00:00
|
|
|
|
|
|
|
commasep(x) = [ x ( `,` x )\* ]
|
2015-07-09 00:49:01 +00:00
|
|
|
|
|
|
|
file_extension_decl = `file_extension` string\_constant `;`
|
|
|
|
|
|
|
|
file_identifier_decl = `file_identifier` string\_constant `;`
|
|
|
|
|
2017-08-14 19:18:06 +00:00
|
|
|
integer\_constant = `-?[0-9]+` | `true` | `false`
|
|
|
|
|
|
|
|
float\_constant = `-?[0-9]+.[0-9]+((e|E)(+|-)?[0-9]+)?`
|
|
|
|
|
|
|
|
string\_constant = `\".*?\"`
|
|
|
|
|
|
|
|
ident = `[a-zA-Z_][a-zA-Z0-9_]*`
|
2015-07-31 19:26:23 +00:00
|
|
|
|