4 ms·
Nom is a fantastic library. I've never implemented a parser before and I found it relatively easy to pick up. Some of that is due to parser combinators in gener
by faitswulff 5y ago
Nom is a fantastic library. I've never implemented a parser before and I found it relatively easy to pick up. Some of that is due to parser combinators in general, no doubt, but it was very satisfying to be able to compose a parser with nom.
- adamch 5y agoI agree, it's surprisingly usable given how complicated parsing can be! I think the key to its ease of use, at least for me, is that you can unit test the individual parsers. You can program very iteratively, building it piece by piece and testing as you go. This is much easier than trying to design the entire parser on a whiteboard/paper and implement it in one big go, I think.
- hobofan 5y agoI can only second that, and it's only getting better over time. It used to be quite fiddly if you wanted to work on the String rather than the byte level, but that has improved a lot. I've written 4(?) different parsers with different major versions of nom, and each has been easier than the previous one. The main thing I'd like to see improved related to it would be `cookie-factory`, its basically symetric serialization library.
- royjacobs 5y agoI completely agree. I wrote a parser for my 6502 assembler and nom together with nom-locate allowed me to write a parser that could recover from errors, parse trivia, return detailed error messages with locations and make everything easily unit testable. The main drawback was that because it's a strongly typed parser combinator you can end up with some pretty inscrutable errors when you combine the parsers incorrectly.