Branch Coverage

parser.c
Criterion Covered Total %
branch 304 570 53.3


line true false branch
169 0 1058 assert(parser); /* Non-NULL parser object is expected. */
170 0 1058 assert(event); /* Non-NULL event object is expected. */
178 1058 0 if (parser->stream_end_produced ||
179 20 1038 (parser->error &&
181 20 0 (!parser->problem_nonstrict || parser->error != YAML_READER_ERROR)) ||
20 0 (!parser->problem_nonstrict || parser->error != YAML_READER_ERROR)) ||
182 0 1058 parser->state == YAML_PARSE_END_STATE) {
317 110 0 token = PEEK_TOKEN(parser);
109 1 token = PEEK_TOKEN(parser);
318 1 109 if (!token) return 0;
320 0 109 if (token->type != YAML_STREAM_START_TOKEN) {
352 109 107 token = PEEK_TOKEN(parser);
108 1 token = PEEK_TOKEN(parser);
353 1 215 if (!token) return 0;
357 107 108 if (!implicit)
359 0 107 while (token->type == YAML_DOCUMENT_END_TOKEN) {
361 0 0 token = PEEK_TOKEN(parser);
0 0 token = PEEK_TOKEN(parser);
362 0 0 if (!token) return 0;
368 108 107 if (implicit && token->type != YAML_VERSION_DIRECTIVE_TOKEN &&
108 0 if (implicit && token->type != YAML_VERSION_DIRECTIVE_TOKEN &&
369 108 0 token->type != YAML_TAG_DIRECTIVE_TOKEN &&
370 20 88 token->type != YAML_DOCUMENT_START_TOKEN &&
371 15 5 token->type != YAML_STREAM_END_TOKEN)
373 0 15 if (!yaml_parser_process_directives(parser, NULL, NULL, NULL))
375 0 15 if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE))
0 0 if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE))
0 15 if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE))
385 98 102 else if (token->type != YAML_STREAM_END_TOKEN)
389 0 98 if (!yaml_parser_process_directives(parser, &version_directive,
392 0 98 token = PEEK_TOKEN(parser);
0 0 token = PEEK_TOKEN(parser);
393 0 98 if (!token)
395 0 98 if (token->type != YAML_DOCUMENT_START_TOKEN) {
400 0 98 if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE))
0 0 if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE))
0 98 if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE))
425 0 0 while (tag_directives.start != tag_directives.end) {
445 98 0 token = PEEK_TOKEN(parser);
97 1 token = PEEK_TOKEN(parser);
446 1 97 if (!token) return 0;
448 97 0 if (token->type == YAML_VERSION_DIRECTIVE_TOKEN ||
449 97 0 token->type == YAML_TAG_DIRECTIVE_TOKEN ||
450 97 0 token->type == YAML_DOCUMENT_START_TOKEN ||
451 97 0 token->type == YAML_DOCUMENT_END_TOKEN ||
452 0 97 token->type == YAML_STREAM_END_TOKEN) {
477 107 0 token = PEEK_TOKEN(parser);
107 0 token = PEEK_TOKEN(parser);
478 0 107 if (!token) return 0;
482 0 107 if (token->type == YAML_DOCUMENT_END_TOKEN) {
488 214 107 while (!STACK_EMPTY(parser, parser->tag_directives)) {
541 0 486 token = PEEK_TOKEN(parser);
0 0 token = PEEK_TOKEN(parser);
542 0 486 if (!token) return 0;
544 16 470 if (token->type == YAML_ALIAS_TOKEN)
557 17 453 if (token->type == YAML_ANCHOR_TOKEN)
563 17 0 token = PEEK_TOKEN(parser);
17 0 token = PEEK_TOKEN(parser);
564 0 17 if (!token)
566 4 13 if (token->type == YAML_TAG_TOKEN)
573 4 0 token = PEEK_TOKEN(parser);
4 0 token = PEEK_TOKEN(parser);
574 0 4 if (!token)
578 78 375 else if (token->type == YAML_TAG_TOKEN)
585 78 0 token = PEEK_TOKEN(parser);
78 0 token = PEEK_TOKEN(parser);
586 0 78 if (!token)
588 0 78 if (token->type == YAML_ANCHOR_TOKEN)
593 0 0 token = PEEK_TOKEN(parser);
0 0 token = PEEK_TOKEN(parser);
594 0 0 if (!token)
599 82 388 if (tag_handle) {
600 2 80 if (!*tag_handle) {
608 151 0 tag_directive != parser->tag_directives.top;
610 80 71 if (strcmp((char *)tag_directive->handle, (char *)tag_handle) == 0) {
614 0 80 if (!tag) {
627 0 80 if (!tag) {
636 82 388 implicit = (!tag || !*tag);
0 82 implicit = (!tag || !*tag);
637 226 244 if (indentless_sequence && token->type == YAML_BLOCK_ENTRY_TOKEN) {
3 223 if (indentless_sequence && token->type == YAML_BLOCK_ENTRY_TOKEN) {
645 337 130 if (token->type == YAML_SCALAR_TOKEN) {
649 303 34 if ((token->data.scalar.style == YAML_PLAIN_SCALAR_STYLE && !tag)
28 275 if ((token->data.scalar.style == YAML_PLAIN_SCALAR_STYLE && !tag)
650 34 28 || (tag && strcmp((char *)tag, "!") == 0)) {
0 34 || (tag && strcmp((char *)tag, "!") == 0)) {
653 28 34 else if (!tag) {
664 12 118 else if (token->type == YAML_FLOW_SEQUENCE_START_TOKEN) {
671 14 104 else if (token->type == YAML_FLOW_MAPPING_START_TOKEN) {
678 104 0 else if (block && token->type == YAML_BLOCK_SEQUENCE_START_TOKEN) {
37 67 else if (block && token->type == YAML_BLOCK_SEQUENCE_START_TOKEN) {
685 67 0 else if (block && token->type == YAML_BLOCK_MAPPING_START_TOKEN) {
63 4 else if (block && token->type == YAML_BLOCK_MAPPING_START_TOKEN) {
692 2 2 else if (anchor || tag) {
2 0 else if (anchor || tag) {
694 0 4 if (!value) {
706 0 0 yaml_parser_set_parser_error_context(parser,
736 37 107 if (first) {
737 0 37 token = PEEK_TOKEN(parser);
0 0 token = PEEK_TOKEN(parser);
738 0 37 if (!PUSH(parser, parser->marks, token->start_mark))
0 0 if (!PUSH(parser, parser->marks, token->start_mark))
0 37 if (!PUSH(parser, parser->marks, token->start_mark))
743 137 7 token = PEEK_TOKEN(parser);
137 0 token = PEEK_TOKEN(parser);
744 0 144 if (!token) return 0;
746 107 37 if (token->type == YAML_BLOCK_ENTRY_TOKEN)
750 107 0 token = PEEK_TOKEN(parser);
107 0 token = PEEK_TOKEN(parser);
751 0 107 if (!token) return 0;
752 107 0 if (token->type != YAML_BLOCK_ENTRY_TOKEN &&
753 104 3 token->type != YAML_BLOCK_END_TOKEN) {
754 0 104 if (!PUSH(parser, parser->states,
0 0 if (!PUSH(parser, parser->states,
0 104 if (!PUSH(parser, parser->states,
765 37 0 else if (token->type == YAML_BLOCK_END_TOKEN)
794 5 4 token = PEEK_TOKEN(parser);
5 0 token = PEEK_TOKEN(parser);
795 0 9 if (!token) return 0;
797 6 3 if (token->type == YAML_BLOCK_ENTRY_TOKEN)
801 6 0 token = PEEK_TOKEN(parser);
6 0 token = PEEK_TOKEN(parser);
802 0 6 if (!token) return 0;
803 5 1 if (token->type != YAML_BLOCK_ENTRY_TOKEN &&
804 5 0 token->type != YAML_KEY_TOKEN &&
805 5 0 token->type != YAML_VALUE_TOKEN &&
806 5 0 token->type != YAML_BLOCK_END_TOKEN) {
807 0 5 if (!PUSH(parser, parser->states,
0 0 if (!PUSH(parser, parser->states,
0 5 if (!PUSH(parser, parser->states,
844 63 115 if (first) {
845 0 63 token = PEEK_TOKEN(parser);
0 0 token = PEEK_TOKEN(parser);
846 0 63 if (!PUSH(parser, parser->marks, token->start_mark))
0 0 if (!PUSH(parser, parser->marks, token->start_mark))
0 63 if (!PUSH(parser, parser->marks, token->start_mark))
851 174 4 token = PEEK_TOKEN(parser);
173 1 token = PEEK_TOKEN(parser);
852 1 177 if (!token) return 0;
854 116 61 if (token->type == YAML_KEY_TOKEN)
858 116 0 token = PEEK_TOKEN(parser);
116 0 token = PEEK_TOKEN(parser);
859 0 116 if (!token) return 0;
860 116 0 if (token->type != YAML_KEY_TOKEN &&
861 116 0 token->type != YAML_VALUE_TOKEN &&
862 116 0 token->type != YAML_BLOCK_END_TOKEN) {
863 0 116 if (!PUSH(parser, parser->states,
0 0 if (!PUSH(parser, parser->states,
0 116 if (!PUSH(parser, parser->states,
874 60 1 else if (token->type == YAML_BLOCK_END_TOKEN)
909 116 0 token = PEEK_TOKEN(parser);
116 0 token = PEEK_TOKEN(parser);
910 0 116 if (!token) return 0;
912 116 0 if (token->type == YAML_VALUE_TOKEN)
916 116 0 token = PEEK_TOKEN(parser);
115 1 token = PEEK_TOKEN(parser);
917 1 115 if (!token) return 0;
918 114 1 if (token->type != YAML_KEY_TOKEN &&
919 114 0 token->type != YAML_VALUE_TOKEN &&
920 114 0 token->type != YAML_BLOCK_END_TOKEN) {
921 0 114 if (!PUSH(parser, parser->states,
0 0 if (!PUSH(parser, parser->states,
0 114 if (!PUSH(parser, parser->states,
959 12 14 if (first) {
960 0 12 token = PEEK_TOKEN(parser);
0 0 token = PEEK_TOKEN(parser);
961 0 12 if (!PUSH(parser, parser->marks, token->start_mark))
0 0 if (!PUSH(parser, parser->marks, token->start_mark))
0 12 if (!PUSH(parser, parser->marks, token->start_mark))
966 25 1 token = PEEK_TOKEN(parser);
25 0 token = PEEK_TOKEN(parser);
967 0 26 if (!token) return 0;
969 14 12 if (token->type != YAML_FLOW_SEQUENCE_END_TOKEN)
971 5 9 if (!first) {
972 5 0 if (token->type == YAML_FLOW_ENTRY_TOKEN) {
974 5 0 token = PEEK_TOKEN(parser);
5 0 token = PEEK_TOKEN(parser);
975 0 5 if (!token) return 0;
984 1 13 if (token->type == YAML_KEY_TOKEN) {
993 13 0 else if (token->type != YAML_FLOW_SEQUENCE_END_TOKEN) {
994 0 13 if (!PUSH(parser, parser->states,
0 0 if (!PUSH(parser, parser->states,
0 13 if (!PUSH(parser, parser->states,
1020 1 0 token = PEEK_TOKEN(parser);
1 0 token = PEEK_TOKEN(parser);
1021 0 1 if (!token) return 0;
1023 1 0 if (token->type != YAML_VALUE_TOKEN && token->type != YAML_FLOW_ENTRY_TOKEN
1 0 if (token->type != YAML_VALUE_TOKEN && token->type != YAML_FLOW_ENTRY_TOKEN
1024 1 0 && token->type != YAML_FLOW_SEQUENCE_END_TOKEN) {
1025 0 1 if (!PUSH(parser, parser->states,
0 0 if (!PUSH(parser, parser->states,
0 1 if (!PUSH(parser, parser->states,
1050 1 0 token = PEEK_TOKEN(parser);
1 0 token = PEEK_TOKEN(parser);
1051 0 1 if (!token) return 0;
1053 1 0 if (token->type == YAML_VALUE_TOKEN) {
1055 1 0 token = PEEK_TOKEN(parser);
1 0 token = PEEK_TOKEN(parser);
1056 0 1 if (!token) return 0;
1057 1 0 if (token->type != YAML_FLOW_ENTRY_TOKEN
1058 1 0 && token->type != YAML_FLOW_SEQUENCE_END_TOKEN) {
1059 0 1 if (!PUSH(parser, parser->states,
0 0 if (!PUSH(parser, parser->states,
0 1 if (!PUSH(parser, parser->states,
1081 1 0 token = PEEK_TOKEN(parser);
1 0 token = PEEK_TOKEN(parser);
1082 0 1 if (!token) return 0;
1110 14 11 if (first) {
1111 0 14 token = PEEK_TOKEN(parser);
0 0 token = PEEK_TOKEN(parser);
1112 0 14 if (!PUSH(parser, parser->marks, token->start_mark))
0 0 if (!PUSH(parser, parser->marks, token->start_mark))
0 14 if (!PUSH(parser, parser->marks, token->start_mark))
1117 23 2 token = PEEK_TOKEN(parser);
23 0 token = PEEK_TOKEN(parser);
1118 0 25 if (!token) return 0;
1120 11 14 if (token->type != YAML_FLOW_MAPPING_END_TOKEN)
1122 3 8 if (!first) {
1123 3 0 if (token->type == YAML_FLOW_ENTRY_TOKEN) {
1125 3 0 token = PEEK_TOKEN(parser);
3 0 token = PEEK_TOKEN(parser);
1126 0 3 if (!token) return 0;
1135 9 2 if (token->type == YAML_KEY_TOKEN) {
1137 9 0 token = PEEK_TOKEN(parser);
9 0 token = PEEK_TOKEN(parser);
1138 0 9 if (!token) return 0;
1139 9 0 if (token->type != YAML_VALUE_TOKEN
1140 9 0 && token->type != YAML_FLOW_ENTRY_TOKEN
1141 9 0 && token->type != YAML_FLOW_MAPPING_END_TOKEN) {
1142 0 9 if (!PUSH(parser, parser->states,
0 0 if (!PUSH(parser, parser->states,
0 9 if (!PUSH(parser, parser->states,
1153 2 0 else if (token->type != YAML_FLOW_MAPPING_END_TOKEN) {
1154 0 2 if (!PUSH(parser, parser->states,
0 0 if (!PUSH(parser, parser->states,
0 2 if (!PUSH(parser, parser->states,
1180 11 0 token = PEEK_TOKEN(parser);
11 0 token = PEEK_TOKEN(parser);
1181 0 11 if (!token) return 0;
1183 2 9 if (empty) {
1189 9 0 if (token->type == YAML_VALUE_TOKEN) {
1191 9 0 token = PEEK_TOKEN(parser);
9 0 token = PEEK_TOKEN(parser);
1192 0 9 if (!token) return 0;
1193 9 0 if (token->type != YAML_FLOW_ENTRY_TOKEN
1194 9 0 && token->type != YAML_FLOW_MAPPING_END_TOKEN) {
1195 0 9 if (!PUSH(parser, parser->states,
0 0 if (!PUSH(parser, parser->states,
0 9 if (!PUSH(parser, parser->states,
1217 0 7 if (!value) {
1253 113 0 if (!STACK_INIT(parser, tag_directives, yaml_tag_directive_t*))
0 113 if (!STACK_INIT(parser, tag_directives, yaml_tag_directive_t*))
1256 0 113 token = PEEK_TOKEN(parser);
0 0 token = PEEK_TOKEN(parser);
1257 0 113 if (!token)
1260 0 113 while (token->type == YAML_VERSION_DIRECTIVE_TOKEN ||
1261 0 113 token->type == YAML_TAG_DIRECTIVE_TOKEN)
1263 0 0 if (token->type == YAML_VERSION_DIRECTIVE_TOKEN) {
1264 0 0 if (version_directive) {
1269 0 0 if (token->data.version_directive.major != 1
1270 0 0 || token->data.version_directive.minor != 1) {
1276 0 0 if (!version_directive) {
1284 0 0 else if (token->type == YAML_TAG_DIRECTIVE_TOKEN) {
1289 0 0 if (!yaml_parser_append_tag_directive(parser, value, 0,
1292 0 0 if (!PUSH(parser, tag_directives, value))
0 0 if (!PUSH(parser, tag_directives, value))
0 0 if (!PUSH(parser, tag_directives, value))
1297 0 0 token = PEEK_TOKEN(parser);
0 0 token = PEEK_TOKEN(parser);
1298 0 0 if (!token)
1303 226 113 default_tag_directive->handle; default_tag_directive++) {
1304 0 226 if (!yaml_parser_append_tag_directive(parser, *default_tag_directive, 1,
1309 98 15 if (version_directive_ref) {
1312 98 15 if (tag_directives_start_ref) {
1313 98 0 if (STACK_EMPTY(parser, tag_directives)) {
1326 15 98 if (!version_directive_ref)
1332 0 0 while (!STACK_EMPTY(parser, tag_directives)) {
1353 113 226 tag_directive != parser->tag_directives.top; tag_directive ++) {
1354 0 113 if (strcmp((char *)value.handle, (char *)tag_directive->handle) == 0) {
1355 0 0 if (allow_duplicates)
1364 226 0 if (!copy.handle || !copy.prefix) {
0 226 if (!copy.handle || !copy.prefix) {
1369 0 226 if (!PUSH(parser, parser->tag_directives, copy))
0 0 if (!PUSH(parser, parser->tag_directives, copy))
0 226 if (!PUSH(parser, parser->tag_directives, copy))