BinaryMuse / toml-node

TOML parser for Node.js and the Browser. Parses TOML v0.4.0
http://binarymuse.github.io/toml-node/
MIT License
306 stars 30 forks source link

PEG doesn't handle quoted key names per spec #21

Closed othiym23 closed 9 years ago

othiym23 commented 9 years ago

I'm sorry I keep coming up with these picayune edge cases, but these are all things I'm trying to handle in my TOML output stream, and the rules for TOML are considerably stricter than JSON in some ways, so I'm coming up with a bunch of output I can't round-trip through toml.

It's also possible that my reading of the spec is incorrect, although I think the way it deals with the quoted key with the dot in it is just wrong.

toml.parse('["the\\ key"]\n\none = "one"\ntwo = 2\nthree = false')
// => SyntaxError: Expected "]" but " " found.
toml.parse('[a."the\\ key"]\n\none = "one"\ntwo = 2\nthree = false')
// => SyntaxError: Expected "]" but " " found.
toml.parse('[a."the-key"]\n\none = "one"\ntwo = 2\nthree = false')
{ a: { '"the-key"': { one: 'one', two: 2, three: false } } }
toml.parse('[a."the.key"]\n\none = "one"\ntwo = 2\nthree = false')
{ a: { '"the': { 'key"': [Object] } } }
BinaryMuse commented 9 years ago

Sorry for the long delay on this. I've added support plus several test cases (including the ones above). It should be good to go in v2.3.0, released today.

iarna commented 6 years ago

I'm... pretty sure this is contrary to the spec, I'll open a new issue…