Re: YPaste parsing for properties

Oren Ben-Kiki <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <1178851450.25277.62.camel@nero>
On Thu, 2007-05-10 at 13:59 -0700, Burt Harris wrote:
> The ypaste tool at http://dev.yaml.org is great.   One experiment I tried:
> 
>         !foo !bar
>         One: two

Lovely!

> Results surprise me, it seems to have parsed !foo and !bar both as properties
> of the mapping.   I didn't think that was allowed under the current rules.

It isn't. I skipped the detailed productions there when I first did the
syntax - did list-of-property instead of (tag anchor?)|(anchor tag?) -
and forgot about fixing it before I uploaded everything. My bad, I'll
fix it.

> I was expecting !bar to be tied One, rather than the mapping,

Actually... IMVHO this should be simply illegal (see below).

> which is what
> happened if I moved !bar to the next line:
> 
>         !foo
>         !bar One: two

Yes, here '!foo' applies to the mapping, and '!bar' to 'One', as one would expect.

> Finally, and most surprisingly, if I put it all on one line, I get an error:
> 
>         !foo !bar One: two

Hmmm. Interesting. I'll have to look into that!

A note about properties in general - the latest version of the spec
allows properties to be on a separate line from the node, e.g.:

  a: !foo
    &bar
    baz

It turns out this leads to all sort of ambiguities - take for example

  !foo
  bar: baz

So, to defuse this, the YamlReference productions insists that the
properties will be on the same line as the node so the above would
assign !foo to the mapping. To associate !foo with 'bar' you'd need to
write:

  !foo bar: baz

FWIW, for most of the time we worked on the spec we did not allow a line
break between a node's property and its content, and none of the
examples in the spec have the properties on a separate line. I'm not
certain what is the current status of the implementations though. So...
feedback on this is welcome!

I was going to cover this in the release notes for an updated spec,
compatible with the corrected productions, which I hope to put a solid
day's work on this weekend, but the issue already came up, we might as
well talk about it now.

Have fun,

	Oren Ben-Kiki


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
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.