Skip to content

Instantly share code, notes, and snippets.

@Conaclos
Last active April 26, 2022 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Conaclos/00fb1bcc2096892ab78f721a4b634d8d to your computer and use it in GitHub Desktop.
Save Conaclos/00fb1bcc2096892ab78f721a4b634d8d to your computer and use it in GitHub Desktop.
Examples of recursive type without support for them
type TypeId uint
type BoolType void
type I8Type void
type I16Type void
type I32Type void
type I64Type void
type IntType void
type StrType void
type U8Type void
type U16Type void
type U32Type void
type U64Type void
type UintType void
type EnumMember struct {
name: str
tag: uint
}
type EnumType list<EnumMember>
type ListType struct {
valType: TypeId
# 0 for variable-length
length: uint
}
type MapType struct {
keyType: TypeId
valType: TypeId
}
type StructField struct {
name: str
type: TypeId
}
type TypeAlias str
type UnionMember struct {
type: TypeId
tag: uint
}
type UnionType list<UnionMember>
type Type union {
| BoolType
| I8Type | I16Type | I32Type | I64Type | IntType
| StrType
| U8Type | U16Type | U32Type | U64Type | UintType
| EnumType
| ListType | MapType
| TypeAlias
| StructType | UnionType
}
type Schema list<Type>
type ElementId uint
type False void
type True void
type Null void
type Object map<str><ElementId>
type Array list<ElementId>
type Element union {
| False
| True
| Null
| f64
| str
| Object
| Array
}
type Document list<Element>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment