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 |
|
2014-11-18 01:27:26 +00:00
|
|
|
attribute\_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 )* `;`
|
|
|
|
|
2014-11-18 01:27:26 +00:00
|
|
|
attribute\_decl = `attribute` string\_constant `;`
|
|
|
|
|
2014-01-28 00:52:49 +00:00
|
|
|
type\_decl = ( `table` | `struct` ) ident metadata `{` field\_decl+ `}`
|
|
|
|
|
|
|
|
enum\_decl = ( `enum` | `union` ) ident [ `:` type ] metadata `{` commasep(
|
|
|
|
enumval\_decl ) `}`
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
type = `bool` | `byte` | `ubyte` | `short` | `ushort` | `int` | `uint` |
|
|
|
|
`float` | `long` | `ulong` | `double`
|
|
|
|
| `string` | `[` type `]` | ident
|
|
|
|
|
|
|
|
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 `;`
|
|
|
|
|
2015-07-31 19:26:23 +00:00
|
|
|
integer\_constant = -?[0-9]+ | `true` | `false`
|
|
|
|
|
|
|
|
float\_constant = -?[0-9]+.[0-9]+((e|E)(+|-)?[0-9]+)?
|