| 84 | */ |
| 85 | |
| 86 | YAML_DECLARE(int) |
| 87 | yaml_parser_load(yaml_parser_t *parser, yaml_document_t *document) |
| 88 | { |
| 89 | yaml_event_t event; |
| 90 | |
| 91 | assert(parser); /* Non-NULL parser object is expected. */ |
| 92 | assert(document); /* Non-NULL document object is expected. */ |
| 93 | |
| 94 | memset(document, 0, sizeof(yaml_document_t)); |
| 95 | if (!STACK_INIT(parser, document->nodes, yaml_node_t*)) |
| 96 | goto error; |
| 97 | |
| 98 | if (!parser->stream_start_produced) { |
| 99 | if (!yaml_parser_parse(parser, &event)) goto error; |
| 100 | assert(event.type == YAML_STREAM_START_EVENT); |
| 101 | /* STREAM-START is expected. */ |
| 102 | } |
| 103 | |
| 104 | if (parser->stream_end_produced) { |
| 105 | return 1; |
| 106 | } |
| 107 | |
| 108 | if (!yaml_parser_parse(parser, &event)) goto error; |
| 109 | if (event.type == YAML_STREAM_END_EVENT) { |
| 110 | return 1; |
| 111 | } |
| 112 | |
| 113 | if (!STACK_INIT(parser, parser->aliases, yaml_alias_data_t*)) |
| 114 | goto error; |
| 115 | |
| 116 | parser->document = document; |
| 117 | |
| 118 | if (!yaml_parser_load_document(parser, &event)) goto error; |
| 119 | |
| 120 | yaml_parser_delete_aliases(parser); |
| 121 | parser->document = NULL; |
| 122 | |
| 123 | return 1; |
| 124 | |
| 125 | error: |
| 126 | |
| 127 | yaml_parser_delete_aliases(parser); |
| 128 | yaml_document_delete(document); |
| 129 | parser->document = NULL; |
| 130 | |
| 131 | return 0; |
| 132 | } |
| 133 | |
| 134 | /* |
| 135 | * Set composer error. |
no test coverage detected