Allow whitespace before commas in comma-separated lists

This commit is contained in:
Adam Chalmers
2023-10-11 17:05:19 -05:00
parent f8d0cb0b92
commit 48fa65e2e6

View File

@ -1209,7 +1209,7 @@ fn colon(i: TokenSlice) -> PResult<()> {
/// Parse a comma, optionally followed by some whitespace.
fn comma_sep(i: TokenSlice) -> PResult<()> {
(comma, opt(whitespace))
(opt(whitespace), comma, opt(whitespace))
.context(expected("a comma, optionally followed by whitespace"))
.parse_next(i)?;
Ok(())
@ -1606,6 +1606,8 @@ const mySk1 = startSketchAt([0, 0])"#;
#[test]
fn check_parsers_work_the_same() {
for (i, test_program) in [
"const myVar = min(5 , -legLen(5, 4))", // Space before comma
"const myVar = min(-legLen(5, 4), 5)",
"const myVar = 5 + 6 |> myFunc(45, %)",
"let x = 1 * (3 - 4)",
r#"const x = 1 // this is an inline comment"#,