MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / yaml_parser_fetch_key

Function yaml_parser_fetch_key

xs/tools/yaml/scanner.c:1653–1700  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1651 */
1652
1653static int
1654yaml_parser_fetch_key(yaml_parser_t *parser)
1655{
1656 yaml_mark_t start_mark, end_mark;
1657 yaml_token_t token;
1658
1659 /* In the block context, additional checks are required. */
1660
1661 if (!parser->flow_level)
1662 {
1663 /* Check if we are allowed to start a new key (not nessesary simple). */
1664
1665 if (!parser->simple_key_allowed) {
1666 return yaml_parser_set_scanner_error(parser, NULL, parser->mark,
1667 "mapping keys are not allowed in this context");
1668 }
1669
1670 /* Add the BLOCK-MAPPING-START token if needed. */
1671
1672 if (!yaml_parser_roll_indent(parser, parser->mark.column, -1,
1673 YAML_BLOCK_MAPPING_START_TOKEN, parser->mark))
1674 return 0;
1675 }
1676
1677 /* Reset any potential simple keys on the current flow level. */
1678
1679 if (!yaml_parser_remove_simple_key(parser))
1680 return 0;
1681
1682 /* Simple keys are allowed after '?' in the block context. */
1683
1684 parser->simple_key_allowed = (!parser->flow_level);
1685
1686 /* Consume the token. */
1687
1688 start_mark = parser->mark;
1689 SKIP(parser);
1690 end_mark = parser->mark;
1691
1692 /* Create the KEY token and append it to the queue. */
1693
1694 TOKEN_INIT(token, YAML_KEY_TOKEN, start_mark, end_mark);
1695
1696 if (!ENQUEUE(parser, parser->tokens, token))
1697 return 0;
1698
1699 return 1;
1700}
1701
1702/*
1703 * Produce the VALUE token.

Callers 1

Calls 3

yaml_parser_roll_indentFunction · 0.85

Tested by

no test coverage detected