| 1704 | */ |
| 1705 | |
| 1706 | static int |
| 1707 | yaml_parser_fetch_value(yaml_parser_t *parser) |
| 1708 | { |
| 1709 | yaml_mark_t start_mark, end_mark; |
| 1710 | yaml_token_t token; |
| 1711 | yaml_simple_key_t *simple_key = parser->simple_keys.top-1; |
| 1712 | |
| 1713 | /* Have we found a simple key? */ |
| 1714 | |
| 1715 | if (simple_key->possible) |
| 1716 | { |
| 1717 | |
| 1718 | /* Create the KEY token and insert it into the queue. */ |
| 1719 | |
| 1720 | TOKEN_INIT(token, YAML_KEY_TOKEN, simple_key->mark, simple_key->mark); |
| 1721 | |
| 1722 | if (!QUEUE_INSERT(parser, parser->tokens, |
| 1723 | simple_key->token_number - parser->tokens_parsed, token)) |
| 1724 | return 0; |
| 1725 | |
| 1726 | /* In the block context, we may need to add the BLOCK-MAPPING-START token. */ |
| 1727 | |
| 1728 | if (!yaml_parser_roll_indent(parser, simple_key->mark.column, |
| 1729 | simple_key->token_number, |
| 1730 | YAML_BLOCK_MAPPING_START_TOKEN, simple_key->mark)) |
| 1731 | return 0; |
| 1732 | |
| 1733 | /* Remove the simple key. */ |
| 1734 | |
| 1735 | simple_key->possible = 0; |
| 1736 | |
| 1737 | /* A simple key cannot follow another simple key. */ |
| 1738 | |
| 1739 | parser->simple_key_allowed = 0; |
| 1740 | } |
| 1741 | else |
| 1742 | { |
| 1743 | /* The ':' indicator follows a complex key. */ |
| 1744 | |
| 1745 | /* In the block context, extra checks are required. */ |
| 1746 | |
| 1747 | if (!parser->flow_level) |
| 1748 | { |
| 1749 | /* Check if we are allowed to start a complex value. */ |
| 1750 | |
| 1751 | if (!parser->simple_key_allowed) { |
| 1752 | return yaml_parser_set_scanner_error(parser, NULL, parser->mark, |
| 1753 | "mapping values are not allowed in this context"); |
| 1754 | } |
| 1755 | |
| 1756 | /* Add the BLOCK-MAPPING-START token if needed. */ |
| 1757 | |
| 1758 | if (!yaml_parser_roll_indent(parser, parser->mark.column, -1, |
| 1759 | YAML_BLOCK_MAPPING_START_TOKEN, parser->mark)) |
| 1760 | return 0; |
| 1761 | } |
| 1762 | |
| 1763 | /* Simple keys after ':' are allowed in the block context. */ |
no test coverage detected