From baae1d155c97c0ee57da5c921302996f996c00cc Mon Sep 17 00:00:00 2001 From: jakecoffman Date: Mon, 11 Jul 2022 10:26:17 -0500 Subject: [PATCH] fix arrays with newline before comma fail to parse --- lib/toml-rb/grammars/array.citrus | 12 ++++++------ test/examples/valid/arrays.json | 3 ++- test/examples/valid/arrays.toml | 3 +++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/toml-rb/grammars/array.citrus b/lib/toml-rb/grammars/array.citrus index f6c5505..b44e2b6 100644 --- a/lib/toml-rb/grammars/array.citrus +++ b/lib/toml-rb/grammars/array.citrus @@ -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 diff --git a/test/examples/valid/arrays.json b/test/examples/valid/arrays.json index ac39e48..e3cde27 100644 --- a/test/examples/valid/arrays.json +++ b/test/examples/valid/arrays.json @@ -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] } diff --git a/test/examples/valid/arrays.toml b/test/examples/valid/arrays.toml index e7d733f..58952ff 100644 --- a/test/examples/valid/arrays.toml +++ b/test/examples/valid/arrays.toml @@ -17,3 +17,6 @@ This \ test \ string''', "Other test string"] +ignore_whitespace = [ 1 +,2 ,3 + ,4 ]