From: Kirill S. <xi...@ga...> - 2006-04-14 09:33:25
|
On Friday 14 April 2006 08:54, Oren Ben-Kiki wrote: > The simple thing is to allow flow content to be non-indented. This leads > to all sort of problems, ranging from readability to breaking all type > of heuristics (folding, error bounding, etc.). The worst is: > > --- > foo: "string > containing > ... > --- > oops!" > > Today, we _know_ that a ... line ends a document and a --- line starts a > new one. Allowing flow content to be non-indented breaks that. YAML was > designed to allow efficient streaming, and being able to break a stream > into documents without parsing is important to us. I don't see any problems with this example. '...' still ends a document. PyYAML raises an error for it: yaml.scanner.ScannerError: while scanning a quoted scalar in "<string>", line 2, column 6: foo: "string ^ found unexpected document separator in "<string>", line 4, column 1: ... ^ Similar errors are raised for unclosed { or [: >>> data = """ ... sequence: [1,2,3 ... mapping: {1: 2, 3: 4} ... """ >>> yaml.load(data) [...] yaml.parser.ParserError: while scanning a flow sequence in "<string>", line 2, column 11: sequence: [1,2,3 ^ expected ',' or ']', but got ':' in "<string>", line 3, column 8: mapping: {1: 2, 3: 4} ^ > Here is an alternative. Today the rule is that all the flow content must > be more-indented than the parent node. Instead, we can change the rule > so that all scalar content must be more indented. The { [ , ] } > indicators only need to be "as indented" as the parent node. This would > mean: Actually I like this rule and think that both human and automatic emitters should adhere it. But then I don't see a compelling reason to enforce this rule in a parser. After all, parsers are expected to be more permissive than the spec requires. -- xi |