Re: example 7.17 in YAML 1.2 spec 2009-07-21
Osamu TAKEUCHI <[email protected]>
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <[email protected]> |
Oren,
> On Wed, 2009-09-30 at 22:05 +0900, Osamu TAKEUCHI wrote:
>> Imagine an input:
>>
>> {::::}
>>
>> With the new rule set, I at first expected the next.
>>
>> !!map
>> ? !!str ":::"
>> : !!null
>>
>> But actually, this input became invalid under the new rule set.
>
> I must say I _like_ this being an error.
> The idea is that ':' is treated as part of the plain character if it is
> followed by something that makes it _clear_ it is not a key:value
> separator.
> Obviously in this case, there's no such indication.
> IMO _however_ you interpret it, some people will be confused.
>
> Given out #1 goal is readability, I think treating this as an error is a
> _good thing_.
Your definition does not seem to increase readability.
Let me show some examples.
Your opinion:
{a} => { "a" : null }
{a:} => { "a" : null }
{a: b} => { "a" : "b" }
{a::} => error
{a:: b} => error
{a::a} => { "a::a" : null }
{a::a:} => { "a::a" : null }
{a::a: b} => { "a::a" : "b" }
{a::a::} => error
{a::a:: b} => error
My opinion:
{a} => { "a" : null }
{a:} => { "a" : null }
{a: b} => { "a" : "b" }
{a::} => { "a:" : null }
{a:: b} => { "a:" : "b" }
{a::a} => { "a::a" : null }
{a::a:} => { "a::a" : null }
{a::a: b} => { "a::a" : "b" }
{a::a::} => { "a::a:" : null }
{a::a:: b} => { "a::a:" : "b" }
The idea is that ':' is treated as part of the plain text
unless it is followed by a delimiter in the context, which
includes a space and a line break.
My definition will be more understandable because we do not
have to think what is "something that makes it _clear_ it is
not a key:value separator." In addition, we have to look ahead
only one character. Your rule requires to look ahead many
characters.
{a:::::::::::b} => { "a:::::::::::b" : null }
{a::::::::::::} => error
Note that, in this case, we have to look ahead more than ten
characters in order to determine whether or not the first ":"
is ns-plain-char.
>> The answer seems to be the next.
>> >
>> > ( ":" /* Followed by ( ns-plain-safe(c) | "#" | ":" ) */ )
>
> There's no need to add '#' since it will be caught by ns-plain-char(c)
> since it is not preceded by a space.
There's a need to add '#' since it will not be caught by ns-plain-safe(c)
even though it is not preceded by a space nor line break. ;)
Best,
Osamu TAKEUCHI
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf