-
Notifications
You must be signed in to change notification settings - Fork 872
Change ABNF array definition to permit single value types only #663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d4657be
4a72cb0
37f8c1f
bd8b641
1ce4a40
94bfb5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,8 +123,20 @@ on the same line (though some values can be broken over multiple lines). | |
key = "value" | ||
``` | ||
|
||
Values must be of the following types: String, Integer, Float, Boolean, | ||
Datetime, Array, or Inline Table. Unspecified values are invalid. | ||
Values must have one of the following types. | ||
|
||
- [String](#user-content-string) | ||
- [Integer](#user-content-integer) | ||
- [Float](#user-content-float) | ||
- [Boolean](#user-content-boolean) | ||
- [Offset Date-Time](#user-content-offset-date-time) | ||
- [Local Date-Time](#user-content-local-date-time) | ||
- [Local Date](#user-content-local-date) | ||
- [Local Time](#user-content-local-time) | ||
- [Array](#user-content-array) | ||
- [Inline Table](#user-content-inline-table) | ||
|
||
Unspecified values are invalid. | ||
|
||
```toml | ||
key = # INVALID | ||
|
@@ -579,9 +591,13 @@ Array | |
----- | ||
|
||
Arrays are square brackets with values inside. Whitespace is ignored. Elements | ||
are separated by commas. Data types may not be mixed (different ways to define | ||
strings should be considered the same type, and so should arrays with different | ||
element types). | ||
are separated by commas. | ||
|
||
All values that are allowed in [key/value pairs](#user-content-keyvalue-pair) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's means... all values are allowed? I'd prefer that we rephrase this paragraph as something along the lines of:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pradyunsg "All values that are allowed in key/value pairs are also allowed in arrays..." – That (partial) sentence or something similar is essential because we have to explain which types are allowed in arrays (String, Integer, Float, Boolean, Offset Date-Time, Local Date-Time, Local Date, Local Time, Array, Inline Table) and which are not (Table, Array of Tables), and currently we don't. It might be possible to rephrase it a bit, say: "An array collects values of any of the types that are allowed in key/value pairs..." But we must be explicit about this, and a backreference to the key/value pairs it much better than having to list all (currently ten) allowed types again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about we provide a separate section for Value Types, so that we can pinpoint those types in the spec? Then we can include a backreference to that section. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optionally, we could move the statements about string, array, and inline table types up to the proposed Value Types section. We'd simplify it, though, if we did that. All string values are considered the same type. All arrays are considered the same type, regardless of content. All inline tables are considered the same type, regardless of content. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having said all that, let me propose the following synthesis of both of your suggestions. We'd also include a backreference from "value type". Arrays are square brackets with values inside. Whitespace is ignored. Elements All elements within an array must have the same value type. (Examples go here.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
LGTM. |
||
are also allowed in arrays, but all values within an array must have the same | ||
data type. Different ways to define strings are considered the same type, and so | ||
are arrays with different element types, and inline tables regardless of their | ||
contents. | ||
|
||
```toml | ||
arr1 = [ 1, 2, 3 ] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,13 +188,51 @@ local-time = partial-time | |
|
||
;; Array | ||
|
||
array = array-open [ array-values ] ws-comment-newline array-close | ||
array = array-open ws-comment-newline [ array-values ] ws-comment-newline array-close | ||
|
||
array-open = %x5B ; [ | ||
array-close = %x5D ; ] | ||
|
||
array-values = ws-comment-newline val ws array-sep array-values | ||
array-values =/ ws-comment-newline val ws [ array-sep ] | ||
array-values = array-strings | ||
array-values =/ array-booleans | ||
array-values =/ array-arrays | ||
array-values =/ array-inline-tables | ||
array-values =/ array-offset-dts | ||
array-values =/ array-local-dts | ||
array-values =/ array-local-dates | ||
array-values =/ array-local-times | ||
array-values =/ array-floats | ||
array-values =/ array-integers | ||
|
||
array-strings = string ws array-sep ws-comment-newline array-strings | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. array-value-sep = ws array-sep ws-comment-newline
array-value-ending = ws [ array-sep ]
array-strings = string array-value-sep array-strings
array-strings =/ string array-value-ending |
||
array-strings =/ string ws [ array-sep ] | ||
|
||
array-booleans = boolean ws array-sep ws-comment-newline array-booleans | ||
array-booleans =/ boolean ws [ array-sep ] | ||
|
||
array-arrays = array ws array-sep ws-comment-newline array-arrays | ||
array-arrays =/ array ws [ array-sep ] | ||
|
||
array-inline-tables = inline-table ws array-sep ws-comment-newline array-inline-tables | ||
array-inline-tables =/ inline-table ws [ array-sep ] | ||
|
||
array-offset-dts = offset-date-time ws array-sep ws-comment-newline array-offset-dts | ||
array-offset-dts =/ offset-date-time ws [ array-sep ] | ||
|
||
array-local-dts = local-date-time ws array-sep ws-comment-newline array-local-dts | ||
array-local-dts =/ local-date-time ws [ array-sep ] | ||
|
||
array-local-dates = local-date ws array-sep ws-comment-newline array-local-dates | ||
array-local-dates =/ local-date ws [ array-sep ] | ||
|
||
array-local-times = local-time ws array-sep ws-comment-newline array-local-times | ||
array-local-times =/ local-time ws [ array-sep ] | ||
|
||
array-floats = float ws array-sep ws-comment-newline array-floats | ||
array-floats =/ float ws [ array-sep ] | ||
|
||
array-integers = integer ws array-sep ws-comment-newline array-integers | ||
array-integers =/ integer ws [ array-sep ] | ||
|
||
array-sep = %x2C ; , Comma | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.