From: Clark C. E. <cc...@cl...> - 2003-08-05 01:45:49
|
On Mon, Aug 04, 2003 at 05:45:11PM -0700, Brian Ingerson wrote: | Since we can't detect the indentation on the first line, what do we do? | I would bet it's a parse error, but maybe the default should be 1 | column. Or maybe two. Quotith the spec... 3.6.5 Literal A literal scalar is the simplest scalar form. No processing is performed on literal scalar characters aside from end of line normalization and stripping away the indentation. Indentation is detected from the first content line. Explicit indentation must be specified in case this yields the wrong result. So, this comes down to what it means by the "first content line", as this is somewhat unclear. I think it would mean "non-comment" line, but, we could update the spec to say "first line which is not an empty line or a comment". This would then fit with _why's usage. | The lookahead problem exists because of the following assumption: | | In some implementations (like C possibly) it might not be efficient | to read in an entire 50kb string into a growable buffer, just to | analyze it. So the implementation might just read 2kb at a time into | a static buffer and report the scalar chunk by chunk. And this is a good conservative assumption (think small devices). | But frankly, that's just being over strict. ... | So why can't we just do the right thing? Examine the whole scalar, and | make the line with the least indentation be the indicator. How about we just scan for the first non-blank line. Scannig the whole scalar for the line with the least indentation is, IMHO, not very clean and could even be dangerous (think a syntax error where someone accidentlty un-indented 1/2 way through the scalar by typing "x" in vim on the way out of the editor. | As for chunky parsers, they can just throw an exception when they've | guessed wrong. They would have had to throw the exception anyway. I'd rather not have YAML compliance vary across parsers. Bings, Clark |