I thought I mostly understood nom…

I am back to trying to parse a multiline file with nom, but I can't figure out how to stop!

I know there are things like eof, but the examples for using eof are just minimal unit tests with fixed strings, that give no explanation of how to use it in any larger context. (Grrr. Rust documentation seems to loath actually explaining things…because then it might resemble other languages?) And my web searches like to turn up obsolete examples from before nom got a big rewrite.

Here is a simplified example of what I am doing, Rust Playground , it parses along just fine, but how do I stop?

Help…

Thanks,

-kb

Disclaimer: I've not worked with nom before. However, looking at your playground link, you are parsing a string with no trailing newline and your parsers seem to be written to expect one. Either include a trailing newline in your string or rewrite your parser to accept eof, maybe like this

4 Likes

Thank you for your solution.

Turns out in my real code (not the playground I posted) one of the things I tried was looking for empty lines, but then I was screwed, if empty lines are legit, how the heck do I get out on an empty line?

-kb

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.