Skip to content

Question about Many parser #165

Closed Answered by randomeizer
mackoj asked this question in Q&A
Discussion options

You must be logged in to vote

Part of your problem here is using Rest() as the main parser. It will consume all characters, including the commas and newlines. Many doesn't 'split' based on the separator, then parse the chunks. It parses from beginning to end, first processing the main parser, then checking to see if the separator is next, and if not, the terminator, and if not that, then it loops back again.

The other issue you'll find here is that the terminator actually consumes the terminator, so it won't be available for the fullLine parser to use as the separator. The good thing is, if you write it correctly, you don't need it - the separator is actually optional.

Try something like this instead:

import Parsing

let

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mackoj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants