| 854 | */ |
| 855 | |
| 856 | static int |
| 857 | yaml_parser_parse_block_mapping_key(yaml_parser_t *parser, |
| 858 | yaml_event_t *event, int first) |
| 859 | { |
| 860 | yaml_token_t *token; |
| 861 | |
| 862 | if (first) { |
| 863 | token = PEEK_TOKEN(parser); |
| 864 | if (!PUSH(parser, parser->marks, token->start_mark)) |
| 865 | return 0; |
| 866 | SKIP_TOKEN(parser); |
| 867 | } |
| 868 | |
| 869 | token = PEEK_TOKEN(parser); |
| 870 | if (!token) return 0; |
| 871 | |
| 872 | if (token->type == YAML_KEY_TOKEN) |
| 873 | { |
| 874 | yaml_mark_t mark = token->end_mark; |
| 875 | SKIP_TOKEN(parser); |
| 876 | token = PEEK_TOKEN(parser); |
| 877 | if (!token) return 0; |
| 878 | if (token->type != YAML_KEY_TOKEN && |
| 879 | token->type != YAML_VALUE_TOKEN && |
| 880 | token->type != YAML_BLOCK_END_TOKEN) { |
| 881 | if (!PUSH(parser, parser->states, |
| 882 | YAML_PARSE_BLOCK_MAPPING_VALUE_STATE)) |
| 883 | return 0; |
| 884 | return yaml_parser_parse_node(parser, event, 1, 1); |
| 885 | } |
| 886 | else { |
| 887 | parser->state = YAML_PARSE_BLOCK_MAPPING_VALUE_STATE; |
| 888 | return yaml_parser_process_empty_scalar(parser, event, mark); |
| 889 | } |
| 890 | } |
| 891 | |
| 892 | else if (token->type == YAML_BLOCK_END_TOKEN) |
| 893 | { |
| 894 | // yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */ |
| 895 | parser->state = POP(parser, parser->states); |
| 896 | /* dummy_mark = */ (void)POP(parser, parser->marks); |
| 897 | MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark); |
| 898 | SKIP_TOKEN(parser); |
| 899 | return 1; |
| 900 | } |
| 901 | |
| 902 | else |
| 903 | { |
| 904 | return yaml_parser_set_parser_error_context(parser, |
| 905 | "while parsing a block mapping", POP(parser, parser->marks), |
| 906 | "did not find expected key", token->start_mark); |
| 907 | } |
| 908 | } |
| 909 | |
| 910 | /* |
| 911 | * Parse the productions: |
no test coverage detected