src/parse.bend checks
raw source on the hub · import emerging-ezjson@1.1.0.0/src/parse.bend as Parse
src/parse: tokens to one JSON value. Commas separate elements, a colon separates a key from its value, and a text has one root.
3 imports
import Base import ./value.bend as V import ./lex.bend as Lex
Types
type Slot source · line 8 · raw
Data
where the next token of an open array or object has to be
SValueSlot
SCommaSlot
SKeySlot
SColonSlot
type Key source · line 15 · raw
Data
an object key: owned text, or the first n chars of a source suffix
KOwn@s:String -> Key
KCut@src:String -> @n:U32 -> Key
type Frame source · line 21 · raw
Data
an open array (its items, reversed) or an open object (its pairs, reversed, and the key awaiting its value)
FArr@items:0x81c67699424929b5c44cd8577e18117f/src/value.Json -> @slot:Slot -> Frame
FObj@pairs:0x81c67699424929b5c44cd8577e18117f/src/value.Json -> @key:Key -> @slot:Slot -> Frame
type P source · line 26 · raw
Data
the parser's state: an error was seen, the finished root, the open frames
P@bad:Bool -> @root:Maybe<&2, 0x81c67699424929b5c44cd8577e18117f/src/value.Json> -> @stack:List<&2, Frame> -> P
Definitions
def word.ok source · line 29 · raw
@+raw:String -> Bool
def word source · line 35 · raw
@+raw:String -> 0x81c67699424929b5c44cd8577e18117f/src/value.Json
a bare word as a value: null, true, false, else a number kept as text
def step.ready source · line 40 · raw
@stack:List<&2, Frame> -> @root:Maybe<&2, 0x81c67699424929b5c44cd8577e18117f/src/value.Json> -> Bool
def put.pair source · line 51 · raw
@key:Key -> @val:0x81c67699424929b5c44cd8577e18117f/src/value.Json -> @pairs:0x81c67699424929b5c44cd8577e18117f/src/value.Json -> 0x81c67699424929b5c44cd8577e18117f/src/value.Json
def put.text source · line 58 · raw
@key:Key -> 0x81c67699424929b5c44cd8577e18117f/src/value.Json
def put source · line 66 · raw
@stack:List<&2, Frame> -> @root:Maybe<&2, 0x81c67699424929b5c44cd8577e18117f/src/value.Json> -> @vv:0x81c67699424929b5c44cd8577e18117f/src/value.Json -> @bad:Bool -> P
a finished value lands in the innermost open frame, or becomes the root
def put.str source · line 79 · raw
@stack:List<&2, Frame> -> @root:Maybe<&2, 0x81c67699424929b5c44cd8577e18117f/src/value.Json> -> @key:Key -> @bad:Bool -> P
def step.open_arr.go source · line 86 · raw
@bad:Bool -> @root:Maybe<&2, 0x81c67699424929b5c44cd8577e18117f/src/value.Json> -> @stack:List<&2, Frame> -> @ok:Bool -> P
def step.open_arr source · line 93 · raw
@st:P -> P
def step.open_obj.go source · line 97 · raw
@bad:Bool -> @root:Maybe<&2, 0x81c67699424929b5c44cd8577e18117f/src/value.Json> -> @stack:List<&2, Frame> -> @ok:Bool -> P
def step.open_obj source · line 104 · raw
@st:P -> P
def step.comma source · line 108 · raw
@stack:List<&2, Frame> -> @root:Maybe<&2, 0x81c67699424929b5c44cd8577e18117f/src/value.Json> -> @bad:Bool -> P
def step.colon source · line 117 · raw
@stack:List<&2, Frame> -> @root:Maybe<&2, 0x81c67699424929b5c44cd8577e18117f/src/value.Json> -> @bad:Bool -> P
def step.word.go source · line 124 · raw
@raw:String -> @st:P -> @ok:Bool -> P
def step.word source · line 132 · raw
@+raw:String -> @st:P -> P
def close_arr source · line 136 · raw
@stack:List<&2, Frame> -> @root:Maybe<&2, 0x81c67699424929b5c44cd8577e18117f/src/value.Json> -> @bad:Bool -> P
a ]: the innermost frame must be an array, empty or just after a value
def close_obj source · line 146 · raw
@stack:List<&2, Frame> -> @root:Maybe<&2, 0x81c67699424929b5c44cd8577e18117f/src/value.Json> -> @bad:Bool -> P
a }: the innermost frame must be an object, empty or just after a value
def step.span.ok source · line 155 · raw
@+raw:String -> @ok:Bool -> Pair(0x81c67699424929b5c44cd8577e18117f/src/value.Json, Bool)
def step.span.use source · line 162 · raw
@+raw:String -> Pair(0x81c67699424929b5c44cd8577e18117f/src/value.Json, Bool)
def step.span.chk source · line 165 · raw
@src:String -> @+nn:U32 -> Pair(0x81c67699424929b5c44cd8577e18117f/src/value.Json, Bool)
def step.span.go source · line 168 · raw
@src:String -> @nn:U32 -> @is_null:Bool -> @is_true:Bool -> @is_false:Bool -> Pair(0x81c67699424929b5c44cd8577e18117f/src/value.Json, Bool)
def step.span.use2 source · line 179 · raw
@st:P -> @val:0x81c67699424929b5c44cd8577e18117f/src/value.Json -> @ok:Bool -> P
def step.span.open source · line 187 · raw
@st:P -> @got:Pair(0x81c67699424929b5c44cd8577e18117f/src/value.Json, Bool) -> P
def step.span source · line 191 · raw
@+src:String -> @+nn:U32 -> @st:P -> P
def step source · line 196 · raw
@tok:0x81c67699424929b5c44cd8577e18117f/src/lex.Tok -> @st:P -> P
one token
def run source · line 229 · raw
@toks:List<&2, 0x81c67699424929b5c44cd8577e18117f/src/lex.Tok> -> @st:P -> P
every token, in order
def result source · line 237 · raw
@bad:Bool -> @stack:List<&2, Frame> -> @root:Maybe<&2, 0x81c67699424929b5c44cd8577e18117f/src/value.Json> -> Maybe<&2, 0x81c67699424929b5c44cd8577e18117f/src/value.Json>
the root, when nothing went wrong and nothing stayed open
def finish source · line 245 · raw
@st:P -> Maybe<&2, 0x81c67699424929b5c44cd8577e18117f/src/value.Json>
the value once the tokens are over
def parse source · line 250 · raw
@txt:String -> Maybe<&2, 0x81c67699424929b5c44cd8577e18117f/src/value.Json>
a text as a value, or None when it is not JSON