| 1109 | */ |
| 1110 | |
| 1111 | static int |
| 1112 | yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser, |
| 1113 | yaml_event_t *event, int first) |
| 1114 | { |
| 1115 | yaml_token_t *token; |
| 1116 | |
| 1117 | if (first) { |
| 1118 | token = PEEK_TOKEN(parser); |
| 1119 | if (!PUSH(parser, parser->marks, token->start_mark)) |
| 1120 | return 0; |
| 1121 | SKIP_TOKEN(parser); |
| 1122 | } |
| 1123 | |
| 1124 | token = PEEK_TOKEN(parser); |
| 1125 | if (!token) return 0; |
| 1126 | |
| 1127 | if (token->type != YAML_FLOW_MAPPING_END_TOKEN) |
| 1128 | { |
| 1129 | if (!first) { |
| 1130 | if (token->type == YAML_FLOW_ENTRY_TOKEN) { |
| 1131 | SKIP_TOKEN(parser); |
| 1132 | token = PEEK_TOKEN(parser); |
| 1133 | if (!token) return 0; |
| 1134 | } |
| 1135 | else { |
| 1136 | return yaml_parser_set_parser_error_context(parser, |
| 1137 | "while parsing a flow mapping", POP(parser, parser->marks), |
| 1138 | "did not find expected ',' or '}'", token->start_mark); |
| 1139 | } |
| 1140 | } |
| 1141 | |
| 1142 | if (token->type == YAML_KEY_TOKEN) { |
| 1143 | SKIP_TOKEN(parser); |
| 1144 | token = PEEK_TOKEN(parser); |
| 1145 | if (!token) return 0; |
| 1146 | if (token->type != YAML_VALUE_TOKEN |
| 1147 | && token->type != YAML_FLOW_ENTRY_TOKEN |
| 1148 | && token->type != YAML_FLOW_MAPPING_END_TOKEN) { |
| 1149 | if (!PUSH(parser, parser->states, |
| 1150 | YAML_PARSE_FLOW_MAPPING_VALUE_STATE)) |
| 1151 | return 0; |
| 1152 | return yaml_parser_parse_node(parser, event, 0, 0); |
| 1153 | } |
| 1154 | else { |
| 1155 | parser->state = YAML_PARSE_FLOW_MAPPING_VALUE_STATE; |
| 1156 | return yaml_parser_process_empty_scalar(parser, event, |
| 1157 | token->start_mark); |
| 1158 | } |
| 1159 | } |
| 1160 | else if (token->type != YAML_FLOW_MAPPING_END_TOKEN) { |
| 1161 | if (!PUSH(parser, parser->states, |
| 1162 | YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE)) |
| 1163 | return 0; |
| 1164 | return yaml_parser_parse_node(parser, event, 0, 0); |
| 1165 | } |
| 1166 | } |
| 1167 | |
| 1168 | parser->state = POP(parser, parser->states); |
no test coverage detected