MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / yaml_parser_load

Function yaml_parser_load

xs/tools/yaml/loader.c:88–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

fxRunContextFunction · 0.85
yaml.hFile · 0.85

Calls 5

yaml_parser_parseFunction · 0.85
yaml_document_deleteFunction · 0.85
assertFunction · 0.50

Tested by 1