| 838 | */ |
| 839 | |
| 840 | static int |
| 841 | yaml_parser_parse_block_mapping_key(yaml_parser_t *parser, |
| 842 | yaml_event_t *event, int first) |
| 843 | { |
| 844 | yaml_token_t *token; |
| 845 | |
| 846 | if (first) { |
| 847 | token = PEEK_TOKEN(parser); |
| 848 | if (!PUSH(parser, parser->marks, token->start_mark)) |
| 849 | return 0; |
| 850 | SKIP_TOKEN(parser); |
| 851 | } |
| 852 | |
| 853 | token = PEEK_TOKEN(parser); |
| 854 | if (!token) return 0; |
| 855 | |
| 856 | if (token->type == YAML_KEY_TOKEN) |
| 857 | { |
| 858 | yaml_mark_t mark = token->end_mark; |
| 859 | SKIP_TOKEN(parser); |
| 860 | token = PEEK_TOKEN(parser); |
| 861 | if (!token) return 0; |
| 862 | if (token->type != YAML_KEY_TOKEN && |
| 863 | token->type != YAML_VALUE_TOKEN && |
| 864 | token->type != YAML_BLOCK_END_TOKEN) { |
| 865 | if (!PUSH(parser, parser->states, |
| 866 | YAML_PARSE_BLOCK_MAPPING_VALUE_STATE)) |
| 867 | return 0; |
| 868 | return yaml_parser_parse_node(parser, event, 1, 1); |
| 869 | } |
| 870 | else { |
| 871 | parser->state = YAML_PARSE_BLOCK_MAPPING_VALUE_STATE; |
| 872 | return yaml_parser_process_empty_scalar(parser, event, mark); |
| 873 | } |
| 874 | } |
| 875 | |
| 876 | else if (token->type == YAML_BLOCK_END_TOKEN) |
| 877 | { |
| 878 | parser->state = POP(parser, parser->states); |
| 879 | (void)POP(parser, parser->marks); |
| 880 | MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark); |
| 881 | SKIP_TOKEN(parser); |
| 882 | return 1; |
| 883 | } |
| 884 | |
| 885 | else |
| 886 | { |
| 887 | return yaml_parser_set_parser_error_context(parser, |
| 888 | "while parsing a block mapping", POP(parser, parser->marks), |
| 889 | "did not find expected key", token->start_mark); |
| 890 | } |
| 891 | } |
| 892 | |
| 893 | /* |
| 894 | * Parse the productions: |
no test coverage detected