add sepBy' and sepBy1' combinators #53
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
this PR is majorly to introduce two combinators that have similar but slightly different behavior than original
sepByandsepBy1.here is the illustration:
here we defined
cvas to be "comma separated letter 'a's". forcva1, it will accept such list ofas without any trailing spaces, but if any trailing spaces exist, it will reject, while the one that usessepBy'combinator accepts both cases.the reason why
sepBydoesn't accept the second case is,sep == spaces *> char ',' *> spaces, wheresephas actually started to acceptspacesalready when it comes to the trailing spaces, and therefore it will expect more spaces, or comma, but not eof, so it rejects the input.also another variation
sepEndBydoesn't work because it requires the input terminates by the exactsepparser.i've been looking around and couldn't find any existing solution to this incident so i ended up deciding to write one.