def co.close

yaml-for-bend@0.1.1.0 · compose.bend:417

import yaml-for-bend@0.1.1.0/compose.bend as Compose
import Base
import yaml-for-bend@0.1.1.0/token.bend as T
import yaml-for-bend@0.1.1.0/value.bend as V

417# The collection on top ends.
418def co.close(co: Co) -> Result<&2, &2, T.Error, Co>:
419  match co:
420    case Co{stack, anchors, +count, root, docs, opened, depth, copied}:
421      match stack:
422        case Nil{}:
423          Fail{content("found the end of a collection that never started", T.Mark{0n, 0n, 0n})}
424        case Con{top, rest}:
425          match top:
426            case OSeq{anchor, tag, items, start, +at}:
427              node.done(Done{collection(tag, V.Seq{List.reverse(&2, V.Yaml, items)})}, Co{rest, anchors, count, root, docs, opened, Nat.sub(depth, 1n), copied}, anchor, False{}, 1n+Nat.sub(count, start), 1n, at)
428            case OMap{anchor, tag, items, start, +at}:
429              node.done(map.tagged(map.value(List.reverse(&2, Item, items)), tag), Co{rest, anchors, count, root, docs, opened, Nat.sub(depth, 1n), copied}, anchor, False{}, 1n+Nat.sub(count, start), 1n, at)

Uses (17)

Used by (1)