Skip to content

Instantly share code, notes, and snippets.

@Conaclos
Last active April 26, 2022 18:29
Show Gist options
  • Save Conaclos/00fb1bcc2096892ab78f721a4b634d8d to your computer and use it in GitHub Desktop.
Save Conaclos/00fb1bcc2096892ab78f721a4b634d8d to your computer and use it in GitHub Desktop.

Revisions

  1. Conaclos revised this gist Apr 26, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion json.zig
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ type Element union {
    | False
    | True
    | Null
    | uint
    | f64
    | str
    | Object
    | Array
  2. Conaclos revised this gist Apr 26, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions json.zig
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,8 @@ type Element union {
    | False
    | True
    | Null
    | uint
    | str
    | Object
    | Array
    }
  3. Conaclos created this gist Apr 26, 2022.
    59 changes: 59 additions & 0 deletions bare.zig
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,59 @@
    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>
    18 changes: 18 additions & 0 deletions json.zig
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    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
    | Object
    | Array
    }

    type Document list<Element>