]> git.huck.website - metaforge.git/commitdiff
fixed: trailing commas and newlines in array definitions
authorHuck Boles <huck@huck.website>
Wed, 24 May 2023 15:16:57 +0000 (10:16 -0500)
committerHuck Boles <huck@huck.website>
Wed, 24 May 2023 15:16:57 +0000 (10:16 -0500)
src/parser/meta.pest
src/parser/tests.rs

index e4e2073c5463c3f4eb0c10ec6da6d7bf3768eec3..a4aa0d74513b046f4bf5400a684414bffd7b51e9 100644 (file)
@@ -17,7 +17,12 @@ char   =  _{
 
 array = _{
     "[" ~ "]"
-  | "[" ~ " "* ~ string ~ (" "* ~ "," ~ " "* ~ string)* ~ " "* ~ "]"
+  | "[" 
+  ~ WHITESPACE* 
+  ~ string 
+  ~ (WHITESPACE* ~ "," ~ WHITESPACE* ~ string)* 
+  ~ WHITESPACE* ~ ","? ~ WHITESPACE*
+  ~ "]"
 }
 
 key_chars = @{ (ASCII_ALPHANUMERIC | "_" | ".")* }
index 03f929f80109bb103f7c41a486794b0bfc209619..5f30461616f192377dea99bae90b80a7dfe8b5c6 100644 (file)
@@ -11,6 +11,16 @@ fn no_spaces_in_def() {
     test_str!(r#"${v='v'}@{a=['a']}&{p='p'}"#);
 }
 
+#[test]
+fn newlines_in_array() {
+    test_str!("@{ a = [\n'stuff',\n'other stuff'\n] }");
+}
+
+#[test]
+fn trailing_commas() {
+    test_str!(r#"@{ a = ['stuff','other stuff',] }"#);
+}
+
 #[test]
 fn just_source_string() {
     test_str!(r#"This is just a &{source} snippet"#);