Whitespace in groups
carl-wallace opened this issue · 0 comments
carl-wallace commented
I was failing to validate a large CDDL file that looked like it ought work and distilled the issue down to this pattern:
$$A //= (b =>
[+int])
The resulting error for the above was this:
error: parser errors
┌─ input:2:4
│
2 │ [+int])
│ ^ invalid group entry syntax
However, removing the new line clears the error.
$$A //= (b => [+int])
So does using a ":" instead of "=>". Additionally, when a colon is used, a newline does not cause an error.
$$A //= (b : [+int])
Or:
$$A //= (b :
[+int])
It looks to me that the issue is in whitespace handling where => is used. Adding the following at line 2606 in parser.rs fixes the issue for me. This is similar to whitespace handling for the colon case a few lines below 2606. I have not tested without the ast-comments feature enabled.
#[cfg(feature = "ast-comments")]
let _ = self.collect_comments()?;
#[cfg(not(feature = "ast-comments"))]
self.advance_newline()?;