Skip to content

Latest commit

 

History

History
113 lines (75 loc) · 1.58 KB

schema_language.md

File metadata and controls

113 lines (75 loc) · 1.58 KB

Molecule Schema Language

Molecule data are strongly-typed and not self-describing.

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:

  • The Molecule serialization don't care about the order of user data in which a sequence of bytes is stored in a computer's memory.

    You have to pack them in your own way and unpack them by yourself.

Composite Types
  • array

An array has an item type and an unsigned integer.

array ArrayName [ItemType; N];  // N is an unsigned integer
  • struct

A struct has a set of named and typed fields.

struct StructName {
    field_name_1: FieldType1,
    field_name_2: FieldType2,
    field_name_3: FieldType3,
}
  • vector

A vector has only an item type.

vector VectorName <ItemType>;
  • table

A table has a set of named and typed fields, same as struct.

table TableName {
    field_name_1: FieldType1,
    field_name_2: FieldType2,
    field_name_3: FieldType3,
}
  • option

An option has only an item type.

option OptionName (ItemType);
  • union

A union has a set of item types.

union UnionName {
    ItemType1,
    ItemType2,
    ItemType3,
}

Keywords

  • import

Import types from other schema files.

import ../library/common_types;