def close_arr

emerging-ezjson@1.3.0.0 · src/parse.bend:135

import emerging-ezjson@1.3.0.0/src/parse.bend as Parse
import Base
import emerging-ezjson@1.3.0.0/src/value.bend as V

135# a `]`: the innermost frame must be an array, empty or just after a value
136def close_arr(stack: List<&2, Frame>, root: Maybe<&2, V.Json>, bad: Bool) -> P:
137  match stack:
138    case Con{FArr{V.JNil{}, SValue{}}, rest}:
139      put(rest, root, V.JArr{V.JNil{}}, bad)
140    case Con{FArr{items, SComma{}}, rest}:
141      put(rest, root, V.JArr{V.reverse(items, V.JNil{})}, bad)
142    case other:
143      P{True{}, root, Nil{}}

Uses (9)

Used by (1)