Re: Streams, directives, and explicit document end markers
William Spitzak <[email protected]>
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <[email protected]> |
I understand 1.2 allows this, what I was trying to do was supply a patch
that fixes libyaml to follow these rules.
Oren Ben-Kiki wrote:
> Not so. YAML 1.2 allows for the example you gave. See
> http://yaml.org/ypaste/587/index.html
>
> Have fun,
>
> Oren Ben-Kiki
>
>
> On Wed, 2009-12-23 at 14:16 -0800, William Spitzak wrote:
>> The new 1.2 documentation says that appending YAML streams with a "..."
>> line inserted between them should always work to append them.
>>
>> Unfortunately this is not true if the second document is an implicit one
>> (ie it has no "---" line). It appears this is literally what the
>> specification says, and also libyaml does complain about the following
>> text where two trivial implicit documents are appended with a "...":
>>
>> doc1
>> ...
>> doc2
>>
>> The following patch (against libyaml-stable branch) fixes it but also
>> makes it not require a "---" after a % directive, this may also be a
>> desirable fix:
>>
>> Index: src/parser.c
>> ===================================================================
>> --- src/parser.c (revision 369)
>> +++ src/parser.c (working copy)
>> @@ -392,18 +392,17 @@
>> token = PEEK_TOKEN(parser);
>> if (!token) goto error;
>> if (token->type != YAML_DOCUMENT_START_TOKEN) {
>> - yaml_parser_set_parser_error(parser,
>> - "did not find expected <document start>",
>> token->start_mark);
>> - goto error;
>> + end_mark = start_mark;
>> + } else {
>> + end_mark = token->end_mark;
>> + SKIP_TOKEN(parser);
>> }
>> if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE))
>> goto error;
>> parser->state = YAML_PARSE_DOCUMENT_CONTENT_STATE;
>> - end_mark = token->end_mark;
>> DOCUMENT_START_EVENT_INIT(*event, version_directive,
>> tag_directives.start, tag_directives.end, 0,
>> start_mark, end_mark);
>> - SKIP_TOKEN(parser);
>> version_directive = NULL;
>> tag_directives.start = tag_directives.end = NULL;
>> return 1;
>>
>
>
------------------------------------------------------------------------------