Ticket #104 (new defect)
Opened 5 years ago
support for pushing data to the parser
| Reported by: | daveb@… | Owned by: | xi |
|---|---|---|---|
| Priority: | normal | Component: | pyyaml |
| Severity: | normal | Keywords: | |
| Cc: |
Description
It would be great if there was a small extension to the libyaml api. Basically, I want to feed data to a yaml parser incrementally so i can implement a non-blocking single-threaded server. The ideal would be if i could write (effectively):
void handle_data_available (yaml_parser_t *parser,
size_t len, const uint8_t *data)
{
if (!yaml_parser_push_data (parser, len, data))
handle_error ();
while ((parse_rv=yaml_parser_load (parser, &document)) > 0)
{
handle_document (); yaml_document_free (&document);
}
if (parse_rv == 0)
handle_parse_error ();
else if (parse_rv == -1)
{ /* need to push more data: nothing to do */ }
}
In general, most of the current API would take on a third possible return-value, -1, if there is no input stream and there is not enough data to continue.
But of course, there are numerous other implementation possibilities. If this design seems ok i can probably contribute a patch.
