def obj.ent

bend-toon-codec@0.1.0.0 · src/step.bend:94

import bend-toon-codec@0.1.0.0/src/step.bend as Step
import Base
import bend-toon-codec@0.1.0.0/src/json.bend as J
import bend-toon-codec@0.1.0.0/src/entry.bend as E
import bend-toon-codec@0.1.0.0/src/frame.bend as F

94# An entry applied to the object frame `FObj{dp, a, fs}` on top of `rest`.
95def obj.ent(+ent: E.Ent, +dp: U32, +a: F.Att, +fs: J.Json, +rest: List<&2, F.Fr>, +root: Maybe<&2, J.Json>, +bmin: U32, +strict: Bool) -> Result<&2, &2, String, F.St>:
96  match ent:
97    case E.ENot{}:
98      Fail{"missing colon after key"}
99    case E.EVal{k, v}:
100      F.put.field(strict, dp, a, fs, k, v, rest, root, bmin)
101    case E.EOpen{k}:
102      Done{F.St{Con{F.FObj{(dp + 1 : U32), F.AKey{k}, J.JNil{}}, Con{F.FObj{dp, a, fs}, rest}}, root, bmin}}
103    case E.EArr{Some{k}, h}:
104      obj.arr(arr_start(F.AKey{k}, (dp + 1 : U32), h, strict), k, dp, a, fs, rest, root, bmin, strict)
105    case E.EArr{None{}, h}:
106      Fail{"array header without a key"}

Uses (15)

Used by (2)