MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / stateArrayValue

Method stateArrayValue

pkg/util/json/tokenizer/decoder.go:209–244  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

207}
208
209func (d *Decoder) stateArrayValue() ([]byte, error) {
210 tok := d.scanner.Next()
211 if len(tok) < 1 {
212 return nil, io.ErrUnexpectedEOF
213 }
214 switch tok[0] {
215 case '{':
216 d.state = (*Decoder).stateObjectString
217 d.push(true)
218 return tok, nil
219 case '[':
220 d.state = (*Decoder).stateArrayValue
221 d.push(false)
222 return tok, nil
223 case ']':
224 if d.mustHaveValue {
225 d.scanner.offset -= len(tok) + 1 // Rewind to point to comma.
226 return nil, fmt.Errorf("stateArrayValue: unexpected comma")
227 }
228 inObj := d.pop()
229 switch {
230 case d.len() == 0:
231 d.state = (*Decoder).stateEnd
232 case inObj:
233 d.state = (*Decoder).stateObjectComma
234 case !inObj:
235 d.state = (*Decoder).stateArrayComma
236 }
237 return tok, nil
238 case Comma:
239 return nil, fmt.Errorf("stateArrayValue: unexpected comma")
240 default:
241 d.state = (*Decoder).stateArrayComma
242 return tok, nil
243 }
244}
245
246func (d *Decoder) stateArrayComma() (_ []byte, err error) {
247 tok := d.scanner.Next()

Callers 1

stateArrayCommaMethod · 0.95

Calls 5

ErrorfMethod · 0.80
NextMethod · 0.65
lenMethod · 0.65
pushMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected