Molecule Schema Language
Grammar
Language Reference
Comments
Line comments:
// This is a line comment
Block comments:
/* This
is
a
block
comment
*/
Built-in Types
Primitive Type
There is only one built-in primitive type: byte.
note
Molecule serialization does not consider the order of user data where a sequence of bytes is stored in memory. You must pack and unpack the data manually.
Composite Types
arrayAn array consists of an item type and an unsigned integer.
array ArrayName [ItemType; N]; // N is an unsigned integer
structA struct consists of a set of named and typed fields.
struct StructName {
field_name_1: FieldType1,
field_name_2: FieldType2,
field_name_3: FieldType3,
}
vectorA vector contains only one item type.
vector VectorName <ItemType>;
tableA table consists of a set of named and typed fields, same asstruct.
table TableName {
field_name_1: FieldType1,
field_name_2: FieldType2,
field_name_3: FieldType3,
}
optionAn option contains only an item type.
option OptionName (ItemType);
unionAunioncontains a set of item types.
union UnionName {
ItemType1,
ItemType2,
ItemType3,
}
Keywords
importImport types from other schema files.
import ../library/common_types;