Dotted keys are parsed as quoted keys
sloede opened this issue · comments
According to the Keys
section of the TOML "standard" (https://github.com/toml-lang/toml/blob/d3d6f32b73369a9bfd8411a143718f7a4a84ee2c/README.md#user-content-keys), keys with unquoted dots should be interpreted as nested tables. However, cpptoml recognizes them as quoted keys, yielding unexpected results.
Example input
foo.bar = "baz"
[happy]
birthday = "to you"
What cpptoml does
When parsing the above input and pushing the root table on an ostream
, the result is something like the following:
"foo.bar" = "baz"
[happy]
birthday = "to you"
What it should be doing
As far as I can tell (please correct me if I'm wrong), this is what should be recognized:
[foo]
bar = "baz"
[happy]
birthday = "to you"
Yes, based on the wording of the "current" standard (really, a WIP draft for TOML v1.0.0), what you have specified is correct.
However, cpptoml does make clear that we target the v0.4.0 spec (the latest "released" version of TOML), which does not say anything about the availability of "." in a bare key name. In fact, the real "bug" here is that we ought to be throwing an error on the example input because it has an unquoted key that contains characters outside of A-Za-z0-9_-
.
Given that this behavior is going to change in the future, I'm inclined to accept any patch that makes the behavior match the behavior described by @sloede.