From: Clark C . E. <cc...@cl...> - 2002-07-05 11:19:40
|
Oren wrote regarding '^...\n' the following: | However, this raises another problem: the parser would | not be able to read data in 1k chunks from the input | stream, because it may overshoot the '...' and would | have no way to "return" these characters to the application. This is a good argument for not allowing anything between ... and the next --- besides a CRLF (and perhaps comments). I do think that there is value for a "flush" mechanism, to let the parser know that the current document is done and can be reported to the application. Or, alternatively, the parser treats all content following a ^...\n till the next ^--- as a big comment and reports it as such. Hmm. If we went this far, we'd probably have to make the three dashes mandatory so that people wouldn't get confused and try to lead their document with a text comment (the parser expecting a key/value pair). Hmm. I don't think having --- mandatory is a bad idea. Hmm. | In both use cases, the YAML parser can be isolated from the physical stream | by an adaptor that fakes an EOF when it sees a '^...'. The application would | be free to invoke a new parser on the rest of the stream (after consuming | any additional characters it wants, as in ysh, or immediatly, as in the | socket case). Regardless of the above comment musing, I can see the benefit of providing built-in support for '^...\n' such that only # comments are allowed between ... and ---. Consider this a socket "flush" operator. | So, if an application feels it needs to pack multiple YAML streams in a | single physical file (ysh and a socket interface being two good examples we | should give), it *should* make use of such a terminator for doing so. | However, the YAML parser itself should be isolated from this, in the | interest of simplicity of specifications and implementations. In other words, I see two options where YAML can do the ... thingy: a) The --- becomes mandatory, and any content before --- and between ... and --- are reported as a comment. b) The --- is still optional at the start, ... is an optional end marker, and only # comments are allowed between. In this way the YAML parser has *full* control over the input stream alleviating much of your concerns. Best, Clark -- Clark C. Evans Axista, Inc. http://www.axista.com 800.926.5525 XCOLLA Collaborative Project Management Software |