| 1 |
|
| |
| 2 |
|
| /* |
| 3 |
|
| * The parser implements the following grammar: |
| 4 |
|
| * |
| 5 |
|
| * stream ::= STREAM-START implicit_document? explicit_document* STREAM-END |
| 6 |
|
| * implicit_document ::= block_node DOCUMENT-END* |
| 7 |
|
| * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* |
| 8 |
|
| * block_node_or_indentless_sequence ::= |
| 9 |
|
| * ALIAS |
| 10 |
|
| * | properties (block_content | indentless_block_sequence)? |
| 11 |
|
| * | block_content |
| 12 |
|
| * | indentless_block_sequence |
| 13 |
|
| * block_node ::= ALIAS |
| 14 |
|
| * | properties block_content? |
| 15 |
|
| * | block_content |
| 16 |
|
| * flow_node ::= ALIAS |
| 17 |
|
| * | properties flow_content? |
| 18 |
|
| * | flow_content |
| 19 |
|
| * properties ::= TAG ANCHOR? | ANCHOR TAG? |
| 20 |
|
| * block_content ::= block_collection | flow_collection | SCALAR |
| 21 |
|
| * flow_content ::= flow_collection | SCALAR |
| 22 |
|
| * block_collection ::= block_sequence | block_mapping |
| 23 |
|
| * flow_collection ::= flow_sequence | flow_mapping |
| 24 |
|
| * block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END |
| 25 |
|
| * indentless_sequence ::= (BLOCK-ENTRY block_node?)+ |
| 26 |
|
| * block_mapping ::= BLOCK-MAPPING_START |
| 27 |
|
| * ((KEY block_node_or_indentless_sequence?)? |
| 28 |
|
| * (VALUE block_node_or_indentless_sequence?)?)* |
| 29 |
|
| * BLOCK-END |
| 30 |
|
| * flow_sequence ::= FLOW-SEQUENCE-START |
| 31 |
|
| * (flow_sequence_entry FLOW-ENTRY)* |
| 32 |
|
| * flow_sequence_entry? |
| 33 |
|
| * FLOW-SEQUENCE-END |
| 34 |
|
| * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? |
| 35 |
|
| * flow_mapping ::= FLOW-MAPPING-START |
| 36 |
|
| * (flow_mapping_entry FLOW-ENTRY)* |
| 37 |
|
| * flow_mapping_entry? |
| 38 |
|
| * FLOW-MAPPING-END |
| 39 |
|
| * flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? |
| 40 |
|
| */ |
| 41 |
|
| |
| 42 |
|
| #include "yaml_private.h" |
| 43 |
|
| |
| 44 |
|
| /* |
| 45 |
|
| * Peek the next token in the token queue. |
| 46 |
|
| */ |
| 47 |
|
| |
| 48 |
|
| #define PEEK_TOKEN(parser) \ |
| 49 |
|
| ((parser->token_available || yaml_parser_fetch_more_tokens(parser)) ? \ |
| 50 |
|
| parser->tokens.head : NULL) |
| 51 |
|
| |
| 52 |
|
| /* |
| 53 |
|
| * Remove the next token from the queue (must be called after PEEK_TOKEN). |
| 54 |
|
| */ |
| 55 |
|
| |
| 56 |
|
| #define SKIP_TOKEN(parser) \ |
| 57 |
|
| (parser->token_available = 0, \ |
| 58 |
|
| parser->tokens_parsed ++, \ |
| 59 |
|
| parser->stream_end_produced = \ |
| 60 |
|
| (parser->tokens.head->type == YAML_STREAM_END_TOKEN), \ |
| 61 |
|
| parser->tokens.head ++) |
| 62 |
|
| |
| 63 |
|
| /* |
| 64 |
|
| * Public API declarations: see yaml.h |
| 65 |
|
| */ |
| 66 |
|
| |
| 67 |
|
| /* |
| 68 |
|
| * Error handling. |
| 69 |
|
| */ |
| 70 |
|
| |
| 71 |
|
| static int |
| 72 |
|
| yaml_parser_set_parser_error(yaml_parser_t *parser, |
| 73 |
|
| const char *problem, yaml_mark_t problem_mark); |
| 74 |
|
| |
| 75 |
|
| static int |
| 76 |
|
| yaml_parser_set_parser_error_context(yaml_parser_t *parser, |
| 77 |
|
| const char *context, yaml_mark_t context_mark, |
| 78 |
|
| const char *problem, yaml_mark_t problem_mark); |
| 79 |
|
| |
| 80 |
|
| /* |
| 81 |
|
| * State functions. |
| 82 |
|
| */ |
| 83 |
|
| |
| 84 |
|
| static int |
| 85 |
|
| yaml_parser_state_machine(yaml_parser_t *parser, yaml_event_t *event); |
| 86 |
|
| |
| 87 |
|
| static int |
| 88 |
|
| yaml_parser_parse_stream_start(yaml_parser_t *parser, yaml_event_t *event); |
| 89 |
|
| |
| 90 |
|
| static int |
| 91 |
|
| yaml_parser_parse_document_start(yaml_parser_t *parser, yaml_event_t *event, |
| 92 |
|
| int implicit); |
| 93 |
|
| |
| 94 |
|
| static int |
| 95 |
|
| yaml_parser_parse_document_content(yaml_parser_t *parser, yaml_event_t *event); |
| 96 |
|
| |
| 97 |
|
| static int |
| 98 |
|
| yaml_parser_parse_document_end(yaml_parser_t *parser, yaml_event_t *event); |
| 99 |
|
| |
| 100 |
|
| static int |
| 101 |
|
| yaml_parser_parse_node(yaml_parser_t *parser, yaml_event_t *event, |
| 102 |
|
| int block, int indentless_sequence); |
| 103 |
|
| |
| 104 |
|
| static int |
| 105 |
|
| yaml_parser_parse_block_sequence_entry(yaml_parser_t *parser, |
| 106 |
|
| yaml_event_t *event, int first); |
| 107 |
|
| |
| 108 |
|
| static int |
| 109 |
|
| yaml_parser_parse_indentless_sequence_entry(yaml_parser_t *parser, |
| 110 |
|
| yaml_event_t *event); |
| 111 |
|
| |
| 112 |
|
| static int |
| 113 |
|
| yaml_parser_parse_block_mapping_key(yaml_parser_t *parser, |
| 114 |
|
| yaml_event_t *event, int first); |
| 115 |
|
| |
| 116 |
|
| static int |
| 117 |
|
| yaml_parser_parse_block_mapping_value(yaml_parser_t *parser, |
| 118 |
|
| yaml_event_t *event); |
| 119 |
|
| |
| 120 |
|
| static int |
| 121 |
|
| yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser, |
| 122 |
|
| yaml_event_t *event, int first); |
| 123 |
|
| |
| 124 |
|
| static int |
| 125 |
|
| yaml_parser_parse_flow_sequence_entry_mapping_key(yaml_parser_t *parser, |
| 126 |
|
| yaml_event_t *event); |
| 127 |
|
| |
| 128 |
|
| static int |
| 129 |
|
| yaml_parser_parse_flow_sequence_entry_mapping_value(yaml_parser_t *parser, |
| 130 |
|
| yaml_event_t *event); |
| 131 |
|
| |
| 132 |
|
| static int |
| 133 |
|
| yaml_parser_parse_flow_sequence_entry_mapping_end(yaml_parser_t *parser, |
| 134 |
|
| yaml_event_t *event); |
| 135 |
|
| |
| 136 |
|
| static int |
| 137 |
|
| yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser, |
| 138 |
|
| yaml_event_t *event, int first); |
| 139 |
|
| |
| 140 |
|
| static int |
| 141 |
|
| yaml_parser_parse_flow_mapping_value(yaml_parser_t *parser, |
| 142 |
|
| yaml_event_t *event, int empty); |
| 143 |
|
| |
| 144 |
|
| /* |
| 145 |
|
| * Utility functions. |
| 146 |
|
| */ |
| 147 |
|
| |
| 148 |
|
| static int |
| 149 |
|
| yaml_parser_process_empty_scalar(yaml_parser_t *parser, |
| 150 |
|
| yaml_event_t *event, yaml_mark_t mark); |
| 151 |
|
| |
| 152 |
|
| static int |
| 153 |
|
| yaml_parser_process_directives(yaml_parser_t *parser, |
| 154 |
|
| yaml_version_directive_t **version_directive_ref, |
| 155 |
|
| yaml_tag_directive_t **tag_directives_start_ref, |
| 156 |
|
| yaml_tag_directive_t **tag_directives_end_ref); |
| 157 |
|
| |
| 158 |
|
| static int |
| 159 |
|
| yaml_parser_append_tag_directive(yaml_parser_t *parser, |
| 160 |
|
| yaml_tag_directive_t value, int allow_duplicates, yaml_mark_t mark); |
| 161 |
|
| |
| 162 |
|
| /* |
| 163 |
|
| * Get the next event. |
| 164 |
|
| */ |
| 165 |
|
| |
| 166 |
|
| YAML_DECLARE(int) |
| 167 |
1058 |
| yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event) |
| 168 |
|
| { |
| 169 |
1058 |
▶ | assert(parser); /* Non-NULL parser object is expected. */ |
Branch: 1 branch
| Branch | True | False | Total |
| assert(parser); /* Non-NULL parser object is expected. */ |
0 |
1058 |
1058 |
|
| 170 |
1058 |
▶ | assert(event); /* Non-NULL event object is expected. */ |
Branch: 1 branch
| Branch | True | False | Total |
| assert(event); /* Non-NULL event object is expected. */ |
0 |
1058 |
1058 |
|
| 171 |
|
| |
| 172 |
|
| /* Erase the event object. */ |
| 173 |
|
| |
| 174 |
1058 |
| memset(event, 0, sizeof(yaml_event_t)); |
| 175 |
|
| |
| 176 |
|
| /* No events after the end of the stream or error. */ |
| 177 |
|
| |
| 178 |
1058 |
▶ | if (parser->stream_end_produced || |
Branch: 1 branch
| Branch | True | False | Total |
| if (parser->stream_end_produced || |
1058 |
0 |
1058 |
|
| 179 |
1058 |
▶ | (parser->error && |
Branch: 1 branch
| Branch | True | False | Total |
| (parser->error && |
20 |
1038 |
1058 |
|
| 180 |
|
| /* continue in nonstrict and READER_ERROR */ |
| 181 |
20 |
▶ | (!parser->problem_nonstrict || parser->error != YAML_READER_ERROR)) || |
Branch: 2 branches
| Branch | True | False | Total |
| (!parser->problem_nonstrict || parser->error != YAML_READER_ERROR)) || |
20 |
0 |
20 |
| (!parser->problem_nonstrict || parser->error != YAML_READER_ERROR)) || |
20 |
0 |
20 |
|
| 182 |
1058 |
▶ | parser->state == YAML_PARSE_END_STATE) { |
Branch: 1 branch
| Branch | True | False | Total |
| parser->state == YAML_PARSE_END_STATE) { |
0 |
1058 |
1058 |
|
| 183 |
0 |
| return 1; |
| 184 |
|
| } |
| 185 |
|
| |
| 186 |
|
| /* Generate the next event. */ |
| 187 |
|
| |
| 188 |
1058 |
| return yaml_parser_state_machine(parser, event); |
| 189 |
|
| } |
| 190 |
|
| |
| 191 |
|
| /* |
| 192 |
|
| * Set parser error. |
| 193 |
|
| */ |
| 194 |
|
| |
| 195 |
|
| static int |
| 196 |
0 |
| yaml_parser_set_parser_error(yaml_parser_t *parser, |
| 197 |
|
| const char *problem, yaml_mark_t problem_mark) |
| 198 |
|
| { |
| 199 |
0 |
| parser->error = YAML_PARSER_ERROR; |
| 200 |
0 |
| parser->problem = problem; |
| 201 |
0 |
| parser->problem_mark = problem_mark; |
| 202 |
|
| |
| 203 |
0 |
| return 0; |
| 204 |
|
| } |
| 205 |
|
| |
| 206 |
|
| static int |
| 207 |
1 |
| yaml_parser_set_parser_error_context(yaml_parser_t *parser, |
| 208 |
|
| const char *context, yaml_mark_t context_mark, |
| 209 |
|
| const char *problem, yaml_mark_t problem_mark) |
| 210 |
|
| { |
| 211 |
1 |
| parser->error = YAML_PARSER_ERROR; |
| 212 |
1 |
| parser->context = context; |
| 213 |
1 |
| parser->context_mark = context_mark; |
| 214 |
1 |
| parser->problem = problem; |
| 215 |
1 |
| parser->problem_mark = problem_mark; |
| 216 |
|
| |
| 217 |
1 |
| return 0; |
| 218 |
|
| } |
| 219 |
|
| |
| 220 |
|
| |
| 221 |
|
| /* |
| 222 |
|
| * State dispatcher. |
| 223 |
|
| */ |
| 224 |
|
| |
| 225 |
|
| static int |
| 226 |
1058 |
| yaml_parser_state_machine(yaml_parser_t *parser, yaml_event_t *event) |
| 227 |
|
| { |
| 228 |
1058 |
| switch (parser->state) |
| 229 |
|
| { |
| 230 |
110 |
| case YAML_PARSE_STREAM_START_STATE: |
| 231 |
110 |
| return yaml_parser_parse_stream_start(parser, event); |
| 232 |
|
| |
| 233 |
109 |
| case YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE: |
| 234 |
109 |
| return yaml_parser_parse_document_start(parser, event, 1); |
| 235 |
|
| |
| 236 |
107 |
| case YAML_PARSE_DOCUMENT_START_STATE: |
| 237 |
107 |
| return yaml_parser_parse_document_start(parser, event, 0); |
| 238 |
|
| |
| 239 |
98 |
| case YAML_PARSE_DOCUMENT_CONTENT_STATE: |
| 240 |
98 |
| return yaml_parser_parse_document_content(parser, event); |
| 241 |
|
| |
| 242 |
107 |
| case YAML_PARSE_DOCUMENT_END_STATE: |
| 243 |
107 |
| return yaml_parser_parse_document_end(parser, event); |
| 244 |
|
| |
| 245 |
15 |
| case YAML_PARSE_BLOCK_NODE_STATE: |
| 246 |
15 |
| return yaml_parser_parse_node(parser, event, 1, 0); |
| 247 |
|
| |
| 248 |
0 |
| case YAML_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE: |
| 249 |
0 |
| return yaml_parser_parse_node(parser, event, 1, 1); |
| 250 |
|
| |
| 251 |
0 |
| case YAML_PARSE_FLOW_NODE_STATE: |
| 252 |
0 |
| return yaml_parser_parse_node(parser, event, 0, 0); |
| 253 |
|
| |
| 254 |
37 |
| case YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE: |
| 255 |
37 |
| return yaml_parser_parse_block_sequence_entry(parser, event, 1); |
| 256 |
|
| |
| 257 |
107 |
| case YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE: |
| 258 |
107 |
| return yaml_parser_parse_block_sequence_entry(parser, event, 0); |
| 259 |
|
| |
| 260 |
9 |
| case YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE: |
| 261 |
9 |
| return yaml_parser_parse_indentless_sequence_entry(parser, event); |
| 262 |
|
| |
| 263 |
63 |
| case YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE: |
| 264 |
63 |
| return yaml_parser_parse_block_mapping_key(parser, event, 1); |
| 265 |
|
| |
| 266 |
115 |
| case YAML_PARSE_BLOCK_MAPPING_KEY_STATE: |
| 267 |
115 |
| return yaml_parser_parse_block_mapping_key(parser, event, 0); |
| 268 |
|
| |
| 269 |
116 |
| case YAML_PARSE_BLOCK_MAPPING_VALUE_STATE: |
| 270 |
116 |
| return yaml_parser_parse_block_mapping_value(parser, event); |
| 271 |
|
| |
| 272 |
12 |
| case YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE: |
| 273 |
12 |
| return yaml_parser_parse_flow_sequence_entry(parser, event, 1); |
| 274 |
|
| |
| 275 |
14 |
| case YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE: |
| 276 |
14 |
| return yaml_parser_parse_flow_sequence_entry(parser, event, 0); |
| 277 |
|
| |
| 278 |
1 |
| case YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE: |
| 279 |
1 |
| return yaml_parser_parse_flow_sequence_entry_mapping_key(parser, event); |
| 280 |
|
| |
| 281 |
1 |
| case YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE: |
| 282 |
1 |
| return yaml_parser_parse_flow_sequence_entry_mapping_value(parser, event); |
| 283 |
|
| |
| 284 |
1 |
| case YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE: |
| 285 |
1 |
| return yaml_parser_parse_flow_sequence_entry_mapping_end(parser, event); |
| 286 |
|
| |
| 287 |
14 |
| case YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE: |
| 288 |
14 |
| return yaml_parser_parse_flow_mapping_key(parser, event, 1); |
| 289 |
|
| |
| 290 |
11 |
| case YAML_PARSE_FLOW_MAPPING_KEY_STATE: |
| 291 |
11 |
| return yaml_parser_parse_flow_mapping_key(parser, event, 0); |
| 292 |
|
| |
| 293 |
9 |
| case YAML_PARSE_FLOW_MAPPING_VALUE_STATE: |
| 294 |
9 |
| return yaml_parser_parse_flow_mapping_value(parser, event, 0); |
| 295 |
|
| |
| 296 |
2 |
| case YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE: |
| 297 |
2 |
| return yaml_parser_parse_flow_mapping_value(parser, event, 1); |
| 298 |
|
| |
| 299 |
0 |
| default: |
| 300 |
|
| assert(1); /* Invalid state. */ |
| 301 |
|
| } |
| 302 |
|
| |
| 303 |
0 |
| return 0; |
| 304 |
|
| } |
| 305 |
|
| |
| 306 |
|
| /* |
| 307 |
|
| * Parse the production: |
| 308 |
|
| * stream ::= STREAM-START implicit_document? explicit_document* STREAM-END |
| 309 |
|
| * ************ |
| 310 |
|
| */ |
| 311 |
|
| |
| 312 |
|
| static int |
| 313 |
110 |
| yaml_parser_parse_stream_start(yaml_parser_t *parser, yaml_event_t *event) |
| 314 |
|
| { |
| 315 |
|
| yaml_token_t *token; |
| 316 |
|
| |
| 317 |
110 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
110 |
0 |
110 |
| token = PEEK_TOKEN(parser); |
109 |
1 |
110 |
|
| 318 |
110 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
1 |
109 |
110 |
|
| 319 |
|
| |
| 320 |
109 |
▶ | if (token->type != YAML_STREAM_START_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type != YAML_STREAM_START_TOKEN) { |
0 |
109 |
109 |
|
| 321 |
0 |
| return yaml_parser_set_parser_error(parser, |
| 322 |
|
| "did not find expected <stream-start>", token->start_mark); |
| 323 |
|
| } |
| 324 |
|
| |
| 325 |
109 |
| parser->state = YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE; |
| 326 |
109 |
| STREAM_START_EVENT_INIT(*event, token->data.stream_start.encoding, |
| 327 |
|
| token->start_mark, token->start_mark); |
| 328 |
109 |
| SKIP_TOKEN(parser); |
| 329 |
|
| |
| 330 |
109 |
| return 1; |
| 331 |
|
| } |
| 332 |
|
| |
| 333 |
|
| /* |
| 334 |
|
| * Parse the productions: |
| 335 |
|
| * implicit_document ::= block_node DOCUMENT-END* |
| 336 |
|
| * * |
| 337 |
|
| * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* |
| 338 |
|
| * ************************* |
| 339 |
|
| */ |
| 340 |
|
| |
| 341 |
|
| static int |
| 342 |
216 |
| yaml_parser_parse_document_start(yaml_parser_t *parser, yaml_event_t *event, |
| 343 |
|
| int implicit) |
| 344 |
|
| { |
| 345 |
|
| yaml_token_t *token; |
| 346 |
216 |
| yaml_version_directive_t *version_directive = NULL; |
| 347 |
|
| struct { |
| 348 |
|
| yaml_tag_directive_t *start; |
| 349 |
|
| yaml_tag_directive_t *end; |
| 350 |
216 |
| } tag_directives = { NULL, NULL }; |
| 351 |
|
| |
| 352 |
216 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
109 |
107 |
216 |
| token = PEEK_TOKEN(parser); |
108 |
1 |
109 |
|
| 353 |
216 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
1 |
215 |
216 |
|
| 354 |
|
| |
| 355 |
|
| /* Parse extra document end indicators. */ |
| 356 |
|
| |
| 357 |
215 |
▶ | if (!implicit) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!implicit) |
107 |
108 |
215 |
|
| 358 |
|
| { |
| 359 |
107 |
▶ | while (token->type == YAML_DOCUMENT_END_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (token->type == YAML_DOCUMENT_END_TOKEN) { |
0 |
107 |
107 |
|
| 360 |
0 |
| SKIP_TOKEN(parser); |
| 361 |
0 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
0 |
0 |
0 |
| token = PEEK_TOKEN(parser); |
0 |
0 |
0 |
|
| 362 |
0 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
0 |
0 |
|
| 363 |
|
| } |
| 364 |
|
| } |
| 365 |
|
| |
| 366 |
|
| /* Parse an implicit document. */ |
| 367 |
|
| |
| 368 |
215 |
▶ | if (implicit && token->type != YAML_VERSION_DIRECTIVE_TOKEN && |
Branch: 2 branches
| Branch | True | False | Total |
| if (implicit && token->type != YAML_VERSION_DIRECTIVE_TOKEN && |
108 |
107 |
215 |
| if (implicit && token->type != YAML_VERSION_DIRECTIVE_TOKEN && |
108 |
0 |
108 |
|
| 369 |
108 |
▶ | token->type != YAML_TAG_DIRECTIVE_TOKEN && |
Branch: 1 branch
| Branch | True | False | Total |
| token->type != YAML_TAG_DIRECTIVE_TOKEN && |
108 |
0 |
108 |
|
| 370 |
108 |
▶ | token->type != YAML_DOCUMENT_START_TOKEN && |
Branch: 1 branch
| Branch | True | False | Total |
| token->type != YAML_DOCUMENT_START_TOKEN && |
20 |
88 |
108 |
|
| 371 |
20 |
▶ | token->type != YAML_STREAM_END_TOKEN) |
Branch: 1 branch
| Branch | True | False | Total |
| token->type != YAML_STREAM_END_TOKEN) |
15 |
5 |
20 |
|
| 372 |
|
| { |
| 373 |
15 |
▶ | if (!yaml_parser_process_directives(parser, NULL, NULL, NULL)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!yaml_parser_process_directives(parser, NULL, NULL, NULL)) |
0 |
15 |
15 |
|
| 374 |
0 |
| return 0; |
| 375 |
15 |
▶ | if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE)) |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE)) |
0 |
15 |
15 |
| if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE)) |
0 |
0 |
0 |
| if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE)) |
0 |
15 |
15 |
|
| 376 |
0 |
| return 0; |
| 377 |
15 |
| parser->state = YAML_PARSE_BLOCK_NODE_STATE; |
| 378 |
15 |
| DOCUMENT_START_EVENT_INIT(*event, NULL, NULL, NULL, 1, |
| 379 |
|
| token->start_mark, token->start_mark); |
| 380 |
15 |
| return 1; |
| 381 |
|
| } |
| 382 |
|
| |
| 383 |
|
| /* Parse an explicit document. */ |
| 384 |
|
| |
| 385 |
200 |
▶ | else if (token->type != YAML_STREAM_END_TOKEN) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (token->type != YAML_STREAM_END_TOKEN) |
98 |
102 |
200 |
|
| 386 |
|
| { |
| 387 |
|
| yaml_mark_t start_mark, end_mark; |
| 388 |
98 |
| start_mark = token->start_mark; |
| 389 |
98 |
▶ | if (!yaml_parser_process_directives(parser, &version_directive, |
Branch: 1 branch
| Branch | True | False | Total |
| if (!yaml_parser_process_directives(parser, &version_directive, |
0 |
98 |
98 |
|
| 390 |
|
| &tag_directives.start, &tag_directives.end)) |
| 391 |
98 |
| return 0; |
| 392 |
98 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
0 |
98 |
98 |
| token = PEEK_TOKEN(parser); |
0 |
0 |
0 |
|
| 393 |
98 |
▶ | if (!token) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) |
0 |
98 |
98 |
|
| 394 |
0 |
| goto error; |
| 395 |
98 |
▶ | if (token->type != YAML_DOCUMENT_START_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type != YAML_DOCUMENT_START_TOKEN) { |
0 |
98 |
98 |
|
| 396 |
0 |
| yaml_parser_set_parser_error(parser, |
| 397 |
|
| "did not find expected <document start>", token->start_mark); |
| 398 |
0 |
| goto error; |
| 399 |
|
| } |
| 400 |
98 |
▶ | if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE)) |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE)) |
0 |
98 |
98 |
| if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE)) |
0 |
0 |
0 |
| if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE)) |
0 |
98 |
98 |
|
| 401 |
0 |
| goto error; |
| 402 |
98 |
| parser->state = YAML_PARSE_DOCUMENT_CONTENT_STATE; |
| 403 |
98 |
| end_mark = token->end_mark; |
| 404 |
98 |
| DOCUMENT_START_EVENT_INIT(*event, version_directive, |
| 405 |
|
| tag_directives.start, tag_directives.end, 0, |
| 406 |
|
| start_mark, end_mark); |
| 407 |
98 |
| SKIP_TOKEN(parser); |
| 408 |
98 |
| version_directive = NULL; |
| 409 |
98 |
| tag_directives.start = tag_directives.end = NULL; |
| 410 |
98 |
| return 1; |
| 411 |
|
| } |
| 412 |
|
| |
| 413 |
|
| /* Parse the stream end. */ |
| 414 |
|
| |
| 415 |
|
| else |
| 416 |
|
| { |
| 417 |
102 |
| parser->state = YAML_PARSE_END_STATE; |
| 418 |
102 |
| STREAM_END_EVENT_INIT(*event, token->start_mark, token->end_mark); |
| 419 |
102 |
| SKIP_TOKEN(parser); |
| 420 |
102 |
| return 1; |
| 421 |
|
| } |
| 422 |
|
| |
| 423 |
0 |
| error: |
| 424 |
0 |
| yaml_free(version_directive); |
| 425 |
0 |
▶ | while (tag_directives.start != tag_directives.end) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (tag_directives.start != tag_directives.end) { |
0 |
0 |
0 |
|
| 426 |
0 |
| yaml_free(tag_directives.end[-1].handle); |
| 427 |
0 |
| yaml_free(tag_directives.end[-1].prefix); |
| 428 |
0 |
| tag_directives.end --; |
| 429 |
|
| } |
| 430 |
0 |
| yaml_free(tag_directives.start); |
| 431 |
0 |
| return 0; |
| 432 |
|
| } |
| 433 |
|
| |
| 434 |
|
| /* |
| 435 |
|
| * Parse the productions: |
| 436 |
|
| * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* |
| 437 |
|
| * *********** |
| 438 |
|
| */ |
| 439 |
|
| |
| 440 |
|
| static int |
| 441 |
98 |
| yaml_parser_parse_document_content(yaml_parser_t *parser, yaml_event_t *event) |
| 442 |
|
| { |
| 443 |
|
| yaml_token_t *token; |
| 444 |
|
| |
| 445 |
98 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
98 |
0 |
98 |
| token = PEEK_TOKEN(parser); |
97 |
1 |
98 |
|
| 446 |
98 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
1 |
97 |
98 |
|
| 447 |
|
| |
| 448 |
97 |
▶ | if (token->type == YAML_VERSION_DIRECTIVE_TOKEN || |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_VERSION_DIRECTIVE_TOKEN || |
97 |
0 |
97 |
|
| 449 |
97 |
▶ | token->type == YAML_TAG_DIRECTIVE_TOKEN || |
Branch: 1 branch
| Branch | True | False | Total |
| token->type == YAML_TAG_DIRECTIVE_TOKEN || |
97 |
0 |
97 |
|
| 450 |
97 |
▶ | token->type == YAML_DOCUMENT_START_TOKEN || |
Branch: 1 branch
| Branch | True | False | Total |
| token->type == YAML_DOCUMENT_START_TOKEN || |
97 |
0 |
97 |
|
| 451 |
97 |
▶ | token->type == YAML_DOCUMENT_END_TOKEN || |
Branch: 1 branch
| Branch | True | False | Total |
| token->type == YAML_DOCUMENT_END_TOKEN || |
97 |
0 |
97 |
|
| 452 |
97 |
▶ | token->type == YAML_STREAM_END_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| token->type == YAML_STREAM_END_TOKEN) { |
0 |
97 |
97 |
|
| 453 |
0 |
| parser->state = POP(parser, parser->states); |
| 454 |
0 |
| return yaml_parser_process_empty_scalar(parser, event, |
| 455 |
|
| token->start_mark); |
| 456 |
|
| } |
| 457 |
|
| else { |
| 458 |
97 |
| return yaml_parser_parse_node(parser, event, 1, 0); |
| 459 |
|
| } |
| 460 |
|
| } |
| 461 |
|
| |
| 462 |
|
| /* |
| 463 |
|
| * Parse the productions: |
| 464 |
|
| * implicit_document ::= block_node DOCUMENT-END* |
| 465 |
|
| * ************* |
| 466 |
|
| * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* |
| 467 |
|
| * ************* |
| 468 |
|
| */ |
| 469 |
|
| |
| 470 |
|
| static int |
| 471 |
107 |
| yaml_parser_parse_document_end(yaml_parser_t *parser, yaml_event_t *event) |
| 472 |
|
| { |
| 473 |
|
| yaml_token_t *token; |
| 474 |
|
| yaml_mark_t start_mark, end_mark; |
| 475 |
107 |
| int implicit = 1; |
| 476 |
|
| |
| 477 |
107 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
107 |
0 |
107 |
| token = PEEK_TOKEN(parser); |
107 |
0 |
107 |
|
| 478 |
107 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
107 |
107 |
|
| 479 |
|
| |
| 480 |
107 |
| start_mark = end_mark = token->start_mark; |
| 481 |
|
| |
| 482 |
107 |
▶ | if (token->type == YAML_DOCUMENT_END_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_DOCUMENT_END_TOKEN) { |
0 |
107 |
107 |
|
| 483 |
0 |
| end_mark = token->end_mark; |
| 484 |
0 |
| SKIP_TOKEN(parser); |
| 485 |
0 |
| implicit = 0; |
| 486 |
|
| } |
| 487 |
|
| |
| 488 |
321 |
▶ | while (!STACK_EMPTY(parser, parser->tag_directives)) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (!STACK_EMPTY(parser, parser->tag_directives)) { |
214 |
107 |
321 |
|
| 489 |
214 |
| yaml_tag_directive_t tag_directive = POP(parser, parser->tag_directives); |
| 490 |
214 |
| yaml_free(tag_directive.handle); |
| 491 |
214 |
| yaml_free(tag_directive.prefix); |
| 492 |
|
| } |
| 493 |
|
| |
| 494 |
107 |
| parser->state = YAML_PARSE_DOCUMENT_START_STATE; |
| 495 |
107 |
| DOCUMENT_END_EVENT_INIT(*event, implicit, start_mark, end_mark); |
| 496 |
|
| |
| 497 |
107 |
| return 1; |
| 498 |
|
| } |
| 499 |
|
| |
| 500 |
|
| /* |
| 501 |
|
| * Parse the productions: |
| 502 |
|
| * block_node_or_indentless_sequence ::= |
| 503 |
|
| * ALIAS |
| 504 |
|
| * ***** |
| 505 |
|
| * | properties (block_content | indentless_block_sequence)? |
| 506 |
|
| * ********** * |
| 507 |
|
| * | block_content | indentless_block_sequence |
| 508 |
|
| * * |
| 509 |
|
| * block_node ::= ALIAS |
| 510 |
|
| * ***** |
| 511 |
|
| * | properties block_content? |
| 512 |
|
| * ********** * |
| 513 |
|
| * | block_content |
| 514 |
|
| * * |
| 515 |
|
| * flow_node ::= ALIAS |
| 516 |
|
| * ***** |
| 517 |
|
| * | properties flow_content? |
| 518 |
|
| * ********** * |
| 519 |
|
| * | flow_content |
| 520 |
|
| * * |
| 521 |
|
| * properties ::= TAG ANCHOR? | ANCHOR TAG? |
| 522 |
|
| * ************************* |
| 523 |
|
| * block_content ::= block_collection | flow_collection | SCALAR |
| 524 |
|
| * ****** |
| 525 |
|
| * flow_content ::= flow_collection | SCALAR |
| 526 |
|
| * ****** |
| 527 |
|
| */ |
| 528 |
|
| |
| 529 |
|
| static int |
| 530 |
486 |
| yaml_parser_parse_node(yaml_parser_t *parser, yaml_event_t *event, |
| 531 |
|
| int block, int indentless_sequence) |
| 532 |
|
| { |
| 533 |
|
| yaml_token_t *token; |
| 534 |
486 |
| yaml_char_t *anchor = NULL; |
| 535 |
486 |
| yaml_char_t *tag_handle = NULL; |
| 536 |
486 |
| yaml_char_t *tag_suffix = NULL; |
| 537 |
486 |
| yaml_char_t *tag = NULL; |
| 538 |
|
| yaml_mark_t start_mark, end_mark, tag_mark; |
| 539 |
|
| int implicit; |
| 540 |
|
| |
| 541 |
486 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
0 |
486 |
486 |
| token = PEEK_TOKEN(parser); |
0 |
0 |
0 |
|
| 542 |
486 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
486 |
486 |
|
| 543 |
|
| |
| 544 |
486 |
▶ | if (token->type == YAML_ALIAS_TOKEN) |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_ALIAS_TOKEN) |
16 |
470 |
486 |
|
| 545 |
|
| { |
| 546 |
16 |
| parser->state = POP(parser, parser->states); |
| 547 |
16 |
| ALIAS_EVENT_INIT(*event, token->data.alias.value, |
| 548 |
|
| token->start_mark, token->end_mark); |
| 549 |
16 |
| SKIP_TOKEN(parser); |
| 550 |
16 |
| return 1; |
| 551 |
|
| } |
| 552 |
|
| |
| 553 |
|
| else |
| 554 |
|
| { |
| 555 |
470 |
| start_mark = end_mark = token->start_mark; |
| 556 |
|
| |
| 557 |
470 |
▶ | if (token->type == YAML_ANCHOR_TOKEN) |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_ANCHOR_TOKEN) |
17 |
453 |
470 |
|
| 558 |
|
| { |
| 559 |
17 |
| anchor = token->data.anchor.value; |
| 560 |
17 |
| start_mark = token->start_mark; |
| 561 |
17 |
| end_mark = token->end_mark; |
| 562 |
17 |
| SKIP_TOKEN(parser); |
| 563 |
17 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
17 |
0 |
17 |
| token = PEEK_TOKEN(parser); |
17 |
0 |
17 |
|
| 564 |
17 |
▶ | if (!token) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) |
0 |
17 |
17 |
|
| 565 |
0 |
| goto error; |
| 566 |
17 |
▶ | if (token->type == YAML_TAG_TOKEN) |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_TAG_TOKEN) |
4 |
13 |
17 |
|
| 567 |
|
| { |
| 568 |
4 |
| tag_handle = token->data.tag.handle; |
| 569 |
4 |
| tag_suffix = token->data.tag.suffix; |
| 570 |
4 |
| tag_mark = token->start_mark; |
| 571 |
4 |
| end_mark = token->end_mark; |
| 572 |
4 |
| SKIP_TOKEN(parser); |
| 573 |
4 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
4 |
0 |
4 |
| token = PEEK_TOKEN(parser); |
4 |
0 |
4 |
|
| 574 |
4 |
▶ | if (!token) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) |
0 |
4 |
4 |
|
| 575 |
0 |
| goto error; |
| 576 |
|
| } |
| 577 |
|
| } |
| 578 |
453 |
▶ | else if (token->type == YAML_TAG_TOKEN) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (token->type == YAML_TAG_TOKEN) |
78 |
375 |
453 |
|
| 579 |
|
| { |
| 580 |
78 |
| tag_handle = token->data.tag.handle; |
| 581 |
78 |
| tag_suffix = token->data.tag.suffix; |
| 582 |
78 |
| start_mark = tag_mark = token->start_mark; |
| 583 |
78 |
| end_mark = token->end_mark; |
| 584 |
78 |
| SKIP_TOKEN(parser); |
| 585 |
78 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
78 |
0 |
78 |
| token = PEEK_TOKEN(parser); |
78 |
0 |
78 |
|
| 586 |
78 |
▶ | if (!token) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) |
0 |
78 |
78 |
|
| 587 |
0 |
| goto error; |
| 588 |
78 |
▶ | if (token->type == YAML_ANCHOR_TOKEN) |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_ANCHOR_TOKEN) |
0 |
78 |
78 |
|
| 589 |
|
| { |
| 590 |
0 |
| anchor = token->data.anchor.value; |
| 591 |
0 |
| end_mark = token->end_mark; |
| 592 |
0 |
| SKIP_TOKEN(parser); |
| 593 |
0 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
0 |
0 |
0 |
| token = PEEK_TOKEN(parser); |
0 |
0 |
0 |
|
| 594 |
0 |
▶ | if (!token) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) |
0 |
0 |
0 |
|
| 595 |
0 |
| goto error; |
| 596 |
|
| } |
| 597 |
|
| } |
| 598 |
|
| |
| 599 |
470 |
▶ | if (tag_handle) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (tag_handle) { |
82 |
388 |
470 |
|
| 600 |
82 |
▶ | if (!*tag_handle) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!*tag_handle) { |
2 |
80 |
82 |
|
| 601 |
2 |
| tag = tag_suffix; |
| 602 |
2 |
| yaml_free(tag_handle); |
| 603 |
2 |
| tag_handle = tag_suffix = NULL; |
| 604 |
|
| } |
| 605 |
|
| else { |
| 606 |
|
| yaml_tag_directive_t *tag_directive; |
| 607 |
80 |
| for (tag_directive = parser->tag_directives.start; |
| 608 |
151 |
▶ | tag_directive != parser->tag_directives.top; |
Branch: 1 branch
| Branch | True | False | Total |
| tag_directive != parser->tag_directives.top; |
151 |
0 |
151 |
|
| 609 |
71 |
| tag_directive ++) { |
| 610 |
151 |
▶ | if (strcmp((char *)tag_directive->handle, (char *)tag_handle) == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp((char *)tag_directive->handle, (char *)tag_handle) == 0) { |
80 |
71 |
151 |
|
| 611 |
80 |
| size_t prefix_len = strlen((char *)tag_directive->prefix); |
| 612 |
80 |
| size_t suffix_len = strlen((char *)tag_suffix); |
| 613 |
80 |
| tag = YAML_MALLOC(prefix_len+suffix_len+1); |
| 614 |
80 |
▶ | if (!tag) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!tag) { |
0 |
80 |
80 |
|
| 615 |
0 |
| parser->error = YAML_MEMORY_ERROR; |
| 616 |
0 |
| goto error; |
| 617 |
|
| } |
| 618 |
80 |
| memcpy(tag, tag_directive->prefix, prefix_len); |
| 619 |
80 |
| memcpy(tag+prefix_len, tag_suffix, suffix_len); |
| 620 |
80 |
| tag[prefix_len+suffix_len] = '\0'; |
| 621 |
80 |
| yaml_free(tag_handle); |
| 622 |
80 |
| yaml_free(tag_suffix); |
| 623 |
80 |
| tag_handle = tag_suffix = NULL; |
| 624 |
80 |
| break; |
| 625 |
|
| } |
| 626 |
|
| } |
| 627 |
80 |
▶ | if (!tag) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!tag) { |
0 |
80 |
80 |
|
| 628 |
0 |
| yaml_parser_set_parser_error_context(parser, |
| 629 |
|
| "while parsing a node", start_mark, |
| 630 |
|
| "found undefined tag handle", tag_mark); |
| 631 |
0 |
| goto error; |
| 632 |
|
| } |
| 633 |
|
| } |
| 634 |
|
| } |
| 635 |
|
| |
| 636 |
470 |
▶ | implicit = (!tag || !*tag); |
Branch: 2 branches
| Branch | True | False | Total |
| implicit = (!tag || !*tag); |
82 |
388 |
470 |
| implicit = (!tag || !*tag); |
0 |
82 |
82 |
|
| 637 |
470 |
▶ | if (indentless_sequence && token->type == YAML_BLOCK_ENTRY_TOKEN) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (indentless_sequence && token->type == YAML_BLOCK_ENTRY_TOKEN) { |
226 |
244 |
470 |
| if (indentless_sequence && token->type == YAML_BLOCK_ENTRY_TOKEN) { |
3 |
223 |
226 |
|
| 638 |
3 |
| end_mark = token->end_mark; |
| 639 |
3 |
| parser->state = YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE; |
| 640 |
3 |
| SEQUENCE_START_EVENT_INIT(*event, anchor, tag, implicit, |
| 641 |
|
| YAML_BLOCK_SEQUENCE_STYLE, start_mark, end_mark); |
| 642 |
3 |
| return 1; |
| 643 |
|
| } |
| 644 |
|
| else { |
| 645 |
467 |
▶ | if (token->type == YAML_SCALAR_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_SCALAR_TOKEN) { |
337 |
130 |
467 |
|
| 646 |
337 |
| int plain_implicit = 0; |
| 647 |
337 |
| int quoted_implicit = 0; |
| 648 |
337 |
| end_mark = token->end_mark; |
| 649 |
337 |
▶ | if ((token->data.scalar.style == YAML_PLAIN_SCALAR_STYLE && !tag) |
Branch: 2 branches
| Branch | True | False | Total |
| if ((token->data.scalar.style == YAML_PLAIN_SCALAR_STYLE && !tag) |
303 |
34 |
337 |
| if ((token->data.scalar.style == YAML_PLAIN_SCALAR_STYLE && !tag) |
28 |
275 |
303 |
|
| 650 |
62 |
▶ | || (tag && strcmp((char *)tag, "!") == 0)) { |
Branch: 2 branches
| Branch | True | False | Total |
| || (tag && strcmp((char *)tag, "!") == 0)) { |
34 |
28 |
62 |
| || (tag && strcmp((char *)tag, "!") == 0)) { |
0 |
34 |
34 |
|
| 651 |
275 |
| plain_implicit = 1; |
| 652 |
|
| } |
| 653 |
62 |
▶ | else if (!tag) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (!tag) { |
28 |
34 |
62 |
|
| 654 |
28 |
| quoted_implicit = 1; |
| 655 |
|
| } |
| 656 |
337 |
| parser->state = POP(parser, parser->states); |
| 657 |
337 |
| SCALAR_EVENT_INIT(*event, anchor, tag, |
| 658 |
|
| token->data.scalar.value, token->data.scalar.length, |
| 659 |
|
| plain_implicit, quoted_implicit, |
| 660 |
|
| token->data.scalar.style, start_mark, end_mark); |
| 661 |
337 |
| SKIP_TOKEN(parser); |
| 662 |
337 |
| return 1; |
| 663 |
|
| } |
| 664 |
130 |
▶ | else if (token->type == YAML_FLOW_SEQUENCE_START_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (token->type == YAML_FLOW_SEQUENCE_START_TOKEN) { |
12 |
118 |
130 |
|
| 665 |
12 |
| end_mark = token->end_mark; |
| 666 |
12 |
| parser->state = YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE; |
| 667 |
12 |
| SEQUENCE_START_EVENT_INIT(*event, anchor, tag, implicit, |
| 668 |
|
| YAML_FLOW_SEQUENCE_STYLE, start_mark, end_mark); |
| 669 |
12 |
| return 1; |
| 670 |
|
| } |
| 671 |
118 |
▶ | else if (token->type == YAML_FLOW_MAPPING_START_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (token->type == YAML_FLOW_MAPPING_START_TOKEN) { |
14 |
104 |
118 |
|
| 672 |
14 |
| end_mark = token->end_mark; |
| 673 |
14 |
| parser->state = YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE; |
| 674 |
14 |
| MAPPING_START_EVENT_INIT(*event, anchor, tag, implicit, |
| 675 |
|
| YAML_FLOW_MAPPING_STYLE, start_mark, end_mark); |
| 676 |
14 |
| return 1; |
| 677 |
|
| } |
| 678 |
104 |
▶ | else if (block && token->type == YAML_BLOCK_SEQUENCE_START_TOKEN) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (block && token->type == YAML_BLOCK_SEQUENCE_START_TOKEN) { |
104 |
0 |
104 |
| else if (block && token->type == YAML_BLOCK_SEQUENCE_START_TOKEN) { |
37 |
67 |
104 |
|
| 679 |
37 |
| end_mark = token->end_mark; |
| 680 |
37 |
| parser->state = YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE; |
| 681 |
37 |
| SEQUENCE_START_EVENT_INIT(*event, anchor, tag, implicit, |
| 682 |
|
| YAML_BLOCK_SEQUENCE_STYLE, start_mark, end_mark); |
| 683 |
37 |
| return 1; |
| 684 |
|
| } |
| 685 |
67 |
▶ | else if (block && token->type == YAML_BLOCK_MAPPING_START_TOKEN) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (block && token->type == YAML_BLOCK_MAPPING_START_TOKEN) { |
67 |
0 |
67 |
| else if (block && token->type == YAML_BLOCK_MAPPING_START_TOKEN) { |
63 |
4 |
67 |
|
| 686 |
63 |
| end_mark = token->end_mark; |
| 687 |
63 |
| parser->state = YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE; |
| 688 |
63 |
| MAPPING_START_EVENT_INIT(*event, anchor, tag, implicit, |
| 689 |
|
| YAML_BLOCK_MAPPING_STYLE, start_mark, end_mark); |
| 690 |
63 |
| return 1; |
| 691 |
|
| } |
| 692 |
4 |
▶ | else if (anchor || tag) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (anchor || tag) { |
2 |
2 |
4 |
| else if (anchor || tag) { |
2 |
0 |
2 |
|
| 693 |
4 |
| yaml_char_t *value = YAML_MALLOC(1); |
| 694 |
4 |
▶ | if (!value) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!value) { |
0 |
4 |
4 |
|
| 695 |
0 |
| parser->error = YAML_MEMORY_ERROR; |
| 696 |
0 |
| goto error; |
| 697 |
|
| } |
| 698 |
4 |
| value[0] = '\0'; |
| 699 |
4 |
| parser->state = POP(parser, parser->states); |
| 700 |
4 |
| SCALAR_EVENT_INIT(*event, anchor, tag, value, 0, |
| 701 |
|
| implicit, 0, YAML_PLAIN_SCALAR_STYLE, |
| 702 |
|
| start_mark, end_mark); |
| 703 |
4 |
| return 1; |
| 704 |
|
| } |
| 705 |
|
| else { |
| 706 |
0 |
▶ | yaml_parser_set_parser_error_context(parser, |
Branch: 1 branch
| Branch | True | False | Total |
| yaml_parser_set_parser_error_context(parser, |
0 |
0 |
0 |
|
| 707 |
|
| (block ? "while parsing a block node" |
| 708 |
|
| : "while parsing a flow node"), start_mark, |
| 709 |
|
| "did not find expected node content", token->start_mark); |
| 710 |
0 |
| goto error; |
| 711 |
|
| } |
| 712 |
|
| } |
| 713 |
|
| } |
| 714 |
|
| |
| 715 |
0 |
| error: |
| 716 |
0 |
| yaml_free(anchor); |
| 717 |
0 |
| yaml_free(tag_handle); |
| 718 |
0 |
| yaml_free(tag_suffix); |
| 719 |
0 |
| yaml_free(tag); |
| 720 |
|
| |
| 721 |
0 |
| return 0; |
| 722 |
|
| } |
| 723 |
|
| |
| 724 |
|
| /* |
| 725 |
|
| * Parse the productions: |
| 726 |
|
| * block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END |
| 727 |
|
| * ******************** *********** * ********* |
| 728 |
|
| */ |
| 729 |
|
| |
| 730 |
|
| static int |
| 731 |
144 |
| yaml_parser_parse_block_sequence_entry(yaml_parser_t *parser, |
| 732 |
|
| yaml_event_t *event, int first) |
| 733 |
|
| { |
| 734 |
|
| yaml_token_t *token; |
| 735 |
|
| |
| 736 |
144 |
▶ | if (first) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (first) { |
37 |
107 |
144 |
|
| 737 |
37 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
0 |
37 |
37 |
| token = PEEK_TOKEN(parser); |
0 |
0 |
0 |
|
| 738 |
37 |
▶ | if (!PUSH(parser, parser->marks, token->start_mark)) |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, parser->marks, token->start_mark)) |
0 |
37 |
37 |
| if (!PUSH(parser, parser->marks, token->start_mark)) |
0 |
0 |
0 |
| if (!PUSH(parser, parser->marks, token->start_mark)) |
0 |
37 |
37 |
|
| 739 |
0 |
| return 0; |
| 740 |
37 |
| SKIP_TOKEN(parser); |
| 741 |
|
| } |
| 742 |
|
| |
| 743 |
144 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
137 |
7 |
144 |
| token = PEEK_TOKEN(parser); |
137 |
0 |
137 |
|
| 744 |
144 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
144 |
144 |
|
| 745 |
|
| |
| 746 |
144 |
▶ | if (token->type == YAML_BLOCK_ENTRY_TOKEN) |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_BLOCK_ENTRY_TOKEN) |
107 |
37 |
144 |
|
| 747 |
|
| { |
| 748 |
107 |
| yaml_mark_t mark = token->end_mark; |
| 749 |
107 |
| SKIP_TOKEN(parser); |
| 750 |
107 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
107 |
0 |
107 |
| token = PEEK_TOKEN(parser); |
107 |
0 |
107 |
|
| 751 |
107 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
107 |
107 |
|
| 752 |
107 |
▶ | if (token->type != YAML_BLOCK_ENTRY_TOKEN && |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type != YAML_BLOCK_ENTRY_TOKEN && |
107 |
0 |
107 |
|
| 753 |
107 |
▶ | token->type != YAML_BLOCK_END_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| token->type != YAML_BLOCK_END_TOKEN) { |
104 |
3 |
107 |
|
| 754 |
104 |
▶ | if (!PUSH(parser, parser->states, |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, parser->states, |
0 |
104 |
104 |
| if (!PUSH(parser, parser->states, |
0 |
0 |
0 |
| if (!PUSH(parser, parser->states, |
0 |
104 |
104 |
|
| 755 |
|
| YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE)) |
| 756 |
0 |
| return 0; |
| 757 |
104 |
| return yaml_parser_parse_node(parser, event, 1, 0); |
| 758 |
|
| } |
| 759 |
|
| else { |
| 760 |
3 |
| parser->state = YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE; |
| 761 |
3 |
| return yaml_parser_process_empty_scalar(parser, event, mark); |
| 762 |
|
| } |
| 763 |
|
| } |
| 764 |
|
| |
| 765 |
37 |
▶ | else if (token->type == YAML_BLOCK_END_TOKEN) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (token->type == YAML_BLOCK_END_TOKEN) |
37 |
0 |
37 |
|
| 766 |
|
| { |
| 767 |
37 |
| parser->state = POP(parser, parser->states); |
| 768 |
37 |
| (void)POP(parser, parser->marks); |
| 769 |
37 |
| SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark); |
| 770 |
37 |
| SKIP_TOKEN(parser); |
| 771 |
37 |
| return 1; |
| 772 |
|
| } |
| 773 |
|
| |
| 774 |
|
| else |
| 775 |
|
| { |
| 776 |
0 |
| return yaml_parser_set_parser_error_context(parser, |
| 777 |
0 |
| "while parsing a block collection", POP(parser, parser->marks), |
| 778 |
|
| "did not find expected '-' indicator", token->start_mark); |
| 779 |
|
| } |
| 780 |
|
| } |
| 781 |
|
| |
| 782 |
|
| /* |
| 783 |
|
| * Parse the productions: |
| 784 |
|
| * indentless_sequence ::= (BLOCK-ENTRY block_node?)+ |
| 785 |
|
| * *********** * |
| 786 |
|
| */ |
| 787 |
|
| |
| 788 |
|
| static int |
| 789 |
9 |
| yaml_parser_parse_indentless_sequence_entry(yaml_parser_t *parser, |
| 790 |
|
| yaml_event_t *event) |
| 791 |
|
| { |
| 792 |
|
| yaml_token_t *token; |
| 793 |
|
| |
| 794 |
9 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
5 |
4 |
9 |
| token = PEEK_TOKEN(parser); |
5 |
0 |
5 |
|
| 795 |
9 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
9 |
9 |
|
| 796 |
|
| |
| 797 |
9 |
▶ | if (token->type == YAML_BLOCK_ENTRY_TOKEN) |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_BLOCK_ENTRY_TOKEN) |
6 |
3 |
9 |
|
| 798 |
|
| { |
| 799 |
6 |
| yaml_mark_t mark = token->end_mark; |
| 800 |
6 |
| SKIP_TOKEN(parser); |
| 801 |
6 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
6 |
0 |
6 |
| token = PEEK_TOKEN(parser); |
6 |
0 |
6 |
|
| 802 |
6 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
6 |
6 |
|
| 803 |
6 |
▶ | if (token->type != YAML_BLOCK_ENTRY_TOKEN && |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type != YAML_BLOCK_ENTRY_TOKEN && |
5 |
1 |
6 |
|
| 804 |
5 |
▶ | token->type != YAML_KEY_TOKEN && |
Branch: 1 branch
| Branch | True | False | Total |
| token->type != YAML_KEY_TOKEN && |
5 |
0 |
5 |
|
| 805 |
5 |
▶ | token->type != YAML_VALUE_TOKEN && |
Branch: 1 branch
| Branch | True | False | Total |
| token->type != YAML_VALUE_TOKEN && |
5 |
0 |
5 |
|
| 806 |
5 |
▶ | token->type != YAML_BLOCK_END_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| token->type != YAML_BLOCK_END_TOKEN) { |
5 |
0 |
5 |
|
| 807 |
5 |
▶ | if (!PUSH(parser, parser->states, |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, parser->states, |
0 |
5 |
5 |
| if (!PUSH(parser, parser->states, |
0 |
0 |
0 |
| if (!PUSH(parser, parser->states, |
0 |
5 |
5 |
|
| 808 |
|
| YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE)) |
| 809 |
0 |
| return 0; |
| 810 |
5 |
| return yaml_parser_parse_node(parser, event, 1, 0); |
| 811 |
|
| } |
| 812 |
|
| else { |
| 813 |
1 |
| parser->state = YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE; |
| 814 |
1 |
| return yaml_parser_process_empty_scalar(parser, event, mark); |
| 815 |
|
| } |
| 816 |
|
| } |
| 817 |
|
| |
| 818 |
|
| else |
| 819 |
|
| { |
| 820 |
3 |
| parser->state = POP(parser, parser->states); |
| 821 |
3 |
| SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->start_mark); |
| 822 |
3 |
| return 1; |
| 823 |
|
| } |
| 824 |
|
| } |
| 825 |
|
| |
| 826 |
|
| /* |
| 827 |
|
| * Parse the productions: |
| 828 |
|
| * block_mapping ::= BLOCK-MAPPING_START |
| 829 |
|
| * ******************* |
| 830 |
|
| * ((KEY block_node_or_indentless_sequence?)? |
| 831 |
|
| * *** * |
| 832 |
|
| * (VALUE block_node_or_indentless_sequence?)?)* |
| 833 |
|
| * |
| 834 |
|
| * BLOCK-END |
| 835 |
|
| * ********* |
| 836 |
|
| */ |
| 837 |
|
| |
| 838 |
|
| static int |
| 839 |
178 |
| yaml_parser_parse_block_mapping_key(yaml_parser_t *parser, |
| 840 |
|
| yaml_event_t *event, int first) |
| 841 |
|
| { |
| 842 |
|
| yaml_token_t *token; |
| 843 |
|
| |
| 844 |
178 |
▶ | if (first) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (first) { |
63 |
115 |
178 |
|
| 845 |
63 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
0 |
63 |
63 |
| token = PEEK_TOKEN(parser); |
0 |
0 |
0 |
|
| 846 |
63 |
▶ | if (!PUSH(parser, parser->marks, token->start_mark)) |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, parser->marks, token->start_mark)) |
0 |
63 |
63 |
| if (!PUSH(parser, parser->marks, token->start_mark)) |
0 |
0 |
0 |
| if (!PUSH(parser, parser->marks, token->start_mark)) |
0 |
63 |
63 |
|
| 847 |
0 |
| return 0; |
| 848 |
63 |
| SKIP_TOKEN(parser); |
| 849 |
|
| } |
| 850 |
|
| |
| 851 |
178 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
174 |
4 |
178 |
| token = PEEK_TOKEN(parser); |
173 |
1 |
174 |
|
| 852 |
178 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
1 |
177 |
178 |
|
| 853 |
|
| |
| 854 |
177 |
▶ | if (token->type == YAML_KEY_TOKEN) |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_KEY_TOKEN) |
116 |
61 |
177 |
|
| 855 |
|
| { |
| 856 |
116 |
| yaml_mark_t mark = token->end_mark; |
| 857 |
116 |
| SKIP_TOKEN(parser); |
| 858 |
116 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
116 |
0 |
116 |
| token = PEEK_TOKEN(parser); |
116 |
0 |
116 |
|
| 859 |
116 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
116 |
116 |
|
| 860 |
116 |
▶ | if (token->type != YAML_KEY_TOKEN && |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type != YAML_KEY_TOKEN && |
116 |
0 |
116 |
|
| 861 |
116 |
▶ | token->type != YAML_VALUE_TOKEN && |
Branch: 1 branch
| Branch | True | False | Total |
| token->type != YAML_VALUE_TOKEN && |
116 |
0 |
116 |
|
| 862 |
116 |
▶ | token->type != YAML_BLOCK_END_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| token->type != YAML_BLOCK_END_TOKEN) { |
116 |
0 |
116 |
|
| 863 |
116 |
▶ | if (!PUSH(parser, parser->states, |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, parser->states, |
0 |
116 |
116 |
| if (!PUSH(parser, parser->states, |
0 |
0 |
0 |
| if (!PUSH(parser, parser->states, |
0 |
116 |
116 |
|
| 864 |
|
| YAML_PARSE_BLOCK_MAPPING_VALUE_STATE)) |
| 865 |
0 |
| return 0; |
| 866 |
116 |
| return yaml_parser_parse_node(parser, event, 1, 1); |
| 867 |
|
| } |
| 868 |
|
| else { |
| 869 |
0 |
| parser->state = YAML_PARSE_BLOCK_MAPPING_VALUE_STATE; |
| 870 |
0 |
| return yaml_parser_process_empty_scalar(parser, event, mark); |
| 871 |
|
| } |
| 872 |
|
| } |
| 873 |
|
| |
| 874 |
61 |
▶ | else if (token->type == YAML_BLOCK_END_TOKEN) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (token->type == YAML_BLOCK_END_TOKEN) |
60 |
1 |
61 |
|
| 875 |
|
| { |
| 876 |
60 |
| parser->state = POP(parser, parser->states); |
| 877 |
60 |
| (void)POP(parser, parser->marks); |
| 878 |
60 |
| MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark); |
| 879 |
60 |
| SKIP_TOKEN(parser); |
| 880 |
60 |
| return 1; |
| 881 |
|
| } |
| 882 |
|
| |
| 883 |
|
| else |
| 884 |
|
| { |
| 885 |
1 |
| return yaml_parser_set_parser_error_context(parser, |
| 886 |
1 |
| "while parsing a block mapping", POP(parser, parser->marks), |
| 887 |
|
| "did not find expected key", token->start_mark); |
| 888 |
|
| } |
| 889 |
|
| } |
| 890 |
|
| |
| 891 |
|
| /* |
| 892 |
|
| * Parse the productions: |
| 893 |
|
| * block_mapping ::= BLOCK-MAPPING_START |
| 894 |
|
| * |
| 895 |
|
| * ((KEY block_node_or_indentless_sequence?)? |
| 896 |
|
| * |
| 897 |
|
| * (VALUE block_node_or_indentless_sequence?)?)* |
| 898 |
|
| * ***** * |
| 899 |
|
| * BLOCK-END |
| 900 |
|
| * |
| 901 |
|
| */ |
| 902 |
|
| |
| 903 |
|
| static int |
| 904 |
116 |
| yaml_parser_parse_block_mapping_value(yaml_parser_t *parser, |
| 905 |
|
| yaml_event_t *event) |
| 906 |
|
| { |
| 907 |
|
| yaml_token_t *token; |
| 908 |
|
| |
| 909 |
116 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
116 |
0 |
116 |
| token = PEEK_TOKEN(parser); |
116 |
0 |
116 |
|
| 910 |
116 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
116 |
116 |
|
| 911 |
|
| |
| 912 |
116 |
▶ | if (token->type == YAML_VALUE_TOKEN) |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_VALUE_TOKEN) |
116 |
0 |
116 |
|
| 913 |
|
| { |
| 914 |
116 |
| yaml_mark_t mark = token->end_mark; |
| 915 |
116 |
| SKIP_TOKEN(parser); |
| 916 |
116 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
116 |
0 |
116 |
| token = PEEK_TOKEN(parser); |
115 |
1 |
116 |
|
| 917 |
116 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
1 |
115 |
116 |
|
| 918 |
115 |
▶ | if (token->type != YAML_KEY_TOKEN && |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type != YAML_KEY_TOKEN && |
114 |
1 |
115 |
|
| 919 |
114 |
▶ | token->type != YAML_VALUE_TOKEN && |
Branch: 1 branch
| Branch | True | False | Total |
| token->type != YAML_VALUE_TOKEN && |
114 |
0 |
114 |
|
| 920 |
114 |
▶ | token->type != YAML_BLOCK_END_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| token->type != YAML_BLOCK_END_TOKEN) { |
114 |
0 |
114 |
|
| 921 |
114 |
▶ | if (!PUSH(parser, parser->states, |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, parser->states, |
0 |
114 |
114 |
| if (!PUSH(parser, parser->states, |
0 |
0 |
0 |
| if (!PUSH(parser, parser->states, |
0 |
114 |
114 |
|
| 922 |
|
| YAML_PARSE_BLOCK_MAPPING_KEY_STATE)) |
| 923 |
0 |
| return 0; |
| 924 |
114 |
| return yaml_parser_parse_node(parser, event, 1, 1); |
| 925 |
|
| } |
| 926 |
|
| else { |
| 927 |
1 |
| parser->state = YAML_PARSE_BLOCK_MAPPING_KEY_STATE; |
| 928 |
1 |
| return yaml_parser_process_empty_scalar(parser, event, mark); |
| 929 |
|
| } |
| 930 |
|
| } |
| 931 |
|
| |
| 932 |
|
| else |
| 933 |
|
| { |
| 934 |
0 |
| parser->state = YAML_PARSE_BLOCK_MAPPING_KEY_STATE; |
| 935 |
0 |
| return yaml_parser_process_empty_scalar(parser, event, token->start_mark); |
| 936 |
|
| } |
| 937 |
|
| } |
| 938 |
|
| |
| 939 |
|
| /* |
| 940 |
|
| * Parse the productions: |
| 941 |
|
| * flow_sequence ::= FLOW-SEQUENCE-START |
| 942 |
|
| * ******************* |
| 943 |
|
| * (flow_sequence_entry FLOW-ENTRY)* |
| 944 |
|
| * * ********** |
| 945 |
|
| * flow_sequence_entry? |
| 946 |
|
| * * |
| 947 |
|
| * FLOW-SEQUENCE-END |
| 948 |
|
| * ***************** |
| 949 |
|
| * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? |
| 950 |
|
| * * |
| 951 |
|
| */ |
| 952 |
|
| |
| 953 |
|
| static int |
| 954 |
26 |
| yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser, |
| 955 |
|
| yaml_event_t *event, int first) |
| 956 |
|
| { |
| 957 |
|
| yaml_token_t *token; |
| 958 |
|
| |
| 959 |
26 |
▶ | if (first) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (first) { |
12 |
14 |
26 |
|
| 960 |
12 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
0 |
12 |
12 |
| token = PEEK_TOKEN(parser); |
0 |
0 |
0 |
|
| 961 |
12 |
▶ | if (!PUSH(parser, parser->marks, token->start_mark)) |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, parser->marks, token->start_mark)) |
0 |
12 |
12 |
| if (!PUSH(parser, parser->marks, token->start_mark)) |
0 |
0 |
0 |
| if (!PUSH(parser, parser->marks, token->start_mark)) |
0 |
12 |
12 |
|
| 962 |
0 |
| return 0; |
| 963 |
12 |
| SKIP_TOKEN(parser); |
| 964 |
|
| } |
| 965 |
|
| |
| 966 |
26 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
25 |
1 |
26 |
| token = PEEK_TOKEN(parser); |
25 |
0 |
25 |
|
| 967 |
26 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
26 |
26 |
|
| 968 |
|
| |
| 969 |
26 |
▶ | if (token->type != YAML_FLOW_SEQUENCE_END_TOKEN) |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type != YAML_FLOW_SEQUENCE_END_TOKEN) |
14 |
12 |
26 |
|
| 970 |
|
| { |
| 971 |
14 |
▶ | if (!first) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!first) { |
5 |
9 |
14 |
|
| 972 |
5 |
▶ | if (token->type == YAML_FLOW_ENTRY_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_FLOW_ENTRY_TOKEN) { |
5 |
0 |
5 |
|
| 973 |
5 |
| SKIP_TOKEN(parser); |
| 974 |
5 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
5 |
0 |
5 |
| token = PEEK_TOKEN(parser); |
5 |
0 |
5 |
|
| 975 |
5 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
5 |
5 |
|
| 976 |
|
| } |
| 977 |
|
| else { |
| 978 |
0 |
| return yaml_parser_set_parser_error_context(parser, |
| 979 |
0 |
| "while parsing a flow sequence", POP(parser, parser->marks), |
| 980 |
|
| "did not find expected ',' or ']'", token->start_mark); |
| 981 |
|
| } |
| 982 |
|
| } |
| 983 |
|
| |
| 984 |
14 |
▶ | if (token->type == YAML_KEY_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_KEY_TOKEN) { |
1 |
13 |
14 |
|
| 985 |
1 |
| parser->state = YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE; |
| 986 |
1 |
| MAPPING_START_EVENT_INIT(*event, NULL, NULL, |
| 987 |
|
| 1, YAML_FLOW_MAPPING_STYLE, |
| 988 |
|
| token->start_mark, token->end_mark); |
| 989 |
1 |
| SKIP_TOKEN(parser); |
| 990 |
1 |
| return 1; |
| 991 |
|
| } |
| 992 |
|
| |
| 993 |
13 |
▶ | else if (token->type != YAML_FLOW_SEQUENCE_END_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (token->type != YAML_FLOW_SEQUENCE_END_TOKEN) { |
13 |
0 |
13 |
|
| 994 |
13 |
▶ | if (!PUSH(parser, parser->states, |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, parser->states, |
0 |
13 |
13 |
| if (!PUSH(parser, parser->states, |
0 |
0 |
0 |
| if (!PUSH(parser, parser->states, |
0 |
13 |
13 |
|
| 995 |
|
| YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE)) |
| 996 |
0 |
| return 0; |
| 997 |
13 |
| return yaml_parser_parse_node(parser, event, 0, 0); |
| 998 |
|
| } |
| 999 |
|
| } |
| 1000 |
|
| |
| 1001 |
12 |
| parser->state = POP(parser, parser->states); |
| 1002 |
12 |
| (void)POP(parser, parser->marks); |
| 1003 |
12 |
| SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark); |
| 1004 |
12 |
| SKIP_TOKEN(parser); |
| 1005 |
12 |
| return 1; |
| 1006 |
|
| } |
| 1007 |
|
| |
| 1008 |
|
| /* |
| 1009 |
|
| * Parse the productions: |
| 1010 |
|
| * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? |
| 1011 |
|
| * *** * |
| 1012 |
|
| */ |
| 1013 |
|
| |
| 1014 |
|
| static int |
| 1015 |
1 |
| yaml_parser_parse_flow_sequence_entry_mapping_key(yaml_parser_t *parser, |
| 1016 |
|
| yaml_event_t *event) |
| 1017 |
|
| { |
| 1018 |
|
| yaml_token_t *token; |
| 1019 |
|
| |
| 1020 |
1 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
1 |
0 |
1 |
| token = PEEK_TOKEN(parser); |
1 |
0 |
1 |
|
| 1021 |
1 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
1 |
1 |
|
| 1022 |
|
| |
| 1023 |
1 |
▶ | if (token->type != YAML_VALUE_TOKEN && token->type != YAML_FLOW_ENTRY_TOKEN |
Branch: 2 branches
| Branch | True | False | Total |
| if (token->type != YAML_VALUE_TOKEN && token->type != YAML_FLOW_ENTRY_TOKEN |
1 |
0 |
1 |
| if (token->type != YAML_VALUE_TOKEN && token->type != YAML_FLOW_ENTRY_TOKEN |
1 |
0 |
1 |
|
| 1024 |
1 |
▶ | && token->type != YAML_FLOW_SEQUENCE_END_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| && token->type != YAML_FLOW_SEQUENCE_END_TOKEN) { |
1 |
0 |
1 |
|
| 1025 |
1 |
▶ | if (!PUSH(parser, parser->states, |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, parser->states, |
0 |
1 |
1 |
| if (!PUSH(parser, parser->states, |
0 |
0 |
0 |
| if (!PUSH(parser, parser->states, |
0 |
1 |
1 |
|
| 1026 |
|
| YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE)) |
| 1027 |
0 |
| return 0; |
| 1028 |
1 |
| return yaml_parser_parse_node(parser, event, 0, 0); |
| 1029 |
|
| } |
| 1030 |
|
| else { |
| 1031 |
0 |
| yaml_mark_t mark = token->end_mark; |
| 1032 |
0 |
| SKIP_TOKEN(parser); |
| 1033 |
0 |
| parser->state = YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE; |
| 1034 |
0 |
| return yaml_parser_process_empty_scalar(parser, event, mark); |
| 1035 |
|
| } |
| 1036 |
|
| } |
| 1037 |
|
| |
| 1038 |
|
| /* |
| 1039 |
|
| * Parse the productions: |
| 1040 |
|
| * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? |
| 1041 |
|
| * ***** * |
| 1042 |
|
| */ |
| 1043 |
|
| |
| 1044 |
|
| static int |
| 1045 |
1 |
| yaml_parser_parse_flow_sequence_entry_mapping_value(yaml_parser_t *parser, |
| 1046 |
|
| yaml_event_t *event) |
| 1047 |
|
| { |
| 1048 |
|
| yaml_token_t *token; |
| 1049 |
|
| |
| 1050 |
1 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
1 |
0 |
1 |
| token = PEEK_TOKEN(parser); |
1 |
0 |
1 |
|
| 1051 |
1 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
1 |
1 |
|
| 1052 |
|
| |
| 1053 |
1 |
▶ | if (token->type == YAML_VALUE_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_VALUE_TOKEN) { |
1 |
0 |
1 |
|
| 1054 |
1 |
| SKIP_TOKEN(parser); |
| 1055 |
1 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
1 |
0 |
1 |
| token = PEEK_TOKEN(parser); |
1 |
0 |
1 |
|
| 1056 |
1 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
1 |
1 |
|
| 1057 |
1 |
▶ | if (token->type != YAML_FLOW_ENTRY_TOKEN |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type != YAML_FLOW_ENTRY_TOKEN |
1 |
0 |
1 |
|
| 1058 |
1 |
▶ | && token->type != YAML_FLOW_SEQUENCE_END_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| && token->type != YAML_FLOW_SEQUENCE_END_TOKEN) { |
1 |
0 |
1 |
|
| 1059 |
1 |
▶ | if (!PUSH(parser, parser->states, |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, parser->states, |
0 |
1 |
1 |
| if (!PUSH(parser, parser->states, |
0 |
0 |
0 |
| if (!PUSH(parser, parser->states, |
0 |
1 |
1 |
|
| 1060 |
|
| YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE)) |
| 1061 |
0 |
| return 0; |
| 1062 |
1 |
| return yaml_parser_parse_node(parser, event, 0, 0); |
| 1063 |
|
| } |
| 1064 |
|
| } |
| 1065 |
0 |
| parser->state = YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE; |
| 1066 |
0 |
| return yaml_parser_process_empty_scalar(parser, event, token->start_mark); |
| 1067 |
|
| } |
| 1068 |
|
| |
| 1069 |
|
| /* |
| 1070 |
|
| * Parse the productions: |
| 1071 |
|
| * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? |
| 1072 |
|
| * * |
| 1073 |
|
| */ |
| 1074 |
|
| |
| 1075 |
|
| static int |
| 1076 |
1 |
| yaml_parser_parse_flow_sequence_entry_mapping_end(yaml_parser_t *parser, |
| 1077 |
|
| yaml_event_t *event) |
| 1078 |
|
| { |
| 1079 |
|
| yaml_token_t *token; |
| 1080 |
|
| |
| 1081 |
1 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
1 |
0 |
1 |
| token = PEEK_TOKEN(parser); |
1 |
0 |
1 |
|
| 1082 |
1 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
1 |
1 |
|
| 1083 |
|
| |
| 1084 |
1 |
| parser->state = YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE; |
| 1085 |
|
| |
| 1086 |
1 |
| MAPPING_END_EVENT_INIT(*event, token->start_mark, token->start_mark); |
| 1087 |
1 |
| return 1; |
| 1088 |
|
| } |
| 1089 |
|
| |
| 1090 |
|
| /* |
| 1091 |
|
| * Parse the productions: |
| 1092 |
|
| * flow_mapping ::= FLOW-MAPPING-START |
| 1093 |
|
| * ****************** |
| 1094 |
|
| * (flow_mapping_entry FLOW-ENTRY)* |
| 1095 |
|
| * * ********** |
| 1096 |
|
| * flow_mapping_entry? |
| 1097 |
|
| * ****************** |
| 1098 |
|
| * FLOW-MAPPING-END |
| 1099 |
|
| * **************** |
| 1100 |
|
| * flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? |
| 1101 |
|
| * * *** * |
| 1102 |
|
| */ |
| 1103 |
|
| |
| 1104 |
|
| static int |
| 1105 |
25 |
| yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser, |
| 1106 |
|
| yaml_event_t *event, int first) |
| 1107 |
|
| { |
| 1108 |
|
| yaml_token_t *token; |
| 1109 |
|
| |
| 1110 |
25 |
▶ | if (first) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (first) { |
14 |
11 |
25 |
|
| 1111 |
14 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
0 |
14 |
14 |
| token = PEEK_TOKEN(parser); |
0 |
0 |
0 |
|
| 1112 |
14 |
▶ | if (!PUSH(parser, parser->marks, token->start_mark)) |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, parser->marks, token->start_mark)) |
0 |
14 |
14 |
| if (!PUSH(parser, parser->marks, token->start_mark)) |
0 |
0 |
0 |
| if (!PUSH(parser, parser->marks, token->start_mark)) |
0 |
14 |
14 |
|
| 1113 |
0 |
| return 0; |
| 1114 |
14 |
| SKIP_TOKEN(parser); |
| 1115 |
|
| } |
| 1116 |
|
| |
| 1117 |
25 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
23 |
2 |
25 |
| token = PEEK_TOKEN(parser); |
23 |
0 |
23 |
|
| 1118 |
25 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
25 |
25 |
|
| 1119 |
|
| |
| 1120 |
25 |
▶ | if (token->type != YAML_FLOW_MAPPING_END_TOKEN) |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type != YAML_FLOW_MAPPING_END_TOKEN) |
11 |
14 |
25 |
|
| 1121 |
|
| { |
| 1122 |
11 |
▶ | if (!first) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!first) { |
3 |
8 |
11 |
|
| 1123 |
3 |
▶ | if (token->type == YAML_FLOW_ENTRY_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_FLOW_ENTRY_TOKEN) { |
3 |
0 |
3 |
|
| 1124 |
3 |
| SKIP_TOKEN(parser); |
| 1125 |
3 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
3 |
0 |
3 |
| token = PEEK_TOKEN(parser); |
3 |
0 |
3 |
|
| 1126 |
3 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
3 |
3 |
|
| 1127 |
|
| } |
| 1128 |
|
| else { |
| 1129 |
0 |
| return yaml_parser_set_parser_error_context(parser, |
| 1130 |
0 |
| "while parsing a flow mapping", POP(parser, parser->marks), |
| 1131 |
|
| "did not find expected ',' or '}'", token->start_mark); |
| 1132 |
|
| } |
| 1133 |
|
| } |
| 1134 |
|
| |
| 1135 |
11 |
▶ | if (token->type == YAML_KEY_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_KEY_TOKEN) { |
9 |
2 |
11 |
|
| 1136 |
9 |
| SKIP_TOKEN(parser); |
| 1137 |
9 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
9 |
0 |
9 |
| token = PEEK_TOKEN(parser); |
9 |
0 |
9 |
|
| 1138 |
9 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
9 |
9 |
|
| 1139 |
9 |
▶ | if (token->type != YAML_VALUE_TOKEN |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type != YAML_VALUE_TOKEN |
9 |
0 |
9 |
|
| 1140 |
9 |
▶ | && token->type != YAML_FLOW_ENTRY_TOKEN |
Branch: 1 branch
| Branch | True | False | Total |
| && token->type != YAML_FLOW_ENTRY_TOKEN |
9 |
0 |
9 |
|
| 1141 |
9 |
▶ | && token->type != YAML_FLOW_MAPPING_END_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| && token->type != YAML_FLOW_MAPPING_END_TOKEN) { |
9 |
0 |
9 |
|
| 1142 |
9 |
▶ | if (!PUSH(parser, parser->states, |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, parser->states, |
0 |
9 |
9 |
| if (!PUSH(parser, parser->states, |
0 |
0 |
0 |
| if (!PUSH(parser, parser->states, |
0 |
9 |
9 |
|
| 1143 |
|
| YAML_PARSE_FLOW_MAPPING_VALUE_STATE)) |
| 1144 |
0 |
| return 0; |
| 1145 |
9 |
| return yaml_parser_parse_node(parser, event, 0, 0); |
| 1146 |
|
| } |
| 1147 |
|
| else { |
| 1148 |
0 |
| parser->state = YAML_PARSE_FLOW_MAPPING_VALUE_STATE; |
| 1149 |
0 |
| return yaml_parser_process_empty_scalar(parser, event, |
| 1150 |
|
| token->start_mark); |
| 1151 |
|
| } |
| 1152 |
|
| } |
| 1153 |
2 |
▶ | else if (token->type != YAML_FLOW_MAPPING_END_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (token->type != YAML_FLOW_MAPPING_END_TOKEN) { |
2 |
0 |
2 |
|
| 1154 |
2 |
▶ | if (!PUSH(parser, parser->states, |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, parser->states, |
0 |
2 |
2 |
| if (!PUSH(parser, parser->states, |
0 |
0 |
0 |
| if (!PUSH(parser, parser->states, |
0 |
2 |
2 |
|
| 1155 |
|
| YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE)) |
| 1156 |
0 |
| return 0; |
| 1157 |
2 |
| return yaml_parser_parse_node(parser, event, 0, 0); |
| 1158 |
|
| } |
| 1159 |
|
| } |
| 1160 |
|
| |
| 1161 |
14 |
| parser->state = POP(parser, parser->states); |
| 1162 |
14 |
| (void)POP(parser, parser->marks); |
| 1163 |
14 |
| MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark); |
| 1164 |
14 |
| SKIP_TOKEN(parser); |
| 1165 |
14 |
| return 1; |
| 1166 |
|
| } |
| 1167 |
|
| |
| 1168 |
|
| /* |
| 1169 |
|
| * Parse the productions: |
| 1170 |
|
| * flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? |
| 1171 |
|
| * * ***** * |
| 1172 |
|
| */ |
| 1173 |
|
| |
| 1174 |
|
| static int |
| 1175 |
11 |
| yaml_parser_parse_flow_mapping_value(yaml_parser_t *parser, |
| 1176 |
|
| yaml_event_t *event, int empty) |
| 1177 |
|
| { |
| 1178 |
|
| yaml_token_t *token; |
| 1179 |
|
| |
| 1180 |
11 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
11 |
0 |
11 |
| token = PEEK_TOKEN(parser); |
11 |
0 |
11 |
|
| 1181 |
11 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
11 |
11 |
|
| 1182 |
|
| |
| 1183 |
11 |
▶ | if (empty) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (empty) { |
2 |
9 |
11 |
|
| 1184 |
2 |
| parser->state = YAML_PARSE_FLOW_MAPPING_KEY_STATE; |
| 1185 |
2 |
| return yaml_parser_process_empty_scalar(parser, event, |
| 1186 |
|
| token->start_mark); |
| 1187 |
|
| } |
| 1188 |
|
| |
| 1189 |
9 |
▶ | if (token->type == YAML_VALUE_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_VALUE_TOKEN) { |
9 |
0 |
9 |
|
| 1190 |
9 |
| SKIP_TOKEN(parser); |
| 1191 |
9 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
9 |
0 |
9 |
| token = PEEK_TOKEN(parser); |
9 |
0 |
9 |
|
| 1192 |
9 |
▶ | if (!token) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) return 0; |
0 |
9 |
9 |
|
| 1193 |
9 |
▶ | if (token->type != YAML_FLOW_ENTRY_TOKEN |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type != YAML_FLOW_ENTRY_TOKEN |
9 |
0 |
9 |
|
| 1194 |
9 |
▶ | && token->type != YAML_FLOW_MAPPING_END_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| && token->type != YAML_FLOW_MAPPING_END_TOKEN) { |
9 |
0 |
9 |
|
| 1195 |
9 |
▶ | if (!PUSH(parser, parser->states, |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, parser->states, |
0 |
9 |
9 |
| if (!PUSH(parser, parser->states, |
0 |
0 |
0 |
| if (!PUSH(parser, parser->states, |
0 |
9 |
9 |
|
| 1196 |
|
| YAML_PARSE_FLOW_MAPPING_KEY_STATE)) |
| 1197 |
0 |
| return 0; |
| 1198 |
9 |
| return yaml_parser_parse_node(parser, event, 0, 0); |
| 1199 |
|
| } |
| 1200 |
|
| } |
| 1201 |
|
| |
| 1202 |
0 |
| parser->state = YAML_PARSE_FLOW_MAPPING_KEY_STATE; |
| 1203 |
0 |
| return yaml_parser_process_empty_scalar(parser, event, token->start_mark); |
| 1204 |
|
| } |
| 1205 |
|
| |
| 1206 |
|
| /* |
| 1207 |
|
| * Generate an empty scalar event. |
| 1208 |
|
| */ |
| 1209 |
|
| |
| 1210 |
|
| static int |
| 1211 |
7 |
| yaml_parser_process_empty_scalar(yaml_parser_t *parser, yaml_event_t *event, |
| 1212 |
|
| yaml_mark_t mark) |
| 1213 |
|
| { |
| 1214 |
|
| yaml_char_t *value; |
| 1215 |
|
| |
| 1216 |
7 |
| value = YAML_MALLOC(1); |
| 1217 |
7 |
▶ | if (!value) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!value) { |
0 |
7 |
7 |
|
| 1218 |
0 |
| parser->error = YAML_MEMORY_ERROR; |
| 1219 |
0 |
| return 0; |
| 1220 |
|
| } |
| 1221 |
7 |
| value[0] = '\0'; |
| 1222 |
|
| |
| 1223 |
7 |
| SCALAR_EVENT_INIT(*event, NULL, NULL, value, 0, |
| 1224 |
|
| 1, 0, YAML_PLAIN_SCALAR_STYLE, mark, mark); |
| 1225 |
|
| |
| 1226 |
7 |
| return 1; |
| 1227 |
|
| } |
| 1228 |
|
| |
| 1229 |
|
| /* |
| 1230 |
|
| * Parse directives. |
| 1231 |
|
| */ |
| 1232 |
|
| |
| 1233 |
|
| static int |
| 1234 |
113 |
| yaml_parser_process_directives(yaml_parser_t *parser, |
| 1235 |
|
| yaml_version_directive_t **version_directive_ref, |
| 1236 |
|
| yaml_tag_directive_t **tag_directives_start_ref, |
| 1237 |
|
| yaml_tag_directive_t **tag_directives_end_ref) |
| 1238 |
|
| { |
| 1239 |
113 |
| yaml_tag_directive_t default_tag_directives[] = { |
| 1240 |
|
| {(yaml_char_t *)"!", (yaml_char_t *)"!"}, |
| 1241 |
|
| {(yaml_char_t *)"!!", (yaml_char_t *)"tag:yaml.org,2002:"}, |
| 1242 |
|
| {NULL, NULL} |
| 1243 |
|
| }; |
| 1244 |
|
| yaml_tag_directive_t *default_tag_directive; |
| 1245 |
113 |
| yaml_version_directive_t *version_directive = NULL; |
| 1246 |
|
| struct { |
| 1247 |
|
| yaml_tag_directive_t *start; |
| 1248 |
|
| yaml_tag_directive_t *end; |
| 1249 |
|
| yaml_tag_directive_t *top; |
| 1250 |
113 |
| } tag_directives = { NULL, NULL, NULL }; |
| 1251 |
|
| yaml_token_t *token; |
| 1252 |
|
| |
| 1253 |
113 |
▶ | if (!STACK_INIT(parser, tag_directives, yaml_tag_directive_t*)) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!STACK_INIT(parser, tag_directives, yaml_tag_directive_t*)) |
113 |
0 |
113 |
| if (!STACK_INIT(parser, tag_directives, yaml_tag_directive_t*)) |
0 |
113 |
113 |
|
| 1254 |
0 |
| goto error; |
| 1255 |
|
| |
| 1256 |
113 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
0 |
113 |
113 |
| token = PEEK_TOKEN(parser); |
0 |
0 |
0 |
|
| 1257 |
113 |
▶ | if (!token) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) |
0 |
113 |
113 |
|
| 1258 |
0 |
| goto error; |
| 1259 |
|
| |
| 1260 |
113 |
▶ | while (token->type == YAML_VERSION_DIRECTIVE_TOKEN || |
Branch: 1 branch
| Branch | True | False | Total |
| while (token->type == YAML_VERSION_DIRECTIVE_TOKEN || |
0 |
113 |
113 |
|
| 1261 |
113 |
▶ | token->type == YAML_TAG_DIRECTIVE_TOKEN) |
Branch: 1 branch
| Branch | True | False | Total |
| token->type == YAML_TAG_DIRECTIVE_TOKEN) |
0 |
113 |
113 |
|
| 1262 |
|
| { |
| 1263 |
0 |
▶ | if (token->type == YAML_VERSION_DIRECTIVE_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->type == YAML_VERSION_DIRECTIVE_TOKEN) { |
0 |
0 |
0 |
|
| 1264 |
0 |
▶ | if (version_directive) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (version_directive) { |
0 |
0 |
0 |
|
| 1265 |
0 |
| yaml_parser_set_parser_error(parser, |
| 1266 |
|
| "found duplicate %YAML directive", token->start_mark); |
| 1267 |
0 |
| goto error; |
| 1268 |
|
| } |
| 1269 |
0 |
▶ | if (token->data.version_directive.major != 1 |
Branch: 1 branch
| Branch | True | False | Total |
| if (token->data.version_directive.major != 1 |
0 |
0 |
0 |
|
| 1270 |
0 |
▶ | || token->data.version_directive.minor != 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| || token->data.version_directive.minor != 1) { |
0 |
0 |
0 |
|
| 1271 |
0 |
| yaml_parser_set_parser_error(parser, |
| 1272 |
|
| "found incompatible YAML document", token->start_mark); |
| 1273 |
0 |
| goto error; |
| 1274 |
|
| } |
| 1275 |
0 |
| version_directive = YAML_MALLOC_STATIC(yaml_version_directive_t); |
| 1276 |
0 |
▶ | if (!version_directive) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!version_directive) { |
0 |
0 |
0 |
|
| 1277 |
0 |
| parser->error = YAML_MEMORY_ERROR; |
| 1278 |
0 |
| goto error; |
| 1279 |
|
| } |
| 1280 |
0 |
| version_directive->major = token->data.version_directive.major; |
| 1281 |
0 |
| version_directive->minor = token->data.version_directive.minor; |
| 1282 |
|
| } |
| 1283 |
|
| |
| 1284 |
0 |
▶ | else if (token->type == YAML_TAG_DIRECTIVE_TOKEN) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (token->type == YAML_TAG_DIRECTIVE_TOKEN) { |
0 |
0 |
0 |
|
| 1285 |
|
| yaml_tag_directive_t value; |
| 1286 |
0 |
| value.handle = token->data.tag_directive.handle; |
| 1287 |
0 |
| value.prefix = token->data.tag_directive.prefix; |
| 1288 |
|
| |
| 1289 |
0 |
▶ | if (!yaml_parser_append_tag_directive(parser, value, 0, |
Branch: 1 branch
| Branch | True | False | Total |
| if (!yaml_parser_append_tag_directive(parser, value, 0, |
0 |
0 |
0 |
|
| 1290 |
|
| token->start_mark)) |
| 1291 |
0 |
| goto error; |
| 1292 |
0 |
▶ | if (!PUSH(parser, tag_directives, value)) |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, tag_directives, value)) |
0 |
0 |
0 |
| if (!PUSH(parser, tag_directives, value)) |
0 |
0 |
0 |
| if (!PUSH(parser, tag_directives, value)) |
0 |
0 |
0 |
|
| 1293 |
0 |
| goto error; |
| 1294 |
|
| } |
| 1295 |
|
| |
| 1296 |
0 |
| SKIP_TOKEN(parser); |
| 1297 |
0 |
▶ | token = PEEK_TOKEN(parser); |
Branch: 2 branches
| Branch | True | False | Total |
| token = PEEK_TOKEN(parser); |
0 |
0 |
0 |
| token = PEEK_TOKEN(parser); |
0 |
0 |
0 |
|
| 1298 |
0 |
▶ | if (!token) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!token) |
0 |
0 |
0 |
|
| 1299 |
0 |
| goto error; |
| 1300 |
|
| } |
| 1301 |
|
| |
| 1302 |
113 |
| for (default_tag_directive = default_tag_directives; |
| 1303 |
339 |
▶ | default_tag_directive->handle; default_tag_directive++) { |
Branch: 1 branch
| Branch | True | False | Total |
| default_tag_directive->handle; default_tag_directive++) { |
226 |
113 |
339 |
|
| 1304 |
226 |
▶ | if (!yaml_parser_append_tag_directive(parser, *default_tag_directive, 1, |
Branch: 1 branch
| Branch | True | False | Total |
| if (!yaml_parser_append_tag_directive(parser, *default_tag_directive, 1, |
0 |
226 |
226 |
|
| 1305 |
|
| token->start_mark)) |
| 1306 |
0 |
| goto error; |
| 1307 |
|
| } |
| 1308 |
|
| |
| 1309 |
113 |
▶ | if (version_directive_ref) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (version_directive_ref) { |
98 |
15 |
113 |
|
| 1310 |
98 |
| *version_directive_ref = version_directive; |
| 1311 |
|
| } |
| 1312 |
113 |
▶ | if (tag_directives_start_ref) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (tag_directives_start_ref) { |
98 |
15 |
113 |
|
| 1313 |
98 |
▶ | if (STACK_EMPTY(parser, tag_directives)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (STACK_EMPTY(parser, tag_directives)) { |
98 |
0 |
98 |
|
| 1314 |
98 |
| *tag_directives_start_ref = *tag_directives_end_ref = NULL; |
| 1315 |
98 |
| STACK_DEL(parser, tag_directives); |
| 1316 |
|
| } |
| 1317 |
|
| else { |
| 1318 |
0 |
| *tag_directives_start_ref = tag_directives.start; |
| 1319 |
0 |
| *tag_directives_end_ref = tag_directives.top; |
| 1320 |
|
| } |
| 1321 |
|
| } |
| 1322 |
|
| else { |
| 1323 |
15 |
| STACK_DEL(parser, tag_directives); |
| 1324 |
|
| } |
| 1325 |
|
| |
| 1326 |
113 |
▶ | if (!version_directive_ref) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!version_directive_ref) |
15 |
98 |
113 |
|
| 1327 |
15 |
| yaml_free(version_directive); |
| 1328 |
113 |
| return 1; |
| 1329 |
|
| |
| 1330 |
0 |
| error: |
| 1331 |
0 |
| yaml_free(version_directive); |
| 1332 |
0 |
▶ | while (!STACK_EMPTY(parser, tag_directives)) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (!STACK_EMPTY(parser, tag_directives)) { |
0 |
0 |
0 |
|
| 1333 |
0 |
| yaml_tag_directive_t tag_directive = POP(parser, tag_directives); |
| 1334 |
0 |
| yaml_free(tag_directive.handle); |
| 1335 |
0 |
| yaml_free(tag_directive.prefix); |
| 1336 |
|
| } |
| 1337 |
0 |
| STACK_DEL(parser, tag_directives); |
| 1338 |
0 |
| return 0; |
| 1339 |
|
| } |
| 1340 |
|
| |
| 1341 |
|
| /* |
| 1342 |
|
| * Append a tag directive to the directives stack. |
| 1343 |
|
| */ |
| 1344 |
|
| |
| 1345 |
|
| static int |
| 1346 |
226 |
| yaml_parser_append_tag_directive(yaml_parser_t *parser, |
| 1347 |
|
| yaml_tag_directive_t value, int allow_duplicates, yaml_mark_t mark) |
| 1348 |
|
| { |
| 1349 |
|
| yaml_tag_directive_t *tag_directive; |
| 1350 |
226 |
| yaml_tag_directive_t copy = { NULL, NULL }; |
| 1351 |
|
| |
| 1352 |
226 |
| for (tag_directive = parser->tag_directives.start; |
| 1353 |
339 |
▶ | tag_directive != parser->tag_directives.top; tag_directive ++) { |
Branch: 1 branch
| Branch | True | False | Total |
| tag_directive != parser->tag_directives.top; tag_directive ++) { |
113 |
226 |
339 |
|
| 1354 |
113 |
▶ | if (strcmp((char *)value.handle, (char *)tag_directive->handle) == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp((char *)value.handle, (char *)tag_directive->handle) == 0) { |
0 |
113 |
113 |
|
| 1355 |
0 |
▶ | if (allow_duplicates) |
Branch: 1 branch
| Branch | True | False | Total |
| if (allow_duplicates) |
0 |
0 |
0 |
|
| 1356 |
0 |
| return 1; |
| 1357 |
0 |
| return yaml_parser_set_parser_error(parser, |
| 1358 |
|
| "found duplicate %TAG directive", mark); |
| 1359 |
|
| } |
| 1360 |
|
| } |
| 1361 |
|
| |
| 1362 |
226 |
| copy.handle = yaml_strdup(value.handle); |
| 1363 |
226 |
| copy.prefix = yaml_strdup(value.prefix); |
| 1364 |
226 |
▶ | if (!copy.handle || !copy.prefix) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!copy.handle || !copy.prefix) { |
226 |
0 |
226 |
| if (!copy.handle || !copy.prefix) { |
0 |
226 |
226 |
|
| 1365 |
0 |
| parser->error = YAML_MEMORY_ERROR; |
| 1366 |
0 |
| goto error; |
| 1367 |
|
| } |
| 1368 |
|
| |
| 1369 |
226 |
▶ | if (!PUSH(parser, parser->tag_directives, copy)) |
Branch: 3 branches
| Branch | True | False | Total |
| if (!PUSH(parser, parser->tag_directives, copy)) |
0 |
226 |
226 |
| if (!PUSH(parser, parser->tag_directives, copy)) |
0 |
0 |
0 |
| if (!PUSH(parser, parser->tag_directives, copy)) |
0 |
226 |
226 |
|
| 1370 |
0 |
| goto error; |
| 1371 |
|
| |
| 1372 |
226 |
| return 1; |
| 1373 |
|
| |
| 1374 |
0 |
| error: |
| 1375 |
0 |
| yaml_free(copy.handle); |
| 1376 |
0 |
| yaml_free(copy.prefix); |
| 1377 |
0 |
| return 0; |
| 1378 |
|
| } |
| 1379 |
|
| |