Skip to content

Commit

Permalink
fix arrays with newline before comma fail to parse
Browse files Browse the repository at this point in the history
  • Loading branch information
jakecoffman committed Jul 11, 2022
1 parent bcca3a4 commit baae1d1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
12 changes: 6 additions & 6 deletions lib/toml-rb/grammars/array.citrus
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
grammar TomlRB::Arrays
include TomlRB::Primitive

rule array_comments
(indent? (comment indent?)*)
end

rule float_array
(float (space "," array_comments float)*) {
(float (indent? "," array_comments float)*) {
captures[:float].map(&:value)
}
end

rule string_array
(string (space "," array_comments string)*) {
(string (indent? "," array_comments string)*) {
captures[:string].map(&:value)
}
end

rule integer_array
(integer (space "," array_comments integer)*) {
(integer (indent? "," array_comments integer)*) {
captures[:integer].map(&:value)
}
end

rule datetime_array
(datetime (space "," array_comments datetime)*) {
(datetime (indent? "," array_comments datetime)*) {
captures[:datetime].map(&:value)
}
end

rule bool_array
(bool (space "," array_comments bool)*) {
(bool (indent? "," array_comments bool)*) {
captures[:bool].map(&:value)
}
end
Expand Down
3 changes: 2 additions & 1 deletion test/examples/valid/arrays.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"floats": [1.1, 2.1, 3.1, 410000.0],
"strings": ["a", "b", "c"],
"multiline_strings": ["This is a test string", "Other test string"],
"multiline_literal": ["This is a test string", "Other test string"]
"multiline_literal": ["This is a test string", "Other test string"],
"ignore_whitespace": [1,2,3,4]
}
3 changes: 3 additions & 0 deletions test/examples/valid/arrays.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ This \
test \
string''',
"Other test string"]
ignore_whitespace = [ 1
,2 ,3
,4 ]

0 comments on commit baae1d1

Please sign in to comment.