def lex_value

qasim-bend-kit@0.1.0.2 · proof/JSON_RenderLexProof.bend:528

import qasim-bend-kit@0.1.0.2/proof/JSON_RenderLexProof.bend as JSONRenderLexProof
import Base
import qasim-bend-kit@0.1.0.2/libs/JSON.bend as J
import qasim-bend-kit@0.1.0.2/proof/JSON_SourceProof.bend as SP

528def lex_value(+value: J.Value,
529              +mode: SP.RenderMode,
530              +boundary: Boundary,
531              +acc: List<&2, J.Lexeme>) -> {J.lex_scan(SP.render_task(value, mode, boundary_text(boundary)), J.Outside{}, SNil{}, acc) == finish(boundary, push(value, mode, acc)) : List<&2, J.Lexeme>}:
532    match value:
533        case J.Null{}: atomic_lex(SP.AtomicNull{}, mode, boundary, acc)
534        case J.Bool{truth}:
535            match truth:
536                case True{}: atomic_lex(SP.AtomicTrue{}, mode, boundary, acc)
537                case False{}: atomic_lex(SP.AtomicFalse{}, mode, boundary, acc)
538        case J.Number{text, certificate}: atomic_lex(SP.AtomicNumber{text, certificate}, mode, boundary, acc)
539        case J.Str{text}: atomic_lex(SP.AtomicString{text}, mode, boundary, acc)
540        case J.Arr{Nil{}}: empty_array_lex(mode, boundary, acc)
541        case J.Obj{Nil{}}: empty_object_lex(mode, boundary, acc)
542        case J.Arr{head <> tail}:
543            lex_array(head, tail, mode, boundary, acc,
544                lex_value(head, SP.RenderWhole{}, array_continuation(tail, boundary), prefix_acc(ArrayKind{}, mode, acc)),
545                lex_value(J.Arr{tail}, SP.RenderAfterSeparator{}, boundary, J.Punctuation{','} <> push(head, SP.RenderWhole{}, prefix_acc(ArrayKind{}, mode, acc))))
546        case J.Obj{(key, head) <> tail}:
547            lex_object(key, head, tail, mode, boundary, acc,
548                lex_value(head, SP.RenderWhole{}, object_continuation(tail, boundary), J.Punctuation{':'} <> J.Payload{"\"" ++ J.escape_string(key) ++ "\""} <> prefix_acc(ObjectKind{}, mode, acc)),
549                lex_value(J.Obj{tail}, SP.RenderAfterSeparator{}, boundary, J.Punctuation{','} <> push(head, SP.RenderWhole{}, J.Punctuation{':'} <> J.Payload{"\"" ++ J.escape_string(key) ++ "\""} <> prefix_acc(ObjectKind{}, mode, acc))))

Uses (27)

Used by (1)