Re: On % being a valid first character in a content line

Oren Ben-Kiki <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <1244922303.20316.30.camel@nero>
On Sat, 2009-06-13 at 10:33 -0700, Joshua Choi wrote:
> I see! Thank you for the reply.
> 
> Now regarding document indicators, is the ... document end marker  
> *required* for separating a document's content from a document with  
> directives?


Yes. 9.2 states:

---
A YAML stream consists of zero or more documents. Subsequent documents
require some sort of separation marker line. If a document is not
terminated by a document end marker line, then the following document
must begin with a directives end marker line. [[so, no directives]]
...

> I was kind of confused on how directives factored into the flexible  
> parsing of YAML streams. I assumed that ... was completely optional  
> and that a % directive line could start a new document, without a ....  
> But it would make sense if the ... would be required, or else in the  
> example "%YAML 1.2" would be interpreted as part of the plain scalar  
> "Blah blah blah". Is this so?

Yes. 9.1.2 states:

---
Using directives raises a potential ambiguity. It is valid to have a “%”
character at the start of a line (e.g. as the first character of a
top-level mapping key) [[This is the phrase that you detected was wrong;
but as I have shown there are other cases]]. How, then, to distinguish
between an actual directive and a content line that happens to start
with a “%” character? 

The solution is the use of two special marker lines to control the
processing of directives, one at the start of a document and one at the
end. 

At the start of a document, lines beginning with a “%” character are
assumed to be directives. The (possibly empty) list of directives is
terminated by a directives end marker line. Lines following this marker
can safely use “%” as the first character. 

At the end of a document, a document end marker line is used to signal
the parser to begin scanning for directives again. 
...

The whole thing was a mess in 1.1 and this hopefully cleaned it up
(well, except for considering % as an indicator which I will fix today,
and hopefully lay it to rest once and for all :-).

Have fun,

	Oren Ben-Kiki


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Yaml-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/yaml-core
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.