From: Neil W. <neilw@ActiveState.com> - 2002-09-18 19:10:53
|
Brian Ingerson [18/09/02 11:59 -0700]: > The spec used to actually allow this. I even implemnted it. Then we decided > that a less indented line beginning with '#', terminates the scalar. I > personally don't care. I had thought that it makes the parsing API simpler > but perhaps that's not true. Neil? It's still true, I think. Otherwise you have to deal with "re-opening" nodes. You'll have a chunk of content, followed by a "comment" node, followed by another chunk of content. It just gets a lot more low-level. With the current system you can get multiple chunks of content (to avoid loading huge scalars into memory, the parser has an option to "chunk" them), but they're guaranteed to be contiguous. You don't have to worry about throwing away some nodes, then joining the chunks together, etc. Having said that, it's not a *huge* price to pay. And there are no extra grammar rules, because comments are special-cased in libyaml to avoid this. When the parser sees a comment token, it immediately shifts it and returns, then continues as if it were never there. This allows sticking comments anywhere without complicating the grammar rules every time we change our minds about where comments are allowed. Later, Neil |