-
Hello, I was just curious about lexing an array of tables. The standard that I saw here: https://toml.io/en/v1.0.0#array-of-tables states that an array of tables only requires double brackets, but unlike the boolean section: https://toml.io/en/v1.0.0#boolean that strictly states "Always lowercase." forbidding boolean value attempts such as Therefore, I just wanted to know if the following are (or should be) permitted alternatives to writing an array of tables.
After lexing those array of tables, in my mind, they end up looking like this:
Just a quick test that I did: Python Tomli ModuleWhen using python's tomli module (python 3.9 with tomli installed via pip in a virtualenv), it strictly requires that the square brackets are adjacent to each other:
Please let me know if I was looking at the wrong document and this information is documented elsewhere. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The section that you link to is right, but the devil's in the details. The standard specifies in its formal grammar, I posit that it's a lot more obvious and minimal if the brackets are constrained this way, not to mention simpler for parsers to work with. For a simple array key, just look for the next pair of right brackets. For quoted array keys, look for them after the key string. Personally, I would not want to change this, unless more significant changes to the syntax were being discussed. But that's just been my experience talking. |
Beta Was this translation helpful? Give feedback.
The section that you link to is right, but the devil's in the details. The standard specifies in its formal grammar,
toml.abnf
(linked to at the bottom of the page), that the double brackets in an array table must be adjacent; no whitespace is permitted between the left brackets or between the right brackets. So[[ThisIsValid]]
and[[ "So's This." ]]
But the whitespace between the same brackets in your examples makes those invalid.I posit that it's a lot more obvious and minimal if the brackets are constrained this way, not to mention simpler for parsers to work with. For a simple array key, just look for the next pair of right brackets. For quoted array keys, look for them after the key…