On Wed, Jun 9, 2010 at 12:19 PM, William Spitzak <firstname.lastname@example.org> wrote:
Thank you for your time and ideas.
Ingy dot Net wrote:I do not like this at all, because now you have to make up rules for how the value is quoted and you need to implement a nested parser for this. Leading spaces? Quotes in it? Backslashes in it? In fact you might as well just put the entire YAML file into one quoted string and call that a solution. I think any real solution has to split things into the final units at the JSON level, with the only post-processing the removal of single bytes from the starts of returned strings.
MY PROPOSAL FOR JYAML:
A value with an anchor:
A value with a tag (the %XX syntax is decoded so !!a%20b is written as "!!a b"):
A value with both an anchor and tag:
["&anchor", "!tag", <value>]
["!tag", "&anchor", <value>]
A value that is a reference:
A map entry with a key that is a string with no tag or anchor:
A map entry with a key that is a reference:
A map entry where the key is any object, including numbers, null, true, false, arrays, maps, and values with anchors or tags. Here 'A' is a string generated by the converter that does not conflict with any other anchors (note that parser can distinguish these anchors because they are declared as keys, not as part of an array value):
# YAML: <key>: <value>
All string values that start with 1 or more '.' characters followed by any one of '&*!@' have a single '.' removed to get the actual value:
".!foo" -> "!foo"
"...!foo" -> "..!foo"
".1" -> ".1" # NOTE NO CHANGE!
"..." -> "..." # AGAIN NO CHANGE!
Errors: Strings starting with '&' or '!' at unexpected places are an error. Strings starting with '@' are always an error. Arrays containing strings starting with '&' or '!' must conform to one of the patterns above, otherwise they are an error.
I guess the ultimate awkward corner case would be:
A tagged custom type, which is also given an anchor, and which is
created from a map with some non-string keys and some
(suitably-escaped) reserved keys.
--- !custom &anchor55: I can't drive
"*1": "I can't drive",