Schemas now support include files.

Bug: 15521443
Change-Id: I2e1ef97e7225a1a0ecf2ca65e31d49d443003747
Tested: on Linux.
This commit is contained in:
Wouter van Oortmerssen
2014-08-19 14:20:05 -07:00
parent 293a8110c4
commit be894f09df
13 changed files with 136 additions and 52 deletions

View File

@@ -1,6 +1,9 @@
# Formal Grammar of the schema language
schema = namespace\_decl | type\_decl | enum\_decl | root\_decl | object
schema = include*
( namespace\_decl | type\_decl | enum\_decl | root\_decl | object )*
include = `include` string\_constant `;`
namespace\_decl = `namespace` ident ( `.` ident )* `;`

View File

@@ -141,6 +141,20 @@ These will generate the corresponding namespace in C++ for all helper
code, and packages in Java. You can use `.` to specify nested namespaces /
packages.
### Includes
You can include other schemas files in your current one, e.g.:
include "mydefinitions.fbs"
This makes it easier to refer to types defined elsewhere. `include`
automatically ensures each file is parsed just once, even when referred to
more than once.
When using the `flatc` compiler to generate code for schema definitions,
only definitions in the current file will be generated, not those from the
included files (those you still generate separately).
### Root type
This declares what you consider to be the root table (or struct) of the