def plan.val

cswap-bend-cli@0.1.0.0 · json.bend:95

import cswap-bend-cli@0.1.0.0/json.bend as Json
import Base
import cswap-bend-cli@0.1.0.0/json/lex.bend as Lex

95def plan.val(+toks: List<&2, Lex.Tok>) -> Plan:
96  match toks:
97    case Con{Lex.TNull{}, t}:
98      PRes{only(t, JNull{})}
99    case Con{Lex.TTrue{}, t}:
100      PRes{only(t, JBool{True{}})}
101    case Con{Lex.TFalse{}, t}:
102      PRes{only(t, JBool{False{}})}
103    case Con{Lex.TNum{x}, t}:
104      PRes{only(t, JNum{x})}
105    case Con{Lex.TStr{x}, t}:
106      PRes{only(t, JStr{x})}
107    case Con{Lex.TLBrack{}, +t}:
108      PArr{t}
109    case Con{Lex.TLBrace{}, +t}:
110      PObj{t}
111    case Nil{}:
112      PRes{Fail{"unexpected end of input"}}
113    case _:
114      PRes{Fail{"unexpected token"}}

Uses (7)

Used by (1)