Re: Streams, directives, and explicit document end markers

William Spitzak <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <[email protected]>
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;


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.