Skip to content
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

fix failure to parse arrays with newline before comma #138

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ]