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

Conversation

jakecoffman
Copy link
Contributor

An array with newlines such as this fails to parse:

array = [1
,2]

According to the TOML spec, whitespace in arrays is ignored. I verified this behavior with a few TOML validators as well.

I've never done any Citrus before so feel free to fix any blunders, thanks!

@emancu
Copy link
Owner

emancu commented Jul 11, 2022

Thanks @jakecoffman for your contribution!

I'm still a bit unsure about your changes, they look ok but I think TOML specifies trailing comma only, nothing about leading comma.
https://toml.io/en/v1.0.0#array

The idea of failing to parse is to have an only way to do it, so the styling doesn't diverge

@jakecoffman
Copy link
Contributor Author

The spec at that URL says

Any number of newlines and comments may precede values, commas, and the closing bracket.

And the official ABNF linked at the bottom has:

array-values =  ws-comment-newline val ws-comment-newline array-sep array-values
array-values =/ ws-comment-newline val ws-comment-newline [ array-sep ]

array-sep = %x2C  ; , Comma

ws-comment-newline = *( wschar / [ comment ] newline )

So since ws-comment-newline can be between val and array-sep, that makes this valid TOML.

@emancu emancu merged commit 3573b65 into emancu:master Jul 15, 2022
@emancu
Copy link
Owner

emancu commented Jul 15, 2022

@jakecoffman Your changes were released in v2.2.0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants