Branch Coverage

parser.c
Criterion Covered Total %
branch 304 570 53.3


line true false branch
169 0 1050 assert(parser); /* Non-NULL parser object is expected. */
170 0 1050 assert(event); /* Non-NULL event object is expected. */
178 1050 0 if (parser->stream_end_produced ||
20 1030 if (parser->stream_end_produced ||
179 20 0 (parser->error &&
181 20 0 (!parser->problem_nonstrict || parser->error != YAML_READER_ERROR)) ||
0 1050 (!parser->problem_nonstrict || parser->error != YAML_READER_ERROR)) ||
317 109 0 token = PEEK_TOKEN(parser);
108 1 token = PEEK_TOKEN(parser);
318 1 108 if (!token) return 0;
320 0 108 if (token->type != YAML_STREAM_START_TOKEN) {
352 108 106 token = PEEK_TOKEN(parser);
107 1 token = PEEK_TOKEN(parser);
353 1 213 if (!token) return 0;
357 106 107 if (!implicit)
359 0 106 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 107 106 if (implicit && token->type != YAML_VERSION_DIRECTIVE_TOKEN &&
107 0 if (implicit && token->type != YAML_VERSION_DIRECTIVE_TOKEN &&
107 0 if (implicit && token->type != YAML_VERSION_DIRECTIVE_TOKEN &&
369 20 87 token->type != YAML_TAG_DIRECTIVE_TOKEN &&
370 15 5 token->type != YAML_DOCUMENT_START_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 97 101 else if (token->type != YAML_STREAM_END_TOKEN)
389 0 97 if (!yaml_parser_process_directives(parser, &version_directive,
392 0 97 token = PEEK_TOKEN(parser);
0 0 token = PEEK_TOKEN(parser);
393 0 97 if (!token)
395 0 97 if (token->type != YAML_DOCUMENT_START_TOKEN) {
400 0 97 if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE))
0 0 if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE))
0 97 if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE))
425 0 0 while (tag_directives.start != tag_directives.end) {
445 97 0 token = PEEK_TOKEN(parser);
96 1 token = PEEK_TOKEN(parser);
446 1 96 if (!token) return 0;
448 96 0 if (token->type == YAML_VERSION_DIRECTIVE_TOKEN ||
96 0 if (token->type == YAML_VERSION_DIRECTIVE_TOKEN ||
449 96 0 token->type == YAML_TAG_DIRECTIVE_TOKEN ||
450 96 0 token->type == YAML_DOCUMENT_START_TOKEN ||
451 0 96 token->type == YAML_DOCUMENT_END_TOKEN ||
477 106 0 token = PEEK_TOKEN(parser);
106 0 token = PEEK_TOKEN(parser);
478 0 106 if (!token) return 0;
482 0 106 if (token->type == YAML_DOCUMENT_END_TOKEN) {
488 212 106 while (!STACK_EMPTY(parser, parser->tag_directives)) {
541 0 483 token = PEEK_TOKEN(parser);
0 0 token = PEEK_TOKEN(parser);
542 0 483 if (!token) return 0;
544 16 467 if (token->type == YAML_ALIAS_TOKEN)
557 17 450 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 372 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 385 if (tag_handle) {
600 2 80 if (!*tag_handle) {
607 151 0 for (tag_directive = parser->tag_directives.start;
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 385 implicit = (!tag || !*tag);
0 82 implicit = (!tag || !*tag);
637 224 243 if (indentless_sequence && token->type == YAML_BLOCK_ENTRY_TOKEN) {
3 221 if (indentless_sequence && token->type == YAML_BLOCK_ENTRY_TOKEN) {
645 335 129 if (token->type == YAML_SCALAR_TOKEN) {
649 301 34 if ((token->data.scalar.style == YAML_PLAIN_SCALAR_STYLE && !tag)
28 273 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 117 else if (token->type == YAML_FLOW_SEQUENCE_START_TOKEN) {
671 14 103 else if (token->type == YAML_FLOW_MAPPING_START_TOKEN) {
678 103 0 else if (block && token->type == YAML_BLOCK_SEQUENCE_START_TOKEN) {
37 66 else if (block && token->type == YAML_BLOCK_SEQUENCE_START_TOKEN) {
685 66 0 else if (block && token->type == YAML_BLOCK_MAPPING_START_TOKEN) {
62 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 &&
104 3 if (token->type != YAML_BLOCK_ENTRY_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 &&
5 0 if (token->type != YAML_BLOCK_ENTRY_TOKEN &&
804 5 0 token->type != YAML_KEY_TOKEN &&
805 5 0 token->type != YAML_VALUE_TOKEN &&
807 0 5 if (!PUSH(parser, parser->states,
0 0 if (!PUSH(parser, parser->states,
0 5 if (!PUSH(parser, parser->states,
844 62 114 if (first) {
845 0 62 token = PEEK_TOKEN(parser);
0 0 token = PEEK_TOKEN(parser);
846 0 62 if (!PUSH(parser, parser->marks, token->start_mark))
0 0 if (!PUSH(parser, parser->marks, token->start_mark))
0 62 if (!PUSH(parser, parser->marks, token->start_mark))
851 172 4 token = PEEK_TOKEN(parser);
171 1 token = PEEK_TOKEN(parser);
852 1 175 if (!token) return 0;
854 115 60 if (token->type == YAML_KEY_TOKEN)
858 115 0 token = PEEK_TOKEN(parser);
115 0 token = PEEK_TOKEN(parser);
859 0 115 if (!token) return 0;
860 115 0 if (token->type != YAML_KEY_TOKEN &&
115 0 if (token->type != YAML_KEY_TOKEN &&
861 115 0 token->type != YAML_VALUE_TOKEN &&
863 0 115 if (!PUSH(parser, parser->states,
0 0 if (!PUSH(parser, parser->states,
0 115 if (!PUSH(parser, parser->states,
874 59 1 else if (token->type == YAML_BLOCK_END_TOKEN)
909 115 0 token = PEEK_TOKEN(parser);
115 0 token = PEEK_TOKEN(parser);
910 0 115 if (!token) return 0;
912 115 0 if (token->type == YAML_VALUE_TOKEN)
916 115 0 token = PEEK_TOKEN(parser);
114 1 token = PEEK_TOKEN(parser);
917 1 114 if (!token) return 0;
918 113 1 if (token->type != YAML_KEY_TOKEN &&
113 0 if (token->type != YAML_KEY_TOKEN &&
919 113 0 token->type != YAML_VALUE_TOKEN &&
921 0 113 if (!PUSH(parser, parser->states,
0 0 if (!PUSH(parser, parser->states,
0 113 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 112 0 if (!STACK_INIT(parser, tag_directives, yaml_tag_directive_t*))
0 112 if (!STACK_INIT(parser, tag_directives, yaml_tag_directive_t*))
1256 0 112 token = PEEK_TOKEN(parser);
0 0 token = PEEK_TOKEN(parser);
1257 0 112 if (!token)
1260 0 112 while (token->type == YAML_VERSION_DIRECTIVE_TOKEN ||
0 112 while (token->type == YAML_VERSION_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)
1302 224 112 for (default_tag_directive = default_tag_directives;
1304 0 224 if (!yaml_parser_append_tag_directive(parser, *default_tag_directive, 1,
1309 97 15 if (version_directive_ref) {
1312 97 15 if (tag_directives_start_ref) {
1313 97 0 if (STACK_EMPTY(parser, tag_directives)) {
1326 15 97 if (!version_directive_ref)
1332 0 0 while (!STACK_EMPTY(parser, tag_directives)) {
1352 112 224 for (tag_directive = parser->tag_directives.start;
1354 0 112 if (strcmp((char *)value.handle, (char *)tag_directive->handle) == 0) {
1355 0 0 if (allow_duplicates)
1364 224 0 if (!copy.handle || !copy.prefix) {
0 224 if (!copy.handle || !copy.prefix) {
1369 0 224 if (!PUSH(parser, parser->tag_directives, copy))
0 0 if (!PUSH(parser, parser->tag_directives, copy))
0 224 if (!PUSH(parser, parser->tag_directives, copy))