MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / parse_array

Function parse_array

std/json/src/main/parser.rs:76–90  ·  view source on GitHub ↗
(tk: &mut Tokenizer, ctx: &LoadCtx)

Source from the content-addressed store, hash-verified

74}
75
76fn parse_array(tk: &mut Tokenizer, ctx: &LoadCtx) -> Result<Handle> {
77 let list = Handle::new_list()?;
78 let first = tk.next_token().map_err(to_pdk_err)?;
79 if matches!(first, Token::RBracket) { return Ok(list); }
80 let mut current = first;
81 loop {
82 let item = parse_value_with(tk, current, ctx)?;
83 let _ = list.call("append", &[item.raw()])?;
84 match tk.next_token().map_err(to_pdk_err)? {
85 Token::Comma => current = tk.next_token().map_err(to_pdk_err)?,
86 Token::RBracket => return Ok(list),
87 _ => return Err(value_err(tk.pos(), "expected ',' or ']' in array")),
88 }
89 }
90}
91
92fn parse_object(tk: &mut Tokenizer, ctx: &LoadCtx) -> Result<Handle> {
93 // `object_pairs_hook` wins over `object_hook` per CPython spec: gather (key, value) pairs and call the hook on them, skipping dict build.

Callers 1

parse_value_withFunction · 0.85

Calls 6

parse_value_withFunction · 0.85
value_errFunction · 0.85
posMethod · 0.80
next_tokenMethod · 0.45
callMethod · 0.45
rawMethod · 0.45

Tested by

no test coverage detected