~/bend-docscommunity

src/decode.bend checks

raw source on the hub · import bend-toon-codec@0.1.0.0/src/decode.bend as Decode

11 imports
import Base
import ./json.bend as J
import ./split.bend as S
import ./prim.bend as P
import ./hdr.bend as H
import ./entry.bend as E
import ./dline.bend as D
import ./frame.bend as F
import ./step.bend as T
import ./expand.bend as X
import ./head.bend as Hd

Types

type DOpts source · line 17 · raw

Data

Decoder options: spaces per indent level, strict mode, and path expansion (section 13.4: unquoted dotted keys become nested objects).

Definitions

def ddefaults source · line 20 · raw

DOpts

def fold source · line 24 · raw

@+ls:List<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/dline.DL> -> @+sr:Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/frame.St> -> @+strict:Bool -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/frame.St>

Apply every line in order, stopping at the first error.

def root.value source · line 33 · raw

@+r:Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/frame.St> -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json>

def fuel source · line 43 · raw

@+r:Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/frame.St> -> Nat

The stack height: enough steps to close every frame.

def finish source · line 51 · raw

@+r:Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/frame.St> -> @+strict:Bool -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json>

Close what is still open and take the root.

def all_blank source · line 54 · raw

@+ls:List<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/dline.DL> -> Bool

def skip_blank source · line 61 · raw

@+ls:List<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/dline.DL> -> List<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/dline.DL>

def init source · line 68 · raw

@+stk:List<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/frame.Fr> -> @+root:Maybe<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json> -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/frame.St>

def object.root source · line 71 · raw

Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/frame.St>

def array.root source · line 75 · raw

@+r:Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/step.Start> -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/frame.St>

The root is an array: its header started a value or an open frame.

def run.object source · line 84 · raw

@+ls:List<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/dline.DL> -> @+strict:Bool -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json>

def run.array source · line 87 · raw

@+ls:List<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/dline.DL> -> @+r:Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/step.Start> -> @+strict:Bool -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json>

def single.pick source · line 91 · raw

@+r:Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/entry.Ent> -> @+text:String -> @+ls:List<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/dline.DL> -> @+strict:Bool -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json>

A one-line document that is no entry is a primitive.

def single.if source · line 98 · raw

@+empty:Bool -> @+text:String -> @+ls:List<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/dline.DL> -> @+strict:Bool -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json>

def single source · line 105 · raw

@+text:String -> @+ls:List<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/dline.DL> -> @+strict:Bool -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json>

def root.other source · line 109 · raw

@+one:Bool -> @+text:String -> @+ls:List<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/dline.DL> -> @+strict:Bool -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json>

Section 5 root form discovery, after the header of a root array failed.

def root.hdr source · line 116 · raw

@+r:Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/hdr.Hdr> -> @+one:Bool -> @+text:String -> @+all:List<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/dline.DL> -> @+rest:List<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/dline.DL> -> @+strict:Bool -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json>

def header.try.pick source · line 123 · raw

@+root:Bool -> @+text:String -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/hdr.Hdr>

def header.try source · line 130 · raw

@+depth:U32 -> @+text:String -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/hdr.Hdr>

def start.first source · line 133 · raw

@+l:0x12996a27cbeef5e5ba1e8cd909be0e05/src/dline.DL -> @+rest:List<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/dline.DL> -> @+strict:Bool -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json>

def start.skipped source · line 138 · raw

@+ls:List<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/dline.DL> -> @+strict:Bool -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json>

def start source · line 145 · raw

@+ls:List<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/dline.DL> -> @+strict:Bool -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json>

def run source · line 148 · raw

@+r:Result<&2, &2, String, List<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/dline.DL>> -> @+strict:Bool -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json>

def post.pick source · line 155 · raw

@+expand:Bool -> @+strict:Bool -> @+v:0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json>

def post source · line 163 · raw

@+expand:Bool -> @+strict:Bool -> @+r:Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json> -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json>

Quoted-key markers come off; with path expansion the dotted keys unfold.

def decode source · line 171 · raw

@+src:String -> @+o:DOpts -> Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json>

Decode TOON text.