MCPcopy Create free account
hub / github.com/dprint/jsonc-parser / parse_object_property

Function parse_object_property

src/parse_to_ast.rs:367–397  ·  view source on GitHub ↗
(context: &mut Context<'a>, prop_name: PropName<'a>)

Source from the content-addressed store, hash-verified

365}
366
367fn parse_object_property<'a>(context: &mut Context<'a>, prop_name: PropName<'a>) -> Result<ObjectProp<'a>, ParseError> {
368 context.start_range();
369
370 let name = match prop_name {
371 PropName::String(prop_name) => ObjectPropName::String(create_string_lit(context, prop_name)),
372 PropName::Word(prop_name) => {
373 if context.allow_loose_object_property_names {
374 ObjectPropName::Word(create_word(context, prop_name))
375 } else {
376 return Err(context.create_error(ParseErrorKind::ExpectedStringObjectProperty));
377 }
378 }
379 };
380
381 match context.scan()? {
382 Some(Token::Colon) => {}
383 _ => return Err(context.create_error(ParseErrorKind::ExpectedColonAfterObjectKey)),
384 }
385
386 context.scan()?;
387 let value = parse_value(context)?;
388
389 match value {
390 Some(value) => Ok(ObjectProp {
391 range: context.end_range(),
392 name,
393 value,
394 }),
395 None => Err(context.create_error(ParseErrorKind::ExpectedObjectValue)),
396 }
397}
398
399fn parse_array<'a>(context: &mut Context<'a>) -> Result<Array<'a>, ParseError> {
400 debug_assert!(context.token() == Some(Token::OpenBracket));

Callers 1

parse_objectFunction · 0.85

Calls 7

create_string_litFunction · 0.85
create_wordFunction · 0.85
start_rangeMethod · 0.80
create_errorMethod · 0.80
end_rangeMethod · 0.80
parse_valueFunction · 0.70
scanMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…