Home | History | Annotate | Download | only in source
      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 | object )*
      8 
      9 include = `include` string\_constant `;`
     10 
     11 namespace\_decl = `namespace` ident ( `.` ident )* `;`
     12 
     13 attribute\_decl = `attribute` string\_constant `;`
     14 
     15 type\_decl = ( `table` | `struct` ) ident metadata `{` field\_decl+ `}`
     16 
     17 enum\_decl = ( `enum` | `union` ) ident [ `:` type ] metadata `{` commasep(
     18 enumval\_decl ) `}`
     19 
     20 root\_decl = `root_type` ident `;`
     21 
     22 field\_decl = ident `:` type [ `=` scalar ] metadata `;`
     23 
     24 type = `bool` | `byte` | `ubyte` | `short` | `ushort` | `int` | `uint` |
     25 `float` | `long` | `ulong` | `double`
     26  | `string` | `[` type `]` | ident
     27 
     28 enumval\_decl = ident [ `=` integer\_constant ]
     29 
     30 metadata = [ `(` commasep( ident [ `:` single\_value ] ) `)` ]
     31 
     32 scalar = integer\_constant | float\_constant
     33 
     34 object = { commasep( ident `:` value ) }
     35 
     36 single\_value = scalar | string\_constant
     37 
     38 value = single\_value | object | `[` commasep( value ) `]`
     39 
     40 commasep(x) = [ x ( `,` x )\* ]
     41 
     42 file_extension_decl = `file_extension` string\_constant `;`
     43 
     44 file_identifier_decl = `file_identifier` string\_constant `;`
     45 
     46 integer\_constant = -?[0-9]+ | `true` | `false`
     47 
     48 float\_constant = -?[0-9]+.[0-9]+((e|E)(+|-)?[0-9]+)?
     49